adding discount section in cart on Brooklyn theme

Tourist
3 0 1

hi there . i'm trying to add a discont section on the cart in the Brooklyn theme . I set the cart in page mode . I found this code on the documentation but doesn't seems to work .

<!-- Cart subtotal -->
Subtotal: {{ cart.items_subtotal_price | money }}
<!-- Cart level discounts -->
{%- if cart.cart_level_discount_applications != blank -%}
Discounts:
<ul>
{%- for discount_application in cart.cart_level_discount_applications -%}
<li>{{- discount_application.title -}}
-{{ discount_application.total_allocated_amount | money }}</li>
{%- endfor -%}
</ul>
{%- endif -%}
<!-- Final cart total -->
Total: {{ cart.total_price | money }}

thanks for the help .

0 Likes
Tourist
3 0 1

so apparently this code work just for 'automatic discount' for code discount you need to install an app

0 Likes
New Member
11 0 0

If you're only looking for a way to display a discount input, then you can add a regular input field with the name 'discount' to the cart's <form> element. This works on the cart page as well as a cart popup, as long as the form action posts into the checkout. The discount will be applied on the checkout page after the form is submitted.

E.g. <label>Discount <input name="discount" type="text></label>

The tricky part is if you want to check that the coupon is applicable to the cart and display the discounted amount. There is no easy way to do that yourself at this time, which is why apps exist to handle this functionality. There are many apps that apply a discount on the cart page. They differ in appearance as well as supporting functionality and price. The app we've developed for this purpose is https://apps.shopify.com/discount-on-cart-pro. It has a 14-day free trial so you can give it a shot risk-free. It handles both automatic discounts (the code you pasted) plus manual discounts when automatic discounts aren't in use (you can't apply both to the same cart).

0 Likes