skip to Main Content

I’m using shopify plus store.
I want to access cart attributes in checkout script editor.
Is there any way to get cart attributes in checkout script editor?

{
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"
}

3

Answers


  1. I would adjust your shop so that you transfer the info you store in cart attributes as line item properties. Those do transfer to checkout scripts. Does not look good for cart note or attributes.

    Login or Signup to reply.
  2. Yes, it is possible

    <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> 
    
    Login or Signup to reply.
  3. This should get you the cart attributes anywhere on Shopify:

    await fetch('/cart.js', {
      method: 'GET'
    })
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search