【发布时间】:2015-12-07 18:31:01
【问题描述】:
我尝试编写一个小扩展程序,以便在用户以访客用户身份访问结帐时停用付款方式(称为 IsrInvoice)。
/app/etc/modules/Shiftmint_Disable_GuestInvoice.xml
<?xml version="1.0"?>
<config>
<modules>
<Shiftmint_Disable_GuestInvoice>
<active>true</active>
<codePool>local</codePool>
<depends>
<Mage_Payment/>
</depends>
</Shiftmint_Disable_GuestInvoice>
</modules>
</config>
/app/code/local/Shiftmint/Disable_GuestInvoice/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Shiftmint_Disable_GuestInvoice>
<version>0.0.1</version>
</Shiftmint_Disable_GuestInvoice>
</modules>
<frontend>
<models>
<Shiftmint_Disable_GuestInvoice>
<class>Shiftmint_Disable_GuestInvoice_Model</class>
</Shiftmint_Disable_GuestInvoice>
</models>
<events>
<payment_method_is_active>
<observers>
<Shiftmint_Disable_GuestInvoice>
<type>singleton</type>
<class>Shiftmint_Disable_GuestInvoice/Observer</class>
<method>paymentMethodIsActive</method>
</Shiftmint_Disable_GuestInvoice>
</observers>
</payment_method_is_active>
</events>
</frontend>
</config>
/app/code/local/Shiftmint/Disable_GuestInvoice/Model/Observer.php
<?php
class Shiftmint_Disable_GuestInvoice_Model_Observer
{
public function paymentMethodIsActive($observer)
{
$instance = $observer->getMethodInstance();
$result = $observer->getResult();
if ($instance->getCode() == "IsrInvoice") {
if (Mage::getSingleton('customer/session')->isLoggedIn()) {
$result->isAvailable = false;
$result->save();
} else {
$result->isAvailable = true;
$result->save();
}
$observer->setResult($result);
}
}
}
有谁知道我做错了什么,因为它不起作用!有没有办法测试加载的内容?
非常感谢您的建议, 斯蒂芬
【问题讨论】:
标签: magento