{{partial:dialog-checkout}}
{{currentSubTotal = 0}} {{ hasEmptyStock = false }}
{{ collection:users title:is="{{ session:user_name }}" }} {{ if cart | count == 0 }}

Your cart is empty

{{ else }}
{{ cart }} {{ qty = quantity }} {{ product }}
{{assets:product_images limit="1"}} {{ alt }} {{/assets:product_images}}
{{ title }}

Variant: {{selected_variant}}

Attribute: {{selected_attribute}}

Weight: {{variants}}{{options }}{{if attribute == selected_attribute}}{{product_weight}}{{/if}}{{/options}}{{/variants}} gram

Stock: {{variants}}{{options }} {{if attribute == selected_attribute}} {{stock}} {{ if stock == 0 }} {{ hasEmptyStock = true }} {{ /if}} {{/if}} {{/options}}{{/variants}}

{{ $current_date = now(); }} {{ $current_date = $current_date->startOfDay(); }} {{ $formatted_current_date = $current_date | format("Y-m-d H:i:s") }} {{currentProductId = id}} {{highest_discount_percentage = 0}}{{selected_valid_until = ''}} {{collection:special_offers }} {{ discount }} {{ if product.id == currentProductId }} {{if valid_until | format('Y-m-d H:i:s') >= $formatted_current_date}} {{ if discount_percentage > highest_discount_percentage }} {{ highest_discount_percentage = discount_percentage}} {{ selected_valid_until = valid_until }} {{ /if }}{{/if}} {{ /if }}{{ /discount }} {{/collection:special_offers }}

Price: Rp. {{variants}}{{options }}{{if attribute == selected_attribute}}{{price}}{{/if}}{{/options}}{{/variants}}

{{if highest_discount_percentage > 0}}

Discount: {{highest_discount_percentage}}%

Price after discount: Rp. {{discount_amount = 0}} {{discounted_price = 0}} {{variants}}{{options }}{{if attribute == selected_attribute}} {{discount_amount = price * (highest_discount_percentage / 100)}} {{discounted_price = price - discount_amount}} {{/if}}{{/options}}{{/variants}} {{discounted_price | format_number(0, ',', '.')}}

{{/if}}
{{ csrf_field }}
{{ csrf_field }}
{{qty}}
{{ csrf_field }} {{currentStock = 0}} {{variants}}{{options }}{{if attribute == selected_attribute}}{{currentStock = stock}}{{/if}}{{/options}}{{/variants}}
{{variantPrice = 0}} {{variants}}{{options }}{{if attribute == selected_attribute}}{{variantPrice = price}}{{/if}}{{/options}}{{/variants}} {{if highest_discount_percentage > 0}} {{subTotal = qty * discounted_price}} {{else}} {{subTotal = qty * variantPrice}} {{/if}}

Subtotal: Rp. {{subTotal | format_number(0, ',', '.')}}

{{/product}} {{/cart}}
{{/if}} {{/collection:users}}

Cart

{{ collection:users title:is="{{ session:user_name }}" }} {{ if cart | count }} {{/if}} {{/collection:users}}

Total Price:    Rp. {{ currentSubTotal | format_number(0, ',', '.') }}