Discount Code Input Methods
- SmartCart.applyDiscount ⇒
void
-
Applies a discount code to the current SmartCart instance.
- SmartCart.getApplicableDiscountCodeTotal ⇒
number
-
Gets the applicable discount amount from a submitted discount code. Used in the Tiered Progress Bar calculations.
- SmartCart.getDiscountButtonLabel ⇒
string
-
Get the discount button label from the current SmartCart instance
- SmartCart.getDiscountCodeLabel ⇒
string
-
Get the discount code label from the current SmartCart instance
- SmartCart.getDiscountCodeSettings ⇒
object | null
-
Get the discount code settings from the current SmartCart instance
- SmartCart.getDiscountInvalidMessage ⇒
string
-
Get the discount invalid message from the current SmartCart instance
- SmartCart.isDiscountInputEnabled ⇒
boolean
-
Determines if the discount code input component is enabled.
- SmartCart.removeDiscount ⇒
void
-
Removes the discount from the current SmartCart instance + local storage.
- SmartCart.shouldApplyDiscountCode ⇒
boolean
-
Determines, based on the presence of an automatic discount, if the discount code should be applied.
- SmartCart.shouldShowDiscountEntitled ⇒
boolean
-
Determines if the discount entitled message should be shown.
- SmartCart.shouldShowDiscountInput ⇒
boolean
-
Determines if the discount input should be shown.
- SmartCart.shouldShowDiscountSubtotal ⇒
boolean
-
Determines if the discount subtotal should be shown.
- SmartCart.showInvalidMessage ⇒
boolean
-
Determines if the invalid message should be shown.
- SmartCart.useDiscountCodeMessageOnly ⇒
boolean
-
Determines if the discount calculation should be omitted (useful for complex discount scenarios).
SmartCart.applyDiscount ⇒ void
Applies a discount code to the current SmartCart instance.
|
Param
|
Type
|
Description
|
|
discountCode
|
string
|
The discount code to apply.
|
|
[e]
|
Event
|
The event object (optional).
|
SmartCart.getApplicableDiscountCodeTotal ⇒ number
Gets the applicable discount amount from a submitted discount code. Used in the Tiered Progress Bar calculations.
Returns: number - The applicable discount amount from the submitted discount code\
Get the discount button label from the current SmartCart instance
Returns: string - The discount button text\
SmartCart.getDiscountCodeLabel ⇒ string
Get the discount code label from the current SmartCart instance
Returns: string - The discount code label text\
SmartCart.getDiscountCodeSettings ⇒ object | null
Get the discount code settings from the current SmartCart instance
Returns: object | null - The discount code component settings\
SmartCart.getDiscountInvalidMessage ⇒ string
Get the discount invalid message from the current SmartCart instance
Returns: string - The discount invalid message text\
Determines if the discount code input component is enabled.
SmartCart.removeDiscount ⇒ void
Removes the discount from the current SmartCart instance + local storage.
SmartCart.shouldApplyDiscountCode ⇒ boolean
Determines, based on the presence of an automatic discount, if the discount code should be applied.
Returns: boolean - Whether the discount code should be applied.\
SmartCart.shouldShowDiscountEntitled ⇒ boolean
Determines if the discount entitled message should be shown.
Returns: boolean - Whether the discount entitled message should be shown.\
Determines if the discount input should be shown.
Returns: boolean - Whether the discount input should be shown.\
SmartCart.shouldShowDiscountSubtotal ⇒ boolean
Determines if the discount subtotal should be shown.
Returns: boolean - Whether the discount subtotal should be shown.\
SmartCart.showInvalidMessage ⇒ boolean
Determines if the invalid message should be shown.
Returns: boolean - Whether the invalid message should be shown.\
SmartCart.useDiscountCodeMessageOnly ⇒ boolean
Determines if the discount calculation should be omitted (useful for complex discount scenarios).
Returns: boolean - Whether the discount calculation should be omitted until checkout.
---
title: Discount Code Input Methods
excerpt: Apply and validate discount codes in the cart drawer
deprecated: false
hidden: false
metadata:
title: ''
description: ''
robots: index
next:
description: Return to the New Methods Overview Page to see other available methods.
pages:
- type: endpoint
slug: smart-cart-methods
title: Methods Overview - New
---
<dl>
<dt><a href="#SmartCart.applyDiscount">SmartCart.applyDiscount</a> ⇒ <code>void</code></dt>
<dd>
<p>Applies a discount code to the current SmartCart instance.</p>
</dd>
<dt><a href="#SmartCart.getApplicableDiscountCodeTotal">SmartCart.getApplicableDiscountCodeTotal</a> ⇒ <code>number</code></dt>
<dd>
<p>Gets the applicable discount amount from a submitted discount code. Used in the Tiered Progress Bar calculations.</p>
</dd>
<dt><a href="#SmartCart.getDiscountButtonLabel">SmartCart.getDiscountButtonLabel</a> ⇒ <code>string</code></dt>
<dd>
<p>Get the discount button label from the current SmartCart instance</p>
</dd>
<dt><a href="#SmartCart.getDiscountCodeLabel">SmartCart.getDiscountCodeLabel</a> ⇒ <code>string</code></dt>
<dd>
<p>Get the discount code label from the current SmartCart instance</p>
</dd>
<dt><a href="#SmartCart.getDiscountCodeSettings">SmartCart.getDiscountCodeSettings</a> ⇒ <code>object</code> | <code>null</code></dt>
<dd>
<p>Get the discount code settings from the current SmartCart instance</p>
</dd>
<dt><a href="#SmartCart.getDiscountInvalidMessage">SmartCart.getDiscountInvalidMessage</a> ⇒ <code>string</code></dt>
<dd>
<p>Get the discount invalid message from the current SmartCart instance</p>
</dd>
<dt><a href="#SmartCart.isDiscountInputEnabled">SmartCart.isDiscountInputEnabled</a> ⇒ <code>boolean</code></dt>
<dd>
<p>Determines if the discount code input component is enabled.</p>
</dd>
<dt><a href="#SmartCart.removeDiscount">SmartCart.removeDiscount</a> ⇒ <code>void</code></dt>
<dd>
<p>Removes the discount from the current SmartCart instance + local storage.</p>
</dd>
<dt><a href="#SmartCart.shouldApplyDiscountCode">SmartCart.shouldApplyDiscountCode</a> ⇒ <code>boolean</code></dt>
<dd>
<p>Determines, based on the presence of an automatic discount, if the discount code should be applied.</p>
</dd>
<dt><a href="#SmartCart.shouldShowDiscountEntitled">SmartCart.shouldShowDiscountEntitled</a> ⇒ <code>boolean</code></dt>
<dd>
<p>Determines if the discount entitled message should be shown.</p>
</dd>
<dt><a href="#SmartCart.shouldShowDiscountInput">SmartCart.shouldShowDiscountInput</a> ⇒ <code>boolean</code></dt>
<dd>
<p>Determines if the discount input should be shown.</p>
</dd>
<dt><a href="#SmartCart.shouldShowDiscountSubtotal">SmartCart.shouldShowDiscountSubtotal</a> ⇒ <code>boolean</code></dt>
<dd>
<p>Determines if the discount subtotal should be shown.</p>
</dd>
<dt><a href="#SmartCart.showInvalidMessage">SmartCart.showInvalidMessage</a> ⇒ <code>boolean</code></dt>
<dd>
<p>Determines if the invalid message should be shown.</p>
</dd>
<dt><a href="#SmartCart.useDiscountCodeMessageOnly">SmartCart.useDiscountCodeMessageOnly</a> ⇒ <code>boolean</code></dt>
<dd>
<p>Determines if the discount calculation should be omitted (useful for complex discount scenarios).</p>
</dd>
</dl>
<a name="SmartCart.applyDiscount"></a>
## `SmartCart.applyDiscount` ⇒ <code>void</code>
Applies a discount code to the current SmartCart instance.
<Table>
<thead>
<tr>
<th>
Param
</th>
<th>
Type
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
discountCode
</td>
<td>
<code>string</code>
</td>
<td>
The discount code to apply.
</td>
</tr>
<tr>
<td>
[e]
</td>
<td>
<code>Event</code>
</td>
<td>
The event object (optional).
</td>
</tr>
</tbody>
</Table>
<a name="SmartCart.getApplicableDiscountCodeTotal"></a>
## `SmartCart.getApplicableDiscountCodeTotal` ⇒ <code>number</code>
Gets the applicable discount amount from a submitted discount code. Used in the Tiered Progress Bar calculations.
**Returns**: <code>number</code> - The applicable discount amount from the submitted discount code\ <a name="SmartCart.getDiscountButtonLabel"></a>
## `SmartCart.getDiscountButtonLabel` ⇒ <code>string</code>
Get the discount button label from the current SmartCart instance
**Returns**: <code>string</code> - The discount button text\ <a name="SmartCart.getDiscountCodeLabel"></a>
## `SmartCart.getDiscountCodeLabel` ⇒ <code>string</code>
Get the discount code label from the current SmartCart instance
**Returns**: <code>string</code> - The discount code label text\ <a name="SmartCart.getDiscountCodeSettings"></a>
## `SmartCart.getDiscountCodeSettings` ⇒ <code>object</code> \| <code>null</code>
Get the discount code settings from the current SmartCart instance
**Returns**: <code>object</code> \| <code>null</code> - The discount code component settings\ <a name="SmartCart.getDiscountInvalidMessage"></a>
## `SmartCart.getDiscountInvalidMessage` ⇒ <code>string</code>
Get the discount invalid message from the current SmartCart instance
**Returns**: <code>string</code> - The discount invalid message text\ <a name="SmartCart.isDiscountInputEnabled"></a>
## `SmartCart.isDiscountInputEnabled` ⇒ <code>boolean</code>
Determines if the discount code input component is enabled.
<a name="SmartCart.removeDiscount"></a>
## `SmartCart.removeDiscount` ⇒ <code>void</code>
Removes the discount from the current SmartCart instance + local storage.
<a name="SmartCart.shouldApplyDiscountCode"></a>
## `SmartCart.shouldApplyDiscountCode` ⇒ <code>boolean</code>
Determines, based on the presence of an automatic discount, if the discount code should be applied.
**Returns**: <code>boolean</code> - Whether the discount code should be applied.\ <a name="SmartCart.shouldShowDiscountEntitled"></a>
## `SmartCart.shouldShowDiscountEntitled` ⇒ <code>boolean</code>
Determines if the discount entitled message should be shown.
**Returns**: <code>boolean</code> - Whether the discount entitled message should be shown.\ <a name="SmartCart.shouldShowDiscountInput"></a>
## `SmartCart.shouldShowDiscountInput` ⇒ <code>boolean</code>
Determines if the discount input should be shown.
**Returns**: <code>boolean</code> - Whether the discount input should be shown.\ <a name="SmartCart.shouldShowDiscountSubtotal"></a>
## `SmartCart.shouldShowDiscountSubtotal` ⇒ <code>boolean</code>
Determines if the discount subtotal should be shown.
**Returns**: <code>boolean</code> - Whether the discount subtotal should be shown.\ <a name="SmartCart.showInvalidMessage"></a>
## `SmartCart.showInvalidMessage` ⇒ <code>boolean</code>
Determines if the invalid message should be shown.
**Returns**: <code>boolean</code> - Whether the invalid message should be shown.\ <a name="SmartCart.useDiscountCodeMessageOnly"></a>
## `SmartCart.useDiscountCodeMessageOnly` ⇒ <code>boolean</code>
Determines if the discount calculation should be omitted (useful for complex discount scenarios).
**Returns**: <code>boolean</code> - Whether the discount calculation should be omitted until checkout.