Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

replace "order.{anything}" for "checkout.order_id"

replace "order.{anything}" for "checkout.order_id"

jorgeplantz
Visitor
2 0 1

We received today an email asking us to replace "order.{anything}" for "checkout.order_id" but I cant find this [Additional Scrips] to update this. 

 

Then when I enter the settings > checkout I see in the first section of the page "Settings (New)" saying "Your Thank You and Order Status page have to be replaced"

 

Can someone pls help me?

 

Thanks a lot in advance!

 

Screenshot 2024-06-12 221247.png

Replies 14 (14)

ImTired
Excursionist
12 0 2

I received the same email. I am using metafields to show a custom order status update and when I made the change, that no longer worked. I ended up just changing it back because I like being able to update customers through their order status page, without needing to purchase anything additional. I'm getting so frustrated with this system that they keep changing on us.

SoapAndTheSea
Visitor
1 0 0

pault70
Tourist
10 0 7

I couldn't find it either. Also "anything" is a really stupid parameter name to send out to non-technical customers. Is the parameter actually called "anything" or does it mean that anything can be between the quotes like "ABC", "asdf", "1337" etc??

osamafarooqi71
Shopify Partner
259 22 45

Hello @jorgeplantz , 

Shopify is evolving and introducing a new set of APIs to improve and scale the platform. In order to resolve this you need to follow the few steps below and you;ll be able to fix it.

 

  1.  Login into your Shopify Admin dashboard.
  2. Go to settings (from the bottom left side of the screen)
  3. Then go to Checkout using the sidebar and scroll down. There you'll find the "Additional scripts".
  4. In the text box, you just need to find "{{ order.order_number }}" or any text next to "order.xxxx". This order is an object and the order_number is it's property. So, we need to replace order object with checkout object, in this case, "checkout.order_id".

 

Path=> Shopify Dashboard > Settings > Checkout > Additional scripts

Before

 

<!-- Purchase Conversion Event Start -->
<script>
window.dataLayer = window.dataLayer || [];
dataLayer.push({ ecommerce: null });
{% if first_time_accessed %}
dataLayer.push({
  event: "purchase_complete",
  ecommerce: {
      transaction_id: "{{ order.order_number }}",
      value: {{ total_price | times: 0.01 }},
      tax: {{ tax_price | times: 0.01 }},
      shipping: {{ shipping_price | times: 0.01 }},
      currency: "{{ order.currency }}",
        }
});
{% endif %}
</script>
<!-- Purchase Conversion Event End -->

 

After

<!-- Purchase Conversion Event Start -->

<script>
window.dataLayer = window.dataLayer || [];
dataLayer.push({ ecommerce: null });
{% if first_time_accessed %}
dataLayer.push({
  event: "purchase_complete",
  ecommerce: {
      transaction_id: "{{ checkout.order_id }}",
      value: {{ total_price | times: 0.01 }},
      tax: {{ tax_price | times: 0.01 }},
      shipping: {{ shipping_price | times: 0.01 }},
      currency: "{{ checkout.currency }}",
        }
});
{% endif %}
</script>

<!-- Purchase Conversion Event End -->

 

 

If you're not familiar with this, please consider contacting a technical person or hire a developer. Any minor mistake can impact analytics and lower conversion results tracking. 

 

Feel free to reach out the me if you still need any help.

 

Regards,

Osama Farooqi

Shopify Theme Developer | Contact me | Hire expert
- Was my reply helpful? Click Like 🙂 to let me know | Buy Me Coffee
- Was your question answered? Mark this as Accepted Solution
Shaymaa
Visitor
1 0 0

Hi Osama,

 

Many thanks. I received that email, too. I followed the steps you mentioned, but I still see the attached error message. The mentioned incompatible apps that I have are Google Analytics and Microsoft Clarity. I made the changes to the following additional script which is at the setting- checkout—the additional script has the code for Google Analytics and Microsoft Clarity. Please let me know how I can solve it. Thanks.

 

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-VKB2PDJ7Y4"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-VKB2PDJ7Y4');
{% if first_time_accessed %}
gtag("event", "purchase", {
transaction_id: "{{ checkout.order_id }}",
value: {{ total_price | times: 0.01 }},
tax: {{ tax_price | times: 0.01 }},
shipping: {{ shipping_price | times: 0.01 }},
currency: "{{ checkout.currency }}",
items: [
{% for line_item in line_items %}
{
item_id: "{{ line_item.product_id }}",
item_name: "{{ line_item.title | remove: "'" | remove: '"' }}",
currency: "{{ checkout.currency }}",
price: {{ line_item.original_price | times: 0.01 }},
quantity: {{ line_item.quantity }}
},
{% endfor %}
]
});
{% endif %}
</script>

<script type="text/javascript">
(function(c,l,a,r,i,t,y){
c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
})(window, document, "clarity", "script", "lmp0ktcva5");
</script>

 

 

Screenshot 2024-06-14 at 11.01.19 PM.png

vishal678
Visitor
1 0 0

i follow the steps when i reach at additional scripts box there is already data present from an app used for providing order cancel option for customer. what should i do please help.

 

"complete text which is already present is below is pasted"

<!-- start codify - order cancel widget -->
<script>
let order_id = {{ order.id | json }};
if(order_id != null) {
if(!window.Shopify.checkout) {
window.Shopify.checkout = {
line_items: []
};
{% for item in order.line_items %}
window.Shopify.checkout.line_items.push({
variant_id: {{ item.variant_id | json }},
quantity: {{ item.quantity | json }}
});
{% endfor %}
}
window.coc = {
shop: {{ shop.permanent_domain | json }},
order_id: order_id,
cancelled: {{ order.cancelled | json }},
fulfillment: {{ order.fulfillment_status | json }},
order_url: {{ order.order_status_url | json }},
total_price: {{ order.total_price | default: 0 }}
}
} else {
location.reload();
}
</script>
<script src="https://www.codifyordercancel.com/order-cancel.js?v=1234" type="text/javascript"></script>
<!-- end codify - order cancel widget -->
Screenshot 2024-07-26 at 11-49-32 Fingrella · Checkout · Shopify.png

lynth
Shopify Partner
140 6 16

You won't be able to implement liquid fragment:

{% for item in order.line_items %}
window.Shopify.checkout.line_items.push({
variant_id: {{ item.variant_id | json }},
quantity: {{ item.quantity | json }}
});
{% endfor %}

Because the customer events pixel works only with JavaScript, you should rebuild it.
Instead {% for item in order.line_items %} use:

function extractProducts(lineItems) {
  return lineItems.map(item => {
      //your code... for example:
      item_name: item.title,
      item_id: item.variant.sku,
      item_category: item.variant.product.type,
      item_variant_id: item.variant.id,
      item_product_id: item.variant.product.id,
  });
}

But I'm not sure it is possible to rebuild all of it.

If my tips are useful, just mark it as the solution. Cheers!
Feeling grateful? Buy me a coffee!

mrycko
Shopify Partner
5 0 0

My client also received such an email.
In additional scripts, I have this line in the analytics script.

'transaction_id': '{{ order.order_number }}',


Will changing order.order_number to checkout.order_number or checkout.order_id (as it was in the email) solve the problem and not kill the analytics?
Which version is correct checkout.order_number or checkout.order_id?

osamafarooqi71
Shopify Partner
259 22 45

Hello @mrycko ,

"checkout.order_id"  is the correct one. You also need to update the currency as well.

 

Before:

currency: "{{ order.currency }}",

 

After:

currency: "{{ checkout.currency }}",

 

Feel free to reach out the me if you still need any help.

 

Regards,

Osama Farooqi

Shopify Theme Developer | Contact me | Hire expert
- Was my reply helpful? Click Like 🙂 to let me know | Buy Me Coffee
- Was your question answered? Mark this as Accepted Solution
razariusu
Shopify Partner
1 0 0

Have you verified that "order.order_number" has to be replaced with "checkout.order_id"? It doesn't make sense as the returned value would be different.

I'd say the whole point is referencing the checkout object instead of order.

osamafarooqi71
Shopify Partner
259 22 45

Hi @razariusu , if you read the official email, you'll notice this that they mentioned to replace the  "order.order_number" with "checkout.order_id". The reason behind this is 'The field(s) "order.(anything)" are populated during order creation. With Checkout Extensibility, this happens independently of the Thank You page loading to improve scale and performance.

 

However, "checkout.order_id", on the other hand, is a common and unique identifier across checkout and order creation. It is available as soon as checkout is completed and can reliably be used to tie together analytics, downstream systems, and the buyer experience.

 

 Moreover, it'll be sunset soon. So, batter to migrate it to Custom Pixels in Shopify.

 

Feel free to reach out the me if you still need any help.

 

Regards,

Osama Farooqi

Shopify Theme Developer | Contact me | Hire expert
- Was my reply helpful? Click Like 🙂 to let me know | Buy Me Coffee
- Was your question answered? Mark this as Accepted Solution
lynth
Shopify Partner
140 6 16

You have to modify it from the Liquid order object to the Liquid checkout object. That's all. Read the documentation and replace it. 

If my tips are useful, just mark it as the solution. Cheers!
Feeling grateful? Buy me a coffee!

osamafarooqi71
Shopify Partner
259 22 45

 

Hello everyone,

In addition to my previous reply, I recommend upgrading Additional Scripts to Checkout Extensibility. Shopify has set a deadline of August 28, 2025, for this transition.

replace order.anything for checkout.order_id upgrade to checkout extensibility in shopify.png

 

Therefore, please upgrade your scripts to Shopify Checkout Extensibility before this date. If you are not a developer, it is advisable to hire a developer to handle the upgrade for you.

 

Reference: https://help.shopify.com/en/manual/checkout-settings/customize-checkout-configurations/checkout-exte...

 

Feel free to reach out the me if you still need any help.

 

Regards,

Osama Farooqi

Shopify Theme Developer | Contact me | Hire expert
- Was my reply helpful? Click Like 🙂 to let me know | Buy Me Coffee
- Was your question answered? Mark this as Accepted Solution
lynth
Shopify Partner
140 6 16

Did you try to implement the Custom Pixels instead of the Additional Scripts? Does it work? I heard there is a problem with sending data to the GTM. Please tell me more about it. You can use the Customer events but it's run in the sandbox environment and you can't grab everything. Alternatively, you can create your own app, but I heard there is no possibility to push data directly to the GTM. Please correct me if I'm wrong.

https://shopify.dev/docs/api/web-pixels-api#app-web-pixels

If my tips are useful, just mark it as the solution. Cheers!
Feeling grateful? Buy me a coffee!