Shopify 结帐脚本获取购物车属性



我正在使用shopify plus store。我想在结帐脚本编辑器中访问购物车属性。有没有办法在结帐脚本编辑器中获取购物车属性?

{
token: "18da3b31a1b1d045500ad49e17836d5a",
note: "",
attributes: {
simply_test: "1"
},
original_total_price: 2900,
total_price: 2900,
total_discount: 0,
total_weight: 0,
item_count: 1,
items: [..],
requires_shipping: true,
currency: "USD"
}

是的,这是可能的

<script>
// Get cart values
$.getJSON( "/cart.js")
    .done(function( response ) {
        console.log(response);
    })
    .fail(function( jqxhr, textStatus, error ) {
        var err = textStatus + ", " + error;
        console.log( "Request Failed: " + err );
    });

// Update cart values
$.post('/cart/update.js', {
    attributes: {
        'Gift wrap': 'maybe',
        'Name': 'Johnny Deep',
    }
});

</script> 

这应该可以让您在 Shopify 上的任何地方获得购物车属性:

await fetch('/cart.js', {
  method: 'GET'
})

我会调整您的商店,以便您将存储在购物车属性中的信息作为订单项属性转移。这些确实会转移到结帐脚本。对于购物车注释或属性看起来不太好。

相关内容