Advanced Dynamic Pricing For WooCommerce

The original price for variations must be shown before the discount

When Advanced Dynamic Pricing for WooCommerce applies a discount rule to a variable product, it modifies the displayed price HTML to show the discounted price range. In some cases this can suppress the original pre-discount price display on the product page — meaning shoppers only see the new price without being shown what it was reduced from.

This article provides a compact snippet that disables Advanced Dynamic Pricing’s price HTML modification specifically for variable products on the product page, restoring WooCommerce’s default behaviour of showing the original price alongside the discounted one so the price reduction is clearly communicated to shoppers.


Code Sample

Add the following snippet to your theme’s functions.php or the Code Snippets plugin:

 

Code Explained (for Developers)

ElementDescription
adp_get_price_html_is_mod_neededA custom filter hook provided by Advanced Dynamic Pricing. It fires during the plugin’s price HTML rendering step and determines whether the plugin should modify the price HTML output for the current product in the current display context. Returning true allows the modification; returning false tells the plugin to leave the price HTML as WooCommerce would render it natively.
$modA boolean value — the current state of the modification flag. true means the plugin intends to modify the price HTML; false means it should not. This is the value you either pass through or override.
$productThe WC_Product object for the product currently being rendered. Used here to check whether the product is of type variable.
$contextA context object provided by the plugin that describes where the price is being displayed. Exposes constants and an is() method for checking the current rendering location.
$product->is_type( 'variable' )Returns true only for variable products — simple, external, and variation products are unaffected by this snippet, so their price HTML continues to be modified by the plugin as normal.
$context->is( $context::WC_PRODUCT_PAGE )Checks whether the price is being rendered on the single product page specifically. This prevents the snippet from affecting price display in other contexts such as the shop/category loop, cart, or checkout — the original price suppression fix only applies where the shopper is evaluating the product in detail.
return falseWhen both conditions are met (variable product + product page context), the snippet returns false to disable the plugin’s price HTML modification, allowing WooCommerce to render the full original-plus-discounted price HTML natively.
return $modFor all other cases, the original $mod value is returned unchanged — ensuring the plugin behaves normally everywhere else.
10, 3Hook priority 10 (standard); 3 means the callback accepts three arguments$mod, $product, and $context.

Key concept: The adp_get_price_html_is_mod_needed filter is scoped by both product type and display context. This makes it precise — you can target exactly the combination of product type and page location where the behaviour needs to change, without creating unintended side effects elsewhere on the site.


Available Context Constants

The $context object exposes constants you can use to target other display locations if needed:

ConstantDescription
$context::WC_PRODUCT_PAGESingle product page
$context::WC_SHOP_PAGEMain WooCommerce shop page / product archive
$context::WC_CARTCart page
$context::WC_CHECKOUTCheckout page

For example, to also disable the price modification for variable products on the shop page, extend the condition:


Targeting Other Product Types

The snippet targets only variable products. If you need to apply the same behaviour to other product types, adjust the is_type() check:

Product typeis_type() value
Simple product'simple'
Variable product'variable'
External / affiliate product'external'
Grouped product'grouped'
Specific variation'variation'
All product typesRemove the is_type() check entirely

To disable the modification for all product types on the product page:


How to Apply This Code

  1. Open Appearance → Theme File Editor in your WordPress admin, or open the Code Snippets plugin.
  2. Paste the snippet into your active child theme’s functions.php or create a dedicated snippet.
  3. Save and navigate to a variable product page that has an active discount rule applied.
  4. Verify that the original price is now displayed alongside the discounted price (typically shown as a strikethrough original price followed by the new discounted price).

⚠️ Editing functions.php directly can be overwritten during theme updates. A child theme or the Code Snippets plugin is the safer long-term approach.


When Should You Use This?

  • Variable product pages show only the discounted price with no reference to the original price, making the discount invisible to shoppers.
  • You want the classic WooCommerce strikethrough price display (~~$20.00~~ $15.00) to appear for variable products with active pricing rules.
  • Your theme relies on WooCommerce’s native price HTML structure and Advanced Dynamic Pricing’s modification is breaking the layout or styling of the variable product price on the product page.
  • You want full transparency about the discount amount on the product page while still applying the discount correctly in the cart and at checkout.
  • You need the price modification to remain active on the shop/category page or in the cart but not on the individual product page.

Have questions? Please submit a support request. We're always happy to help!

Advanced Dynamic Pricing
for WooCommerce
PRO

From $60
Buy
✓ 30-day money-back guarantee