創建一個簡單模塊,以在下拉菜單中顯示推薦產品。現在我想有一個按鈕「添加到購物車/購物籃」立即添加此產品。 這個方法或者如何去做?如何在自定義模塊中添加「添加到購物車」
0
A
回答
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
不客氣。 :) –
相關問題
- 1. Magento:在結帳/購物車中添加自定義模塊塊
- 2. 自定義模塊添加到購物車成功消息Magento
- 3. 如何在virtmart 2.04購物車模塊中添加刪除購物車按鈕
- 4. 如何使用prestashop中的自定義模塊添加購物車功能1.7
- 5. 在購物車中將產品添加到自定義評論
- 6. 如何添加自定義表格「添加到購物車」頁面
- 7. Magento添加到購物車滑塊
- 8. 添加購物車塊到cms頁面
- 9. 「購物車塊」和「添加到購物車」按鈕消失Prestashop
- 10. 添加購物車上的購物車
- 11. 自定義數據添加到購物車項目在Magento 1.6
- 12. 自定義「添加到購物車」按鈕,在WooCommerce
- 13. 如何添加產品到購物車?
- 14. Magento - 在購物車頁面上使用自定義模塊添加自定義模塊
- 15. 特定數量添加到購物車
- 16. 添加模式到woocommerce添加到購物車按鈕
- 17. 添加自定義字段到購物車顯示 - Ubercart 3
- 18. woocommerce hide添加到購物車基於自定義字段
- 19. woocommerce將自定義帖子類型添加到購物車
- 20. 將自定義屬性添加到magento1.7購物車側欄
- 21. 使用自定義選項將產品添加到購物車
- 22. 添加自定義字段到購物車項目
- 23. 從表單添加自定義值到購物車,prestashop
- 24. Woocommerce產品添加到購物車自定義數據img
- 25. 與產品添加自定義價格到購物車Shopify
- 26. 的Prestashop產品list.tpl自定義添加到購物車款
- 27. Woocommerce添加到購物車將整個股票添加到購物車
- 28. 阿賈克斯添加到購物車未將產品添加到購物車
- 29. WooCommerce添加到購物車驗證:防止添加到購物車
- 30. 如何在magento 1.4.1.1中添加自定義上傳圖片到購物車?
對於誰給了我-1,你想解釋爲什麼嗎? –