Configure products to automatically apply discount codes when customers add them to their cart, perfect for exclusive offers or test products.
EliteCart Professional account
Admin access to create product metafields
Go to Settings → Custom data in your Shopify admin
Click Products → Add definition
Configure the metafield exactly as follows:
Name: elitecart_auto_apply_discount_code
Namespace and key: custom.elitecart_auto_apply_discount_code
Type: Single line text
One value (not list of values)
Storefront API access: Must be enabled (toggle ON)
Click Save (you can now save the name as well if you like)
Important: The namespace and key (red below) must be exactly custom.elitecart_auto_apply_discount_code
for the feature to work.
Go to Discounts in your Shopify admin
Create a new manual discount code
Configure the discount settings (amount, products, usage limits)
Save the discount code name for the next step
Edit the product that should trigger the discount
Scroll to Metafields section
Find elitecart_auto_apply_discount_code
Enter your discount code (e.g., TESTPRODUCT100
)
Save the product
Visit the product page
Add the product to cart
Open the cart drawer
Verify the discount code is automatically applied
Create a 100% discount that applies to specific sample products.
Create discount code FREE_SAMPLE
with 100% off
Limit to a specific product
Add the code to that product’s metafield
The discount is now automatically applied when the product is added to cart and further limits the free samples per order to 1.
Run promotions without banners or popups:
Create time-limited discount code
Add to featured products
Discount applies seamlessly at checkout
When a customer adds a product to cart:
EliteCart checks for the discount metafield
If found, applies the code automatically
Cart updates with discounted pricing
No manual code entry required
Only one discount code per product
Discount applies only when adding from product page
Existing discount codes are preserved
Works with all EliteCart features (upsells, rewards, etc.)
Discount not applying:
Verify metafield key is exactly custom.elitecart_auto_apply_discount_code
Ensure Storefront API access is enabled
Check discount code is active and valid
Confirm product page URL matches the product
Wrong discount applied:
Check for typos in the discount code
Verify discount settings in Shopify admin
Test with a different discount code
Multiple products with different codes:
Each product can have its own discount code
All valid codes will be applied to cart
Shopify's discount stacking rules apply