Okay
  Public Ticket #4246284
about rules bug
Closed

Comments

  •  1
    Vladislav started the conversation

    Hello,

    We are reporting a potential bug with the "Apply discount as sale price" option in dynamic rules.

    Problem description:

    • When the option is disabled, the discount is calculated based on the B2B group price (not the B2C/regular price).

    • When the option is enabled, the discount is applied immediately as a sale price, even when the quantity condition is not met (e.g., the rule requires 3 items, but the discount is triggered with only 1 item).

    We have double-checked the rule configuration and are running the latest version of B2BKing, so this is not a configuration issue.

    What we need:

    1. The discount must respect the quantity condition (≥ 3 items).

    2. The discount should be calculated from the B2C (regular) price, not the B2B group price, when "Apply discount as sale price" is enabled.

    Could you please confirm if this is a known bug?
    If yes, do you have a temporary fix or code snippet that we could use until a permanent solution is available?

    Thank you in advance for your help!

  •  2,496
    WebWizards replied

    Hi Vladislav,

    Glad to assist,

    1. Regarding the discount calculation from B2C/regular price - yes, by default these discounts are applied based on the user's regular price, and for B2B users the group price is considered their regular price. However, I can provide you with a code snippet that will force the rules to always use the B2C regular price: https://pastecode.io/s/a78mwiw0

     

    You can add this to your theme's functions.php file or using a code snippets plugin.

    2. Regarding the conditions issue - this is important to note: for category rules, only category conditions apply, and for product rules, only product conditions apply. If you have a category rule but set a product condition, that condition won't be applied, which might explain the behavior you're seeing.

    Could you please share a screenshot of your rule configuration so we can take a closer look?

    Kind regards,
    Stefan

  •  1
    Vladislav replied

    I’m writing regarding the dynamic discount rule we discussed earlier.

    We noticed the following:

    1. When the option “Apply discount as sale price” is enabled, a 50 % discount is immediately applied to each product associated with the rule (shown as a “sale” price), even though the rule specifies that the discount should apply only when 3 units are added to the cart.

    2. When this option is disabled, the discount is applied only in the cart, but it is calculated from the B2B group price rather than the B2C (retail) price.

    3. We need the discount to apply only when the customer adds 3 or more units to the cart and to be based on the B2C price (not the B2B price).

    4. We added the code snippet you provided—intended to force the discount calculation to use the retail price—but it did not change the behaviour described above.

    Could you please confirm whether this is a known bug and suggest a workaround or fix to ensure that the discount is applied according to the rules and calculated from the B2C price? I can provide screenshots of the settings and results if needed (I have attached them).

    Thank you in advance for your help.

    Attached files:  cbd448a8-8c3b-4127-83d0-526a125b18e8.jpg
      e917ed21-4ab5-42f4-85bd-12ee7d40136e.jpg
      a8495d26-586d-4b73-aaa3-01f38872fac9.jpg
      Screenshot 2025-08-04 194334.png

  •  2,496
    WebWizards replied

    Hi Vladislav,

    Thanks for providing those details,

    1. I noticed the rule is currently set up with category conditions, but it only contains products. This is causing the conditions not to work as expected - for category rules, only category conditions apply, while for product rules, only product conditions apply. To fix this, you'll need to change from 'category qty' to 'product qty' in your rule conditions here: https://prnt.sc/h8y2YMA-UdqN

     

    2. Regarding the discount calculation based on retail price - I've tested this on my local site and the code snippet should make the discount calculate based on the B2C price. For example, if a product has:
    - B2B group price: $50 
    - B2C price: $60
    With a 50% discount, the final price should be $30 (half of B2C price) rather than $25 (half of B2B price).

    You can see this behavior demonstrated here: https://www.loom.com/share/debf8acf060047c7af23e4588ee825af?sid=3c5cbd9c-f08a-4891-9543-bf6989b1674c

     

    I also notice in your screenshots that the product page price is $43 but shows as $60.2 in cart. If this isn't due to tax calculations, you may have a pricing conflict with another plugin. I'd recommend checking if any other plugins are affecting your pricing.

     

    Kind regards,
    Stefan