【问题标题】:BigCommerce - Display buy now button on product page and cart gets automatically emptyBigCommerce - 在产品页面上显示“立即购买”按钮,购物车自动清空
【发布时间】:2019-07-24 11:05:11
【问题描述】:

在重定向到结帐页面的产品页面上显示立即购买按钮。购物车自动清空。我只想要点击“立即购买”按钮的结帐购物车中的那个产品。

function check()
    {
        console.log("hi");
            $( ".dropdown-menu .previewCart .previewCartItem .mini-cart-item-actions .cart-remove" ).each(function() {
              console.log("product-id",$(this).attr('data-cart-itemid'));
               $.ajax({url: "/cart.php?action=remove&item="+$(this).attr('data-cart-itemid'),async: false, success: function(result){
                console.log("success");
              }});
            });
        }); 
    }

【问题讨论】:

    标签: cart shopping-cart bigcommerce


    【解决方案1】:

    您似乎正在调用 URL 以从购物车中删除产品 (/cart.php?action=remove),这可以解释为什么购物车是空的。我建议使用此处记录的添加到购物车 URL:

    https://developer.bigcommerce.com/api-docs/cart-and-checkout/add-to-cart-url#add-cart-url_add-specific-sku-cart

    例如,此 URL 会将特定 URL 添加到购物车并重定向到购物车页面:

    /cart.php?action=add&sku=INSERT-SKU-HERE

    【讨论】:

    • 嗨,凯伦,感谢您的回复。我想要产品页面上的“立即购买”按钮,它仅重定向到该产品的结帐页面。如果我们先将 2-3 个产品添加到购物车,然后再从“立即购买”选项添加到该特定产品,那么我们在结账时只需要该特定产品,但现在它会在结账时显示所有产品(包括购物车产品),但我只想要那个特定的我点击立即购买选项的产品我们需要隐藏购物车产品。从您的 url 产品将转到结帐页面。
    • function check() { $( ".mini-cart-item .mini-cart-item-actions .link" ).each(function() { console.log(" product-id",$(this).attr('data-product-id')); $.ajax({url:"/cart.php?action=remove&item="+$(this).attr('data -product-id'),async: false, 成功: function(result){ console.log("success"); }}); }); } 请看代码
    猜你喜欢
    • 2015-01-15
    • 2015-05-24
    • 2016-06-20
    • 1970-01-01
    • 1970-01-01
    • 2018-04-01
    • 2014-06-06
    • 2017-10-21
    • 1970-01-01
    相关资源
    最近更新 更多