简体   繁体   English

Magento分组产品的单独“添加到购物车”按钮

[英]Individual “Add To Cart” Button for Magento Grouped Products

I am trying to create individual "Add to Cart" buttons for each product in the Grouped Products table in a magento store but am unsure of how to do this. 我试图在magento商店的“分组产品”表中为每个产品创建单独的“添加到购物车”按钮,但是不确定如何执行此操作。

At the moment the table that is shown for a grouped product on a product page has a column for the product name, the products price and a quantity box for users to enter their requirement before clicking an " add to cart" button below the table. 目前,在产品页面上为分组产品显示的表格中有一列产品名称,产品价格和数量框,供用户在单击表下方的“添加到购物车”按钮之前输入其要求。

I would like the quantity column to be an individual "add to cart" button for each of the grouped products that adds 1 of that option into the cart. 我希望数量列成为每个分组产品的单独“添加到购物车”按钮,以将其中一个选项添加到购物车中。

I have ftp access etc and the magento store version is community 1.7.0.2 我有ftp访问权限,并且magento商店的版本是社区1.7.0.2

You can achieve this modifying your product template. 您可以完成修改产品模板的操作。 It is possible to add products to the cart via query string . 可以通过查询字符串将产品添加到购物车 Have a look at the controller Mage_Checkout_CartController . 看一下控制器Mage_Checkout_CartController

Add following code to the lines in your groupedproduct columns: 将以下代码添加到您的分组产品列中的行:

<button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="addtocart" onclick="setLocation('<?php echo Mage::getUrl('checkout/cart/add', array('product'=>$_item->getId(),'qty'=>1)) ?>')"/>

This worked for me: https://magento.stackexchange.com/questions/11237/add-to-cart-button-next-to-each-grouped-item 这对我有用https//magento.stackexchange.com/questions/11237/add-to-cart-button-next-to-each-grouped-item

I changed value from 我改变了value

value="<?php echo $_item->getQty()*1 ?>"

to

value="1"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM