How do I update customer store credit programmatically

≡放荡痞女 提交于 2019-12-05 15:21:22

Try this

$balance = Mage::getModel('enterprise_customerbalance/balance')
                    ->setCustomer($customer)
                    ->setWebsiteId($websiteId)
                    ->setAmountDelta($anyNumber)
                    ->setComment($data['comment']);

$balance->save();

take more look at function customerSaveAfter() in observer of customerBalance module

user2965205

This will work perfectly

$balance = Mage::getModel('enterprise_customerbalance/balance');
$balance->setCustomerId($customer_id)
        ->setWebsiteId(Mage::app()->getStore()->getWebsiteId())
        ->loadByCustomer();

$current_balance = $balance->getAmount();
$comment = 'This is a comment that will appear in the credit update history';

// add store credit
$balance->setAmount($current_balance);
$balance->setAmountDelta($amount_to_be_added);
$balance->setUpdatedActionAdditionalInfo($comment);
$balance->setHistoryAction(1); // 1= updated
$balance->save();
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!