1

I am trying to create a salesrep system for a customers store. These salesreps have limited backend access and can create and edit customers and create orders for their customers as well as viewing their customers orders.

I now have the following issue:

Salesreps should be allowed different payment types than regular store users, but from the roles permissions I can't seem to allow this per role, nor per customer group (the samesrep creates an order on the customers behalf).

So I was wondering what is the best way to do this? Extend the payment type modules to be allowed by store view and use a 2nd store for the salesreps and allow / disallow the specific payment modules per store view, or write a module that checks for roles or customer groups before displaying the payment types?

/edit: Or maybe use Shoppingcart Rules, but I'm not sure these work when creating orders from the backend?

Any help is appreciated.

1

tecjam,

Hi guess that your issue has been solved by Magento Event Observer.

For Study:

  1. magentocommerce
  2. tutsplus

Fire an Observer on payment_method_is_active event.

Basic of Admin Role or Customer group or store,you can prevent to show Payment at checkout.

Module config.xml code:

<global>
    <events>
    <payment_method_is_active>
        <observers>
            <paymentfilter_payment_method_is_active>
            <type>singleton</type>
            <class>zerosubtotalpaymentmethod/observer</class>
            <method>filterpaymentmethod</method>
            </paymentfilter_payment_method_is_active>
        </observers>
    </payment_method_is_active>
    </events>
</global>

Observer code is

<?php
class Bh_ZeroSubtotalpaymentmethod_Model_Observer {

    public function filterpaymentmethod(Varien_Event_Observer $observer) {

        if (Mage::app()->getStore()->isAdmin()) {

         //currentstore is  Admin
            /* Current Admin User */
            $admin_user_session = Mage::getSingleton('admin/session');
            $adminuserId = $admin_user_session->getUser()->getUserId();
             if ($adminuserId):  //check if the admin is logged in
                /*
                $role_data = Mage::getModel('admin/user')->load($adminuserId)->getRole()->getData();
            $role_name = $role_data['role_name'];
                */
             endif

        }else{
        // 
        }



        /* call get payment method */
        $method = $observer->getEvent()->getMethodInstance();

        if($method->getCode()=='paypal_standard')
        {   $quote = $observer->getEvent()->getQuote();
            if(Mage::app()->getStore()->roundPrice($quote->getGrandTotal())<=0){
            $result = $observer->getEvent()->getResult();   
            $result->isAvailable = false;
            }
            return;
        }
        if($method->getCode()=='free'){
            $quote = $observer->getEvent()->getQuote();
            if(Mage::app()->getStore()->roundPrice($quote->getGrandTotal())>0){
            $result = $observer->getEvent()->getResult();   
            $result->isAvailable = false;
            return;
            }
        }
        return;
    }
}
?>
  • Thanks again Amit, you've helped me for the 2nd time in as many days =) – tecjam Feb 6 '15 at 15:54
  • wait is give more details.... – Amit Bera Feb 6 '15 at 15:55
1

Have a look at this extension. It allows you to set payment methods to only be used in the backend http://www.magentocommerce.com/magento-connect/admin-payments.html

The code is available on github (https://github.com/getsquare/Magento-Admin-Payments)

The event that you would want to observe is payment_method_is_active.

<adminhtml>
    <events>
        <payment_method_is_active>
            <observers>
                ...
            </observers>
        </payment_method_is_active>
    </events>
</adminhtml>

In you observer

$event = $observer->getEvent();
$paymentMethod = $event->getMethodInstance();

$result = $observer->getResult();
$result->isAvailable = true;

You can do checks agains the payment method code etc $paymentMethod->getCode()

$result->isAvailable = true; will allow the payment method to be used

  • This looks like a great alternative. I'll check it out. Thanks. – tecjam Feb 9 '15 at 8:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.