Magento:查询字符串直接添加到购物车链接
我在为Magento创建直接添加到购物车链接时遇到了一些困难。我已经阅读了关于类似问题的其他q/a,但找不到我正在寻找的解决方案 我想使用的直接链接是:Magento:查询字符串直接添加到购物车链接,magento,Magento,我在为Magento创建直接添加到购物车链接时遇到了一些困难。我已经阅读了关于类似问题的其他q/a,但找不到我正在寻找的解决方案 我想使用的直接链接是: [site]/checkout/cart/add/product/[prod\u id]/form\u key/[key]/ 但是,如何指定选项?上面的链接将我重定向到产品页面,并提示我“请指定选项”(特别是产品尺寸)。如何正确地将大小ID合并到链接中?我想知道我在指定这一点的链接中缺少了什么,因此该链接会将客户直接发送到产品的购物车,而不仅仅
[site]/checkout/cart/add/product/[prod\u id]/form\u key/[key]/
但是,如何指定选项?上面的链接将我重定向到产品页面,并提示我“请指定选项”(特别是
产品尺寸
)。如何正确地将大小ID合并到链接中?我想知道我在指定这一点的链接中缺少了什么,因此该链接会将客户直接发送到产品的购物车,而不仅仅是将他们重定向到产品页面。这个问题也发布在magento.stackexchange上,用户马吕斯好心地给了我解决方案
This has worked for me on CE 1.7.0.2 (with sample data):
/checkout/cart/add/product/126?super_attribute[525]=100&super_attribute[272]=22
NOTE (this puzzles me a bit):
There is a difference between calling:
/checkout/cart/add/product/126?super_attribute[525]=100&super_attribute[272]=22
and
/checkout/cart/add/product/126?super_attribute[272]=22&super_attribute[525]=100
I mean the order of the super_attribute parameters is important. After calling the 2 URLs above I ended up with 2 cart lines of the same product with the same options. one looked like this:
Size Small Color Green
and the other was
Color Green Size Small
I guess if you add the products to cart via URL you should keep the order of the attributes as shown in the product view page for consistency.
按照他的建议,您可以使用该方法构建addtocart链接
我希望这将对您有所帮助。对于Magento 1.5到1.9,您可以使用此扩展直接将产品添加到购物车,并将用户重定向到购物车或结账页面