Skip to main content

Letting customers apply discount codes in the cart

Add a discount code field to the cart drawer, style its states, and know every message a customer can see.

Written by Eddie Lavandera

The discount codes module adds a field to the cart drawer where customers can enter a code and see immediately whether it worked. By the end of this it will be enabled and styled. The codes themselves are created in Shopify: Atlas provides the field and validates what customers type.

In this article:


Step 1: Enable it

  1. In the cart drawer editor, select Discount Codes.

  2. Select Activate.

Until then: "Discount codes are not shown because they are disabled. Activate to show them in your cart. You can review changes before saving."


Step 2: Set the labels

Field

Default

Help text

Discount Input Placeholder

Discount Code

Placeholder text shown in the discount code input field.

Discount Apply Button Text

Apply

Text displayed on the apply discount button.

The defaults are fine. Change them only if your store uses different language for codes, such as "voucher" or "promo code".


Step 3: Style the states

The field has three visual states, each with its own colours.

Control

State

Input background color, Input text color

Default

Button background color, Button text color

The apply button

Success message color, Success background color

A valid code

Error message color

An invalid code

Preview each with the Previewing control, which offers No discount, Valid code and Invalid code.

💡 Check the invalid state carefully. It is the one customers actually encounter, since typos and expired codes are far more common than perfect entries, and an error message in low-contrast red on a coloured background is unreadable exactly when it matters.


The messages customers see

Atlas validates the code against Shopify and returns a specific message. These are the exact strings a customer will read, and the ones they will quote to you.

Situation

Message

Success

Discount code "{code}" applied!

Nothing entered

Please enter a discount code

Code not recognised

This discount code is not valid

Code disabled

This discount code is not currently active

Start date in the future

This discount code is not yet active

Past its end date

This discount code has expired

Usage limit reached

This discount code has reached its usage limit

Lookup failed

Unable to validate discount code. Please try again.

ℹ️ These are specific for a reason. A customer told a code "has expired" understands the situation, whereas one told it "is not valid" assumes they typed it wrong and tries again. When a customer contacts you about a code, ask which message they saw.


Whether to enable it at all

Worth thinking about rather than switching on by default.

Enable it when you actively issue codes: email campaigns, influencer partnerships, recovery offers, customer service goodwill.

Consider leaving it off when you do not. An empty discount code field prompts customers to go and look for one, and many will leave your cart to search for a code that does not exist. Some of them will not come back.

⚠️ A visible discount code field on a store that never issues codes measurably increases cart abandonment. If your promotions are automatic discounts rather than codes, this module is costing you more than it earns.


Codes are created in Shopify

Atlas provides the field and validates entries. The codes themselves are created in your Shopify admin under Discounts, with the discount method set to Discount code.

This is separate from the automatic discounts behind your reward progress bar, which customers never type. See Creating the discounts behind your reward bar and Shopify's documentation on discount codes.


Next steps

Did this answer your question?