2016-07-25 55 views

回答

1

方法1:

如果你是在一個延伸Mage_Catalog_Block_Product_Abstract塊,您可以使用此行代碼塊中的類本身或在此塊的PHTML模板文件以獲取添加到購物車網址。

<button type="button" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Add to Cart')) ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_item) ?>')"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button> 

方法2:

通產品對象結帳/車助手,進入添加到購物車網址。 然後添加到購物車的鏈接地址將是:

 $product=Mage::getModel('catalog/product')->load($productId);//load the product by product id 
     $product=Mage::getModel('catalog/product')->loadByAttribute('sku',$skuNum);//or load the product by sku number 
     $product=Mage::getModel('catalog/product')->setStoreId($storeId)->loadByAttribute('sku',$skuNum);//or load the product from a given store id 
<a href="<?php echo $this->helper('checkout/cart')->getAddUrl($product);?>">Add to cart</a> //Get the add to cart url 
+0

謝謝Shahed。 –

+0

不客氣。 :) –

相關問題