I want to get customer balance(store credit) by customer id in custom collection.
I am loading credit memo collection, so i want to show remaining customer balance with that.
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.Sign up to join this community
Below is the code which useful to get store credit..
<?php use \Magento\Framework\App\Bootstrap; require __DIR__ . '/app/bootstrap.php'; $bootstrap = Bootstrap::create(BP, $_SERVER); $objectManager = $bootstrap->getObjectManager(); $instance = \Magento\Framework\App\ObjectManager::getInstance(); $state = $objectManager->get('\Magento\Framework\App\State'); $state->setAreaCode('frontend'); $balanceCollection = $objectManager->get('Magento\CustomerBalance\Model\BalanceFactory'); $model = $balanceCollection->create(); $model->setCustomerId(1)->loadByCustomer(); // put your customer id here echo $model->getAmount(); ?>