My condition: Selected Payment Gateway Eligible only for a selected customer group, id 9.
My observer:
<?php
class Gta_FilterPaymentGateway_Model_Observer
{
public function paymenter(Varien_Event_Observer $observer)
{
$currentCustomerGroup = (int)Mage::getSingleton('customer/session')->getCustomerGroupId();
if(Mage::getSingleton('customer/session')->isLoggedIn())
{
if (($observer->getMethodInstance()->getCode() == 'paytm_cc') && ($currentCustomerGroup !== 9))
{
$result = $observer->getResult();
$result->isAvailable = false;
}
}
}
}
Here i can set PayTM payment Gateway only for customer group 9, but guest customer also eligible to pay via PayTM payment gateway, how to restrict for guest customer also?
Hi @Aveeva
Please share the config.xml file code to get some help.
@Mukesh Tiwari config.xml
<?xml version="1.0"?> <config> <modules> <Gta_FilterPaymentGateway> <version>1.0.0</version> </Gta_FilterPaymentGateway> </modules> <global> <models> <gta_filterpaymentgateway> <class>Gta_FindPaymentGateway_Model</class> </gta_filterpaymentgateway> </models> <events> <payment_method_is_active> <observers> <Gta_FilterPaymentGateway_Model_Observer> <class>Gta_FilterPaymentGateway_Model_Observer</class> <method>paymenter</method> </Gta_FilterPaymentGateway_Model_Observer> </observers> </payment_method_is_active> </events> </global> </config>
Hi @Aveeva
Remove following condition from your code
if(Mage::getSingleton('customer/session')->isLoggedIn())
You are checking only for logged in customer. After removing it the code will work for guest users also.
@Mukesh Tiwari Yes i removed, Guest Customer Default Id is 0 using this,
<?php class Gta_FilterPaymentGateway_Model_Observer { public function paymenter(Varien_Event_Observer $observer) { $currentCustomerGroup = (int)Mage::getSingleton('customer/session')->getCustomerGroupId(); if (($observer->getMethodInstance()->getCode() == 'paytm_cc') && ($currentCustomerGroup !== 9) || ($currentCustomerGroup != 0)) { $result = $observer->getResult(); $result->isAvailable = false; } } }
Still getting an error, i want Guest customer not able to pay PayTm Payment method.
FabFitFun Coupon Code FabFitFun Coupon Code is the best way to avail discounts on FabFitFun store shopping, there are lots of items on which you can avail the discount, amazing offers so visit the store by clicking the button and Save your Pocket now!