Skip to main content
Contributor I
Feb 4, 2025 10:03 AM UTC
Solved

WooCommerce Order confirmation - how to not loop everything?

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.

 

    This topic has been closed for replies.
    emma.owens
    Community Manager
    Feb 5, 2025 9:58 PM UTC

    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
    Feb 4, 2025 10:33 AM UTC

    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
    Feb 5, 2025 9:58 PM UTC

    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
    Feb 6, 2025 8:25 AM UTC

    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!