Order attributes added at Checkout are dropped

Topic summary

Issue: Cart attributes for a “Gift” option are successfully saved during checkout but do not appear on the final order (Notes section is empty) on a Shopify Plus store using a heavily customized, deprecated checkout.liquid.

Implementation details:

  • Gift fields posted as cart attributes via AJAX to /cart.js (both jQuery.ajax and fetch tested).
  • Attributes (e.g., is_gift, gift_first_name, gift_email) are visible in /cart.js throughout checkout (Customer → Shipping → Payment).
  • An unrelated “funnel” attribute script was suspected of overwriting attributes; disabling it did not help.
  • An earlier attempt stored data as nested keys (attributes.gift.first_name), which appeared but got serialized into a single string and was unusable; that code is now lost.

Context and constraints:

  • Team intentionally avoiding Checkout Extensions for speed, despite checkout.liquid deprecation.
  • Expectation was that cart attributes would carry into the order (appearing in Notes), but they are missing post-purchase.

Status:

  • Unresolved. A follow-up asks whether a fix was found, indicating no confirmed solution.

Notes:

  • Code snippets and API behavior (cart.js responses) are central to understanding the problem.
Summarized with AI on December 31. AI used: gpt-5.

Hi there,

I am working with a client’s existing Shopify store and I am trying to add a “Gift” option at Checkout, on the Customer Details page. They are a Shopify Plus store using a checkout.liquid file (which I’m aware is being deprecated) which has heavy customisations. For the sake of getting the Gift feature rolled out quickly, the plan is currently to keep it this way, so I am not looking for a Checkout Extension-based solution.

I’ve successfully added a checkbox that reveals the recipient’s name and email fields, which are named like so:

 name="attributes[gift_first_name]"

When a customer changes any of the fields related to gifts, listening to the JavaScript change event, I collect all those fields values into a giftFields object, and update the cart via the API:

Checkout.$.ajax({
  type: "POST",
  url: '/cart.js',
  dataType: 'json',
  data: { attributes: giftFields },
  success: function(res) { console.log(res); },
  error: function(err) { console.error(err); }
});

I can verify the API call is successful as it returns the cart info with the attributes property, containing the fields I provided.

After this, when a user goes to the shipping then payment page, the cart API still returns this gift data in the attributes, as I can verify in my browser’s DevTools. However, test orders performed by the client have been unsuccessful and the Notes section is empty.

Our first attempt did have the info but stored as a sub-property of attributes (attributes.gift.first_name, attributes.gift.last_name, and so on), which got encoded into a single string that could not be parsed by our post-checkout suite of tools. This semi-functional code has been lost and we’ve been trying to get this to work since, and all attempts have failed so far. The only difference is that this first attempt used fetch, versus new attempts are using jQuery’s ajax method, but

The latest test did have an attribute from another script to register the “funnel” the user took, and I feared it was overwriting all of the attributes, but disabling that code had no effect, and did not affect the first test we did.

I am a developer so I am very comfortable with all of this process, but cannot figure out why Shopify is dropping the attributes, which are clearly registered into the cart as the DevTools show when I run the following code:

fetch(window.location.origin + '/cart.js');

// Returns the following (truncated):
{
    ...
    "note": null,
    "attributes": {
        "is_gift": "true",
        "anticipated_gifting_date": "2023-12-22",
        "gift_first_name": "John",
        "gift_last_name": "Doe",
        "gift_email": "jd@example.com"
    },
    ...
}

I would love some help to get this sorted out as it seems like a very simple addition, and I feel I must be missing something that might be common knowledge among Shopify devs.

Thank you in advance for any and all help, and happy holidays!

Chris

2 Likes

Did you ever fix this? Or someone else? My client has the same problem..