Okay
  Public Ticket #4513148
I’ve run into an issue with the Sale badge and price display when discounts are applied via Dynamic Rules.
Closed

Comments

  •  2
    Vladislav started the conversation

    When I set product discounts through B2BKing Dynamic Rules, the Sale badge and discounted price are shown correctly on simple products.
    However, for variable products (products with attributes like different sizes/volumes), the shop/archive card does not show the discount — it either shows the regular price or just the “SALE” badge inconsistently. Only products without any attributes display the discount as expected.

    Steps to reproduce
    1. Create a variable product with multiple attributes (e.g., sizes).

    2. Create a Dynamic Rule (e.g., Discount % or Set Price) targeting that product or its category for a B2B group.

    3. View the product in the shop / archive grid.

    4. Compare with a simple product affected by the same rule.

    Expected behavior
    • The discounted price and Sale badge should be visible on the archive card for variable products (same as for simple products), using the rule-adjusted price for the default/lowest-price variation.

    Actual behavior
    • On variable products:

      • The Sale badge sometimes appears but the discounted price doesn’t.

      • In other cases, neither the badge nor the discounted price appears in the archive; the discount is visible only on the single product page after selecting a variation.

    • On simple products: both the badge and discounted price display correctly.

    Notes / Environment
    • Theme: Woodmart

    • Cache: WP Rocket (logged-in user cache disabled)

    • WooCommerce + B2BKing Pro (latest versions)

    • Issue occurs for products with multiple attributes (e.g., different sizes/quantities).

    Questions
    1. Is there a known limitation for showing Dynamic Rule discounts on variable products in the archive loop?

    2. Is there a recommended hook/filter to force the archive card to use the rule-adjusted variation price (e.g., default variation) so the Sale badge and price render correctly?

    3. If there’s a snippet or setting to enable “calculate sale for variable products in loop”, could you share it?

    I can provide product IDs or a staging login if needed.

    Attached files:  Ekrano kopija 2025-11-05 133716.png

  •  2,605
    WebWizards replied

    Hi Vladislav,

    By default, WooCommerce doesn't show the discounted price percentage in badges - it only displays the "SALE" text. The percentage calculation you're seeing is a feature from your Woodmart theme.

    Regarding the variable products sometimes not showing the badge at all in archives (not even the "SALE" text) - this might be a caching issue. Variable products tend to get heavily cached in WooCommerce. Try saving the product again to refresh the cache and see if that helps.

     

    As for the badge percentage calculation on variable products, this is trickier. Do all your variations have the same discount percentage? If so, we could potentially create a custom snippet that grabs the discount from the first variation and displays it in the badge.

    If you'd like, I can take a closer look at this directly. Could you share a staging site login?

    Kind regards,
    Stefan

  •  2
    Vladislav replied

    Hi Stefan,

    Yes, please create the custom snippet. Here is exactly what we need for variable products in the archive/shop loop when discounts come from B2BKing Dynamic Rules:

    Requirements

    1. Resolve the product’s default variation (or the lowest-price variation, whichever is simpler) in the archive loop.

    2. Retrieve the rule-adjusted price for that variation based on the B2C (regular) price (to avoid double-discounting from a B2B group price).

    3. Output price HTML so that the card shows the discounted price + crossed regular price.

    4. Show a SALE badge with the correct percentage for that resolved variation (percentage = (regular − discounted) / regular).

    5. If the product has no applicable discount, fall back to the theme’s default output.

    6. Theme: Woodmart, but a theme-agnostic approach via WooCommerce filters is preferred (e.g., woocommerce_get_price_html, woocommerce_variable_price_html, or a helper you recommend).

    7. Please ensure it does not stack with other discount displays and works with logged-in B2B users.

    If there is an internal helper to get the effective Dynamic Rules price for a given variation and user/group outside the single product page, please use it (or let us know which to call).

    We can provide staging access if needed—please share the safest way to send credentials.

    Thanks a lot!
    Vladislav

  •   WebWizards replied privately