magento - access cart in external PHP file -
trying access magento cart external php file, have loaded mage , able access products & categories reason i'm unable access cart information.
shop located in www.domain.com/shop/ php file located in www.domain.com/file.php magento cookie setting set '/'
i have looked @ , tried many illustration of how info , none of them have worked, code have @ moment is:
<?php require_once '/home/admin/public_html/shop/appmage.php'; mage::app(); mage::getsingleton('checkout/cart', array('name' => 'frontend')); $cartitemscount = mage::getsingleton('checkout/cart')->getitemscount(); $carttotal = mage::helper('checkout')->formatprice(mage::getsingleton('checkout/cart')->getquote()->getgrandtotal()); echo 'you have '. $cartitemscount . ' item(s) in cart. <a class="cartgo" href="'.mage::helper('checkout/cart')->getcarturl().'">checkout</a>'; if($carttotal > 0){ echo '<span>[£'.$carttotal.']</span>'; } echo '</a>'; ?>
it works fine within magento site not external file reason. returns 0 though there product in cart.
any pointers?
try
// mage init require_once '../../app/mage.php'; umask(0); mage::init('default'); mage::getsingleton('core/session', array('name' => 'frontend')); // client session $session = mage::getsingleton('customer/session'); // cart instance $cart = mage::getsingleton('checkout/cart'); $cart->init(); $cartitemscount = $cart->getitemscount();
see magento 1.8 add together product cart using php
magento magento-1.7
No comments:
Post a Comment