How to hide the discount code input field for specific users?

Solved

How to hide the discount code input field for specific users?

a_zelinsky
Shopify Partner
27 0 4

Hi, I'm looking for the location of the discount code input field in the theme code, I can't quite find it. I need to hide the discount code input field for users with a certain tag on them. I'm thinking of just a simple conditional rendering for the discount code input field.

If anyone can provide insight on where that code lies, or an alternative to prevent users with a specific tag from using discounts, that would be really appreciated! 

Accepted Solution (1)
PaulNewton
Shopify Partner
7721 678 1625

This is an accepted solution.

A screenshot is useless for solutions needing reproduction and inspection. 

 

Be aware checkout.liquid customizations are being depreciated next year

https://changelog.shopify.com/posts/the-checkout-liquid-theme-file-is-being-deprecated 

 

If this is for checkout the main way to not have the discount field is to not have any manual discount codes in the store. Meaning using only automatic-discounts or checkout-scripts.


Beyond that the actual CSS varies and has to be maintained, read constantly monitored.

Be sure to make a backup and !important 💣read guidance on editing that template.

https://shopify.dev/docs/themes/architecture/layouts/checkout-liquid  

Roughly target the discount form with something like following, but that actual CSS can be different because of the utter worthless selector soup shopify insists on rendering in in some cases.

 

 

#Form0 { display: none; }
/* or */
 .order-summary__section.order-summary__section--discount { display: none; }

 

 

To find the exact CSS selector use a browsers developer tools to inspect the html of the page.

https://stackoverflow.com/questions/4500572/how-can-i-get-the-css-selector-in-chrome  

 

There's also a line-item-scripts to reject any discount-codes (idk why they labeled it "disable")

https://help.shopify.com/en/manual/checkout-settings/script-editor/examples/line-item-scripts#disabl... 

Though there are ways with checkout-scripts to hide shipping rates and hide payment methods in typical fashion there is no parity in having  a checkout-script approach to hide the discount field in a similar way.

 

 

Good Hunting.

Contact paull.newton+shopifyforum@gmail.com for the solutions you need


Save time & money ,Ask Questions The Smart Way


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Thank Paul with a Coffee for more answers or donate to eff.org


View solution in original post

Replies 3 (3)

PaulNewton
Shopify Partner
7721 678 1625

Others do not know what you know you have to communicate it always provide context for technical issues:  Store url, example url,  storefront password if applicable, theme name, apps used.

https://community.shopify.com/c/shopify-design/help-us-help-you/td-p/668159

 

If for the cart template if your using a discount app disable any cart discount fields in the app.

If not using an app, others need better specifics to see or reproduce the situation.

 

If for the checkout merchants cannot modify the checkout unless on the shopify PLUS enterprise plan.

 

 

Contact paull.newton+shopifyforum@gmail.com for the solutions you need


Save time & money ,Ask Questions The Smart Way


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Thank Paul with a Coffee for more answers or donate to eff.org


a_zelinsky
Shopify Partner
27 0 4

Hi Paul, 

Thanks for your response. Attached is the image of the discount code input field. The store is not using an app. Our store is Shopify Plus, but we have not upgraded to checkout extensibility yet. We have customizations through checkout.liquid. Thanks for your help!Screenshot 2023-04-12 at 10.32.59 PM.png

PaulNewton
Shopify Partner
7721 678 1625

This is an accepted solution.

A screenshot is useless for solutions needing reproduction and inspection. 

 

Be aware checkout.liquid customizations are being depreciated next year

https://changelog.shopify.com/posts/the-checkout-liquid-theme-file-is-being-deprecated 

 

If this is for checkout the main way to not have the discount field is to not have any manual discount codes in the store. Meaning using only automatic-discounts or checkout-scripts.


Beyond that the actual CSS varies and has to be maintained, read constantly monitored.

Be sure to make a backup and !important 💣read guidance on editing that template.

https://shopify.dev/docs/themes/architecture/layouts/checkout-liquid  

Roughly target the discount form with something like following, but that actual CSS can be different because of the utter worthless selector soup shopify insists on rendering in in some cases.

 

 

#Form0 { display: none; }
/* or */
 .order-summary__section.order-summary__section--discount { display: none; }

 

 

To find the exact CSS selector use a browsers developer tools to inspect the html of the page.

https://stackoverflow.com/questions/4500572/how-can-i-get-the-css-selector-in-chrome  

 

There's also a line-item-scripts to reject any discount-codes (idk why they labeled it "disable")

https://help.shopify.com/en/manual/checkout-settings/script-editor/examples/line-item-scripts#disabl... 

Though there are ways with checkout-scripts to hide shipping rates and hide payment methods in typical fashion there is no parity in having  a checkout-script approach to hide the discount field in a similar way.

 

 

Good Hunting.

Contact paull.newton+shopifyforum@gmail.com for the solutions you need


Save time & money ,Ask Questions The Smart Way


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Thank Paul with a Coffee for more answers or donate to eff.org