skip to Main Content

i am trying add an new attribute to cart on checkout page after selecting shipping method, i can able to see the attribute on console till the payment page but after completing checkout, attribute which i am adding on checkout page it is not available on order status page and email confirmation template.It lost after checkout. here is snippet i am using to update my cart attribute:

    function updateCartAttributes(data, callback) {
      var params = {
        type: 'POST',
        url: '/cart/update.js', 
        data: data,
        dataType: 'json',
        success: function(cart) {
          if ((typeof callback) === 'function') {
            callback(cart);
          }
          else {
            Shopify.onCartUpdate(cart);
          }
        },
        error: function(XMLHttpRequest, textStatus) {
          Shopify.onError(XMLHttpRequest, textStatus);
          // $("#load").hide();
        },
        complete: function(jqxhr, text) {
           $("#load").hide();
        }
      };
      $.ajax(params);
};

This is how i am calling this function and my callback:

function noteSaved(cart){
              jQuery.getJSON('/cart.js', function(cart) { 
             console.log( JSON.stringify(cart)  );
                } );
                  $("#load").hide();
             }


             var attribute = "attributes[Tax_Note]=INTERNATIONAL ORDER: Local Taxes, VAT and/or Duty will be collected AT TIME OF DELIVERY";
             updateCartAttributes(attribute,noteSaved);

and here is the ss of payment page

enter image description here

2

Answers


  1. I think you have to add cart attributes before checkout. Anything you do in checkout is probably just thrown out as noise by Shopify. If they allowed random scripting in checkout it would cause chaos. Perhaps if you test this theory out, it will allow you to make the same note, at the cart.liquid time, and hence your attribute would exist at the end of the order cycle.

    Login or Signup to reply.
  2. I am working with Rohit on this and Shopify has told us this is indeed possible. The 1st thing is to make sure the checout.liquid is enabled then you can use the checkout.shipping_address value to invoke the pop up when the country is not USA during the checkout. Maybe this information will help.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search