简体   繁体   English

使用Magento中的默认值将可配置产品添加到购物车

[英]Adding configurable products to cart using default values in Magento

All the products in the magento site are configurable products. magento网站中的所有产品都是可配置的产品。 The add to cart button works okay in the product page. “添加到购物车”按钮在产品页面上可以正常工作。

My problem comes in when I try to add the product to the cart from the compare window, the wishlist page or related products, it doesn't add the product to the cart for the obvious reason that there is no selected option on the dropdown attribute I've added(product size). 当我尝试从比较窗口,愿望清单页面或相关产品中将产品添加到购物车时,出现了我的问题,原因很明显,下拉列表属性上没有选择的选项,所以我没有将产品添加到购物车中我已添加(产品尺寸)。

Anyway, how can I add the product to the cart from these windows using the product with the smallest size as the default value so that the customer wouldn't be redirected to the product page anymore to select a size when the link/button obviously says Add to Cart? 无论如何,我如何使用最小尺寸的产品作为默认值从这些窗口中将产品添加到购物车中,以便当链接/按钮明显显示时,不再将客户重定向到产品页面来选择尺寸添加到购物车?

There are 2 solutions. 有2个解决方案。

1°) Display a dropdown selection in every one of these places. 1°)在这些位置的每个位置显示一个下拉选择。 To let user choose size. 让用户选择尺寸。

2°) Define a global rule to define the default size to select (like the smallest in stock, or always the 'M', etc.) you may have a rule for every attribute set if needed. 2°)定义一个全局规则,以定义要选择的默认大小(例如最小的库存,或始终为“ M”等),如果需要,您可以为每个属性集设置一个规则。 Then modify these area to show information of the configurable except price and add to cart button that are taken from the "default" simple product, the one with the default attribute value. 然后修改这些区域以显示除价格外的其他可配置信息,并添加到购物车按钮,这些信息取自“默认”简单产品,即具有默认属性值的产品。

!! Be sure to always have a default size (ie. your rule have some 'else'/'catch' part to always find a size even if 'M' doesn't exist or isn't in stock). 确保始终使用默认大小(即,您的规则中有一些'else'/'catch'部分,即使'M'不存在或没有库存,也总是可以找到大小)。

There is no code here, choose a solution, try to do it and if you're unsuccessful someone (incl me) will help you. 此处没有代码,请选择一种解决方案,然后尝试执行此操作,如果不成功,则有人(包括我)将为您提供帮助。

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

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