I create a function base on getAddToCartUrl at
core/mage/catalog/product/abstract.php class Mage_Catalog_Block_Product_Abstract
public function getAddToCartUrl2($backOrNot,$product) { $session = Mage::getSingleton("core/session"); $session->setData("isbackornot",$backOrNot); //other code }
Then I call it at design/frontend/(mypath)/default/template/catalog/product/list.phtml
<button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick= "setLocation('<?php echo $this->getAddToCartUrl2(false,$_product)?>')"> <span><span> <?php echo $this->__('Buy Immediately') ?> </span></span></button> <a href="#" onclick= "setLocation('<?php echo $this->getAddToCartUrl2(true,$_product)?>')"> <?php echo $this->__('Add to Cart') ?></a>
Why can't it work correctly?When I click Buy Immediately and Add to Cart button at frontend ,$backOrNot in getAddToCartUrl2 is always true?
Solved! Go to Solution.
My mistake.
I should put var in array(),not as global var.Problem solved.