Advertisement
jayelkaake

Output Magento store credit balance with Magecredit module

Jan 28th, 2015
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.07 KB | None | 0 0
  1. <?php
  2. // Loads a blank page and displays something like "Hello Jane Doe! Your store credit balance is $150.25"
  3. // If you don't already have the Magecredit Magento extension you can get it at www.magecredit.com
  4.  
  5. require_once('app/Mage.php'); //Path to Magento
  6. umask(0);
  7. Mage::app();
  8.  
  9. // Now you can run ANY Magento code you want
  10.  
  11. // Change 12 to the ID of the product you want to load
  12. $_customer = Mage::getModel('customer/customer')
  13.                 ->setWebsiteId(1) // website ID
  14.                 ->loadByEmail('janedoe@example.com'); // email address
  15.  
  16. // The next line loads the magecredit customer balance model
  17. $_balance = Mage::getModel('wf_customerbalance/balance')->setCustomer($_customer)->loadByCustomer();
  18.  
  19. // This line formats the amount using the currently loaded store's currency
  20. $_amount = Mage::app()->getStore()->formatPrice( $_balance->getAmount() );
  21.  
  22. // Output it!
  23. echo Mage::helper('core')->__('Hello %1$s! Your store credit balance is %2$s', $_customer->getName(), $_amount);
  24.  
  25. // Example Output: Hello Jane Doe! Your store credit balance is $150.25
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement