我正在尝试为特定客户群禁用货到付款,我想只为零售商启用一种付款方式,例如货到付款,在magento中,我尝试了一些选项,但它会抛出一些错误。我已按照这些链接enter link description here
配置文件
<?xml version="1.0"?> <config>
<modules>
<Suyati_Cashondelivery>
<version>1.6.0.0</version>
</Suyati_Cashondelivery>
</modules>
<!-- <global>
<blocks>
<checkout>
<rewrite>
<onepage_payment_methods>Suyati_Cashondelivery_Block_Methods</onepage_payment_methods>
</rewrite>
</checkout>
</blocks>
</global> -->
<events>
<payment_method_is_active>
<observers>
<paymentfilter_payment_method_is_active>
<type>singleton</type>
<class>Suyati_Cashondelivery_model_observer</class>
<method>filterpaymentmethod</method>
</paymentfilter_payment_method_is_active>
</observers>
</payment_method_is_active>
</events>
</config>
observer.php
class Suyati_Cashondelivery_model_observer
{
public function filterpaymentmethod(Varien_Event_Observer $observer) {
/* call get payment method */
$method = $observer->getEvent()->getMethodInstance();
$role = "Retailer";
/* get Quote */
$quote = $observer->getEvent()->getQuote();
/* Disable Your payment method for adminStore */
if($role == "Retiler"){
allow cash ondelivery // am not sure which code needs to be written here.
}
}
答案 0 :(得分:1)
你可以试试这个:
if ($role == 'Retailer') {
$result = $observer->getEvent()->getResult();
$result->isAvailable = true;
}