Вход на сайт

Просмотр новости

Найдите то, что Вас интересует

Hide the Discount Code Fields

Дата публикации: 02-10-2026 15:35:59

Sometimes a discount code field on your checkout page costs you sales. A member who would have paid full price sees the field and goes searching for “company name discount codes” instead of completing checkout. This code recipe hides the discount code field from checkout and only shows it when a code is passed through (more...)

Основное содержимое страницы с новостью.

Sometimes a discount code field on your checkout page costs you sales. A member who would have paid full price sees the field and goes searching for “company name discount codes” instead of completing checkout.

This code recipe hides the discount code field from checkout and only shows it when a code is passed through the URL, in the format &discount_code=CODEID.

Fake checkout page mockup showing the discount code field revealed because discount_code=SUMMER20 is present in the URL bar

Do You Need This Recipe?

By default, Paid Memberships Pro only shows the discount code field at checkout when the selected membership level has a discount code configured. If none of your levels use discount codes, the field is already hidden, so you don’t need this recipe.

Use this recipe when a level does have a discount code configured, so the field would normally show, but you only want members to see it when they already have a code in hand, for example from an email campaign or a partner link. The snippet hides the field by default and only reveals it when discount_code is present in the URL.

Best Practices and Considerations

Keep in mind this is not a security feature. Hiding the field only keeps casual visitors from noticing the discount. Anyone with the code and the URL format can still apply it. If you need to make sure only approved members use a code, build that check into the code itself rather than relying on this recipe alone.

About the Code Recipe

This recipe uses a PMPro filter called pmpro_show_discount_code to control whether the discount code field appears at checkout. The snippet below hides the field by default, and only shows it when the checkout URL includes a discount_code value.

To share a link that reveals the field, add discount_code=CODEID as a query parameter to your membership checkout URL, alongside the level parameter:

  • With the field hidden: https://yoursite.com/membership-checkout/?level=2
  • With the field revealed: https://yoursite.com/membership-checkout/?level=2&discount_code=SUMMER20

A member who visits the second link sees the discount code field and can apply the code. A member who visits the first link never sees the field at all.

The Code RecipeAdding the Recipe to Your Website

You can add this recipe to your site by creating a custom plugin or using the Code Snippets plugin available for free in the WordPress repository. Read this companion article for step-by-step directions on either method.

How to Customize This Code Recipe

The recipe works as-is for most sites. The options below are for more specific setups.

  • Use a different parameter name (line 17): Change discount_code to match a different query parameter name if you already use discount_code elsewhere on your site.
  • Require a specific level too: Wrap the check in a condition using pmpro_hasMembershipLevel() so the field only unlocks via URL for certain levels, even if other levels also have discount codes configured.
  • Match against a list of valid codes: Instead of only checking for presence, compare $_REQUEST['discount_code'] against an array of the codes you issue, so the field only reveals itself for codes you recognize, not any value in the URL.

Jason Coleman

Author: Jason Coleman

Jason Coleman is the co-founder and CEO of Paid Memberships Pro, the most trusted membership platform that grows with you. With a deep passion for open source software, Jason is the author of Building Web Apps With WordPress, published by O'Reilly Media.

Jason's entrepreneurial spirit is driven by uncertainty, risk, and the thrill of new opportunities. With over two decades of experience in development, management, and marketing, he is committed to Paid Memberships Pro: the only open source platform focused on helping creators get paid so they can find freedom in their life and fulfill their goals.

View more articles by Jason Coleman »

Get Support From Our Team of Experts

Have a question about how to use this feature? Our Support Page outlines three ways to get support.

Our Max plans include hands-on help customizing your membership site and implementing new features. Upgrade to PMPro Max now »

Was this article helpful?

YesNo

Схожие новости

#Наименование новостиТональностьИнформативностьДата публикации
1Prevent Users From Using an Email Address as Their Username06.9702-10-2026
2Restrict your Membership Sites Mailing Locations by Specifying Valid Zip Codes05.202-10-2026
3Remove the Restricted Access Messages on Blog Homepage07.8301-10-2026
4Disable PMPro’s Redirect on the WordPress Registration Page011.9907-10-2026
5Adjust the Set Expiration Year After a Specific Month07.2702-10-2026
6Add Custom Colors to the Block Editor Color Palette07.1815-10-2026
7Give Your Custom Post Types Their Own Memberlite Layout Settings08.115-10-2026
8Скидки маркетплейса за счет продавца: учет без ошибок07.9716-10-2026
9The Paid Newsletter Playbook: Content Strategy + Hybrid Setup with PMPro08.9214-10-2026
10How to Quickly and Easily Add One-Click Checkout to WooCommerce #ecommerce #wordpress010.3625-10-2025

Классификация: . Схожих патентов: 0. Схожих новостей: 10. Тональность: 0. Информативность: 7.65. Источник: www.paidmembershipspro.com.