Skip to main content
Contributor I
February 4, 2025
Solved

WooCommerce Order confirmation - how to not loop everything?

  • February 4, 2025
  • 3 replies
  • 116 views

Hi,

I have a problem where shipping method and total cost gets looped on every item.

Tried using a separate table but it still loop it for every product.

 

    Best answer by emma.owens

    Hi ​@Andreas Furuskog ! 

    Thank you for reaching out to the Community! Were you able to resolve this? 

    If you are using a dynamic table and including the shipping and total cost in that same table, it is going to loop for each product that is in a customers order. 

    I would suggest including the shipping and total cost variables in a separate static text block so that it doesn’t repeat for each item! 

     

     

    3 replies

    Contributor I
    February 4, 2025

    This is the code I´m using where its looping shipping and total cost:

    {{ item.Name|default:'' }}
    Quantity: {{ item.Quantity|floatformat:0}}
    {{ item.Price|floatformat:0 }} {{ event|lookup:'$currency_code'|default:'' }}

    {{ event.ShippingMethods }} {{ event.extra.TotalShipping|floatformat:0 }} {{ event|lookup:'$currency_code'|default:'' }}

    Total: {{ event|lookup:'$value'|floatformat:2 }}  {{ event|lookup:'$currency_code'|default:'' }}

     

    Also tried this but it doesnt show product name and are still showing shipping and total cost for every product:

    {% for item in event.extra.items %} 
    {{ item.Name|default:'' }}
    Quantity: {{ item.Quantity|floatformat:0 }}
    {{ item.Price|floatformat:0 }} {{ event|lookup:'$currency_code'|default:'' }}
    {% endfor %}

    {{ event.ShippingMethods }} {{ event.extra.TotalShipping|floatformat:0 }} {{ event|lookup:'$currency_code'|default:'' }}

    Total: {{ event|lookup:'$value'|floatformat:2 }}  {{ event|lookup:'$currency_code'|default:'' }}

    emma.owens
    Community Manager
    Community Manager
    February 5, 2025

    Hi ​@Andreas Furuskog ! 

    Thank you for reaching out to the Community! Were you able to resolve this? 

    If you are using a dynamic table and including the shipping and total cost in that same table, it is going to loop for each product that is in a customers order. 

    I would suggest including the shipping and total cost variables in a separate static text block so that it doesn’t repeat for each item! 

     

     

    Contributor I
    February 6, 2025

    Hi ​@Andreas Furuskog ! 

    Thank you for reaching out to the Community! Were you able to resolve this? 

    If you are using a dynamic table and including the shipping and total cost in that same table, it is going to loop for each product that is in a customers order. 

    I would suggest including the shipping and total cost variables in a separate static text block so that it doesn’t repeat for each item! 

     

     

    Thank you so much, that was the solution.

    Now it looks perfect!