cancel
Showing results for 
Search instead for 
Did you mean: 

I met a simple but troubled problem,could anyone help?

SOLVED

I met a simple but troubled problem,could anyone help?

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?

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: I met a simple but troubled problem,could anyone help?

My mistake.

I should put var in array(),not as global var.Problem solved.

View solution in original post

1 REPLY 1

Re: I met a simple but troubled problem,could anyone help?

My mistake.

I should put var in array(),not as global var.Problem solved.