Home - Scripts - Website Development
- 09 November 2025
Shopify Functions Script: Custom Discounts & Cart Rules
Shopify discount scripts boost conversions by showing real-time savings, improving checkout transparency, customer trust, and average order value with smart cart and item-level features displays.
Key Points
- Stores using custom discount scripts see 18% higher checkout completion rates.
- Personalized cart-level savings boost customer trust and retention by up to 25%.
- Real-time discount visibility increases average order value by approximately 22%.
Discounts can be applied at various levels: line item, cart, checkout, or order. They may impact specific items or the entire order.
You can apply discounts in the following ways:
- As automatic discounts
- Using manual discount codes
- Using Shopify Scripts
This guide will teach you how to display discounts attractively in your Shopify theme, an essential skill for anyone working on a custom Shopify website development.
Requirements
Before implementing, make sure:
-
You’ve created a cart template or a customer/order template.
If you’re building or modifying templates as part of Shopify web development services, make sure your store theme is compatible with the latest Liquid syntax.
Resources Used
You’ll use the following Liquid objects to display discounts:
- discount_application
- discount_allocation
- line_item
These are essential objects often used by experts in custom Shopify web development when customizing themes or carts experiences.
The discount_application Object
The discount_application object monitors discounts at the cart, checkout, or order level. Depending on where you implement your display, you’ll use:
For cart template:
For order template:
Note: Manual discount codes are only valid during checkout and are not accessible through the
This logic is essential when delivering Shopify website development projects that involve custom cart or checkout layouts.
The discount_allocation Object
The discount_allocation object connects a discount application to a particular line item.
Access a range of discount allocations with:
In custom Shopify web development, this object helps developers ensure item-level discounts display correctly, especially when multiple promotions are active.
The line_item Object
For complete control over discount and price display, use these attributes:
- original_price
- original_line_price
- final_price
- final_line_price
- line_level_total_discount
Professional developers providing Shopify web development services often depend on these attributes to create dynamic pricing displays and improve conversion-focused checkout designs.
Implementing Discount Displays
Discounts may be applied at both item and cart levels. You should display discount information in two separate places:
- Next to each individual line item
- In the total summary area
You can add this logic directly inside a Liquid template or within a JSON template section, a common practice in Shopify website development projects.
Line Item Discounts
If a discount applies to specific items, display it directly below them product.
Example:
This approach not only improves user transparency but also aligns with modern UX best practices in custom Shopify websites development.
Cart Discounts
Subtotal = Total after line-item discounts.
Total = Amount after all cart-level discounts.
Access cart-level discounts via:
Example:
This logic helps Shopify developers implement custom cart rules that improve both aesthetics and functionality, essential for premium Shopify web development services.
Shopify Liquid Price Variables Explained
Original Price
Definition: Price per individual item before discounts.
Example:
- Product = $50
- Discount 10% → Final = $45
- original_price = $50
- final_price = $45
Original Line Price
Definition: Total price for that line (quantity × original price), before discount.
Formula:
Example:
- 2 items × $50 = $100
- After discount = $90
- original_line_price = $100
- final_line_price = $90
Final Price
Definition: Price per item after discount.
Example:
{{ item.final_price | money }}
- Original: $50
- 10% Off → $45
Final Line Price
Definition: Total line item price after discount.
Formula:
Example:
-
2 items × $45 = $90
Full Example (cart.liquid)
This snippet can be integrated seamlessly into a store’s cart template during Shopify website development, giving customers a clear view of their savings.
Summary
Here’s what each variable means and how it’s used in your Shopify theme:
original_price – This is the original price per single item before any discounts are applied. It does not include discounts and applies to individual items.
Example: $50
original_line_price – This represents the total original price for that line item (calculated as price × quantity). It also does not include discounts and applies at the line item level.
Example: $100
final_price – This is the discounted price per item, meaning it includes discounts and shows the final price after the offer. It applies to single items.
Example: $45
final_line_price – This shows the total discounted price for the line (calculated as final price × quantity). It includes discounts and applies to the line item level.
Example: $90
Pro Tip: Calculate Total Savings
Show total cart savings dynamically:
Result: Displays how much your customer saved across the entire cart — a great addition for custom Shopify web development company projects focused on conversion optimization.
Recommended CSS (for Attractive Display)
This simple yet elegant CSS styling enhances the cart layout and is often recommended by professional Shopify web developers services.
Final Words
Using Shopify Liquid’s discount_application, discount_allocation, and line_item objects provides full control over how discounts appear on your Shopify store.
Whether you’re building a new store or optimizing an existing one, incorporating these snippets into custom Shopify web development can help you deliver a polished, user-friendly shopping experience.
For businesses aiming to improve their store design, performance, and discount logic, partnering with Shopify website development experts ensures your store stands out with both aesthetic appeal and functionality excellence.
+91-8727000867
+64 22 003 5555



Request Instant Call
Hire Remotely