【问题标题】:Magento: query string direct add to cart linkMagento:查询字符串直接添加到购物车链接
【发布时间】:2015-12-25 06:04:09
【问题描述】:

我在为 Magento 创建直接添加到购物车链接时遇到了一些困难。我已阅读有关类似问题的其他 q/a,但找不到我正在寻找的解决方案。

我想我想使用的直接链接是这样的:

[site]/checkout/cart/add/product/[prod_id]/form_key/[key]/

但是,我将如何指定选项?上面的链接将我重定向到产品页面,并提示我“please specify options”(特别是product size)。我如何正确地将尺码 ID 合并到链接中?我想知道我在链接中缺少什么来指定这一点,因此该链接会将客户直接发送到包含产品的购物车,而不仅仅是将他们重定向到产品页面。

【问题讨论】:

    标签: magento


    【解决方案1】:

    这个问题也发布在 magento.stackexchange 上,用户 Marius 好心地给了我解决方案...

    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.
    

    根据他的建议,您可以使用该方法构建添加到购物车的链接。

    希望对您有所帮助。

    【讨论】:

      【解决方案2】:

      对于 Magento 1.5 到 1.9,您可以使用此扩展程序将产品直接添加到购物车并将用户轻松重定向到购物车或结帐页面https://marketplace.magento.com/sukhvir-direct-product-add.html

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多