Skip to main content
Solved

Adding product size in order confirmation (WooCommerce)

  • June 27, 2023
  • 1 reply
  • 156 views

Forum|alt.badge.img+2

Hey everyone

I am trying to add the product size to each item ordered in the order confirmation email

I’ve added this code {{ event.extra.Items.0.Variant.Attributes.0.Value|default:'' }} but the problem is that when someone orders more than 1 product, it shows the same size in all the products on the order confirmation email

I'm using Woocommerce

Happy to get help here

 

Best answer by Brian Turcotte

Hi @Karina!

This is because the order items are stacked in an array, and the ‘0’ after ‘Items’ in the event variable you are using refers to the first product in the order (the numbering paradigm starts at 0, 1, etc.):

 

{{ event.extra.Items.0.Variant.Attributes.0.Value|default:'' }}

 

Therefore, since you’re essentially just copying and pasting this event variable, the same size value is being called in each repetition. 

 

To fix this, you can follow the steps in this Help Center article to create a repeating block.

 

Essentially, you will have to create a dynamic block and navigate to Display Options > Content Repeat > Create Repeat Rules. Then, create an item alias (explained in the Help Center article) like this:

 


Now, you will be able to include {{Item.Variant.Attributes.0.Value|default:''}} in your product block, and when the block repeats it will include the correct size for that item.

 

I hope this helps, and thanks for using the Community!

- Brian

1 reply

Brian Turcotte
Forum|alt.badge.img+37
  • Klaviyo Alum
  • 1393 replies
  • Answer
  • June 27, 2023

Hi @Karina!

This is because the order items are stacked in an array, and the ‘0’ after ‘Items’ in the event variable you are using refers to the first product in the order (the numbering paradigm starts at 0, 1, etc.):

 

{{ event.extra.Items.0.Variant.Attributes.0.Value|default:'' }}

 

Therefore, since you’re essentially just copying and pasting this event variable, the same size value is being called in each repetition. 

 

To fix this, you can follow the steps in this Help Center article to create a repeating block.

 

Essentially, you will have to create a dynamic block and navigate to Display Options > Content Repeat > Create Repeat Rules. Then, create an item alias (explained in the Help Center article) like this:

 


Now, you will be able to include {{Item.Variant.Attributes.0.Value|default:''}} in your product block, and when the block repeats it will include the correct size for that item.

 

I hope this helps, and thanks for using the Community!

- Brian