Advanced Dynamic Pricing For WooCommerce

Show “Bulk discounts” badge for Woodmart theme

The Woodmart WooCommerce theme ships with its own product label system that overrides the default woocommerce_sale_flash hook with a custom function — woodmart_product_label. Because Woodmart manages the sale badge rendering entirely on its own, the standard approach used by Advanced Dynamic Pricing for WooCommerce to display bulk discount badges is bypassed and never fires.

This article provides a ready-to-use snippet that correctly replaces Woodmart’s label handler with a custom one that is fully compatible with Advanced Dynamic Pricing’s bulk discount rules — while preserving all of Woodmart’s other label features (Hot, New, Sold Out, product attributes, and percentage labels).


Code Sample

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

 

To customise the badge text, find this line and change 'Bulk discounts' to any string you prefer:


Code Explained (for Developers)

The snippet is made up of three parts: a hook swap on init, a badge text override function, and a full label renderer that replaces Woodmart’s default one.


Part 1 — Hook swap (init action)

ElementDescription
add_action( 'init', ... )Runs after WordPress and all plugins/themes have loaded, ensuring Woodmart’s hooks are already registered before we attempt to modify them.
has_action( 'woocommerce_sale_flash', 'woodmart_product_label' )Checks whether Woodmart has registered woodmart_product_label on woocommerce_sale_flash. Returns the registered priority if found, or false if not. Storing the return value in $priority is essential — remove_action() requires the exact priority used during registration.
remove_action( 'woocommerce_sale_flash', 'woodmart_product_label', $priority )Removes Woodmart’s label renderer from the hook. Returns true on success, ensuring we only register our replacement if the removal actually worked.
add_action( 'woocommerce_sale_flash', 'wdp_product_label' )Registers our custom label renderer as the replacement. Only fires if the removal of Woodmart’s function succeeded — preventing duplicate labels.

Part 2 — Badge text override (lmb_customize_badge)

ElementDescription
function_exists( 'adp_functions' )Safety check — if Advanced Dynamic Pricing is not active or not loaded, the function returns the original badge unchanged to avoid fatal errors.
adp_functions()->getActiveRulesForProduct( $product, 999.0 )Retrieves all currently active pricing rules for the product at a quantity of 999.0. Using a high quantity ensures bulk pricing tiers are included in the result.
$r->getProductRangeAdjustmentHandler()Accesses the adjustment handler for each rule, which describes the type of discount applied.
$adjustmentHandler->getType() === $adjustmentHandler::TYPE_BULKChecks whether the rule is specifically a bulk discount rule. If at least one bulk rule is found, $changeBadgeText is set to true and the loop exits early via break.
return 'Bulk discounts'The replacement badge text shown when a bulk rule is active. This is the only line you need to change to customise the displayed text.
Fallback return $badgeIf no bulk rule is found, the original badge string (e.g. -25% or Sale) is returned unchanged.

Part 3 — Label renderer (wdp_product_label)

This function is a near-complete replacement for Woodmart’s woodmart_product_label(). It preserves all of Woodmart’s native label logic while routing the sale badge text through lmb_customize_badge() to enable bulk discount detection.

ElementDescription
woodmart_get_product_attributes_label()Woodmart function that returns any custom product attribute labels configured in the theme settings. Preserved as-is.
woodmart_get_opt( 'percentage_label' )Reads the Woodmart theme option for whether to show percentage labels. The percentage calculation only runs if this is enabled.
$product->is_on_sale()Standard WooCommerce check — the sale label block only runs for products that are currently on sale (either via WooCommerce native prices or dynamic pricing rules).
Variable product branchLoops all variation prices to find the highest discount percentage across all variations, matching Woodmart’s native behavior.
Simple / external branchCalculates the discount percentage from get_regular_price() and get_sale_price() directly.
lmb_customize_badge( '-' . $percentage . '%' )Passes the computed percentage string to the badge customiser. If a bulk rule is active, it replaces the percentage with 'Bulk discounts'; otherwise, the percentage is shown as-is.
lmb_customize_badge( esc_html__( 'Sale', 'woodmart' ) )Same as above but for products with no percentage (e.g. products with a sale price but no regular price set).
Sold out, Hot, New labelsWoodmart’s native labels — fully preserved and output exactly as the original woodmart_product_label() function would.
woodmart_get_opt( 'label_shape' )Reads the Woodmart label shape setting and applies it as a CSS class, maintaining theme styling consistency.

Customising the Bulk Badge Text

Only one line needs to be changed to customise the label displayed for bulk discount products:

Replace 'Bulk discounts' with any text you prefer, for example:


How to Apply This Code

  1. Open Appearance → Theme File Editor in your WordPress admin, or open the Code Snippets plugin.
  2. Paste the full snippet into your active child theme’s functions.php, or create a dedicated snippet.
  3. Save and navigate to a shop or category page containing products with active bulk discount rules.
  4. Verify that the product label shows your custom bulk discount text instead of the default sale badge.

⚠️ Do not paste this into Woodmart’s parent theme files — it will be overwritten on theme updates. Always use a child theme or the Code Snippets plugin.

⚠️ If you already have custom code that modifies woocommerce_sale_flash, check for conflicts — only one replacement handler should be registered at a time.


What Woodmart Labels Are Preserved?

This snippet is a full drop-in replacement for woodmart_product_label(). All of the following Woodmart labels continue to work exactly as before:

LabelCondition
Sale / percentage badgeProduct is on sale (is_on_sale())
Bulk discounts (new)Product has an active bulk pricing rule
Sold outProduct is out of stock
HotProduct is featured + Woodmart “Hot label” option enabled
NewProduct has _woodmart_new_label meta + Woodmart “New label” option enabled
Attribute labelsCustom product attribute labels configured in Woodmart

When Should You Use This?

  • You use the Woodmart theme and bulk discount labels are not appearing on product cards.
  • Advanced Dynamic Pricing’s bulk rules are active, but the product badge still shows “Sale” or a percentage instead of a bulk discount indicator.
  • You want to inform shoppers at a glance that a product has volume pricing available, directly on the product card.
  • You need a Woodmart-compatible badge solution that doesn’t break the theme’s Hot, New, Sold Out, or attribute labels.

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