Я попытался написать небольшое расширение, чтобы отключить способ оплаты (называемый IsrInvoice), если пользователь обращается к кассе в качестве гостевого пользователя.Magento deactivate Способ оплаты для гостя
/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);
}
}
}
Кто-нибудь знает, что я делаю неправильно, потому что он не работает! Есть ли способ проверить, что загружено?
Большое спасибо за советы, Стефан
Идея состоит в том, чтобы не отключать выезд для гостей, чтобы разрешить/запретить способы оплаты, если вы гость! –