{assign var="cart_coupon" value=0} {assign var="subtotal_without_vat" value=0} {assign var="rate" value=0} {foreach $order_info.products as $cart_id=>$product} {assign var="price_without_vat" value=$product.price} {if isset($order_info.taxes) && is_array($order_info.taxes) && count($order_info.taxes) > 0} {foreach $order_info.taxes as $tax} {foreach $tax.applies.items.P as $key => $boolean} {if $key == $cart_id} {assign var="rate" value=$tax.rate_value} {/if} {/foreach} {/foreach} {/if} {assign var="price_without_vat" value=($price_without_vat/(1+($rate/100))) } {$subtotal_without_vat = $subtotal_without_vat + $price_without_vat*$product.amount } {/foreach} {foreach $order_info.promotions as $key => $value} {if isset($value.bonuses)} {foreach $value.bonuses as $bonus} {if $bonus.bonus == "order_discount"} {if $bonus.discount_bonus == "by_fixed"} {$cart_coupon = $cart_coupon + round($bonus.discount_value/(1+$rate/100), 2)} {/if} {if $bonus.discount_bonus == "by_percentage"} {$cart_coupon = $cart_coupon + $bonus.discount_value*$subtotal_without_vat/100} {/if} {/if} {/foreach} {/if} {/foreach}