Search code examples
magentostore

Magento enterprise how to apply user store credit to Order amount on cart page


currently i am working on which apply customer store credit to customer current order automatically so once user reach payment page system automatically subtract total order amount with system credit ( so if user ordering 200$ things and he has $100 store credit then once user reach payment page his balance will be $100.

i want to do this programmatically. if anyone has any idea please msg. me.

Note : i am using Magento Enterprise. i want to apply store credit programmatically.

Thanks


Solution

  • i post this question before some days but still no replay. yesterday i found solution. here is solution. for this we need to create one controller so once user click on apply credit button then we need to update quote.

    code :

    $balanceModel = Mage::getModel('enterprise_customerbalance/balance')
                ->setCustomerId($sessionCustomer->getCustomer()->getId())
                ->setWebsiteId(Mage::app()->getWebsite()->getId())
                ->loadByCustomer()->getAmount();
             if($balanceModel > 0):
                $cart = Mage::getModel('checkout/cart')->getQuote();
                $cart->setuse_customer_balance("1");
                $cart->save();
             endif;

    that's it done.

    Thanks