0

Using the commercial WooCommerce dynamic pricing plugin and need to modify the way it applies discounts. This is somewhat related to Exclude product categories from custom dynamic pricing in Woocommerce answer code.

  • Role Pricing. I have this set to discount all products for specific roles.
  • Advanced Brand Pricing. I have this set to discount certain brands based on the user role. I do not want these combined and right now they do and are performed separate from one another with Role Pricing taking precedence over Advanced Brand Pricing.

Here's an example of what I would like to happen. A customer with a role that offers a 5% discount is purchasing an item that has a brand based discount of 10%. I want the 10% brand discount to override the role discount so that only a 10% discount is applied.

I should also mention that I am using the following code to exclude sale priced items from being further discounted, in case that has any bearing on this.

add_filter( 'woocommerce_dynamic_pricing_process_product_discounts', 'wc_dynamic_pricing_is_product_eligible', 10, 4 );
function wc_dynamic_pricing_is_product_eligible( $eligible, $product, $discounter_name, $discounter_object ) {
    remove_action( 'woocommerce_product_is_on_sale', array(
        WC_Dynamic_Pricing::instance(),
        'on_get_product_is_on_sale'
    ), 10, 2 );

    remove_filter( 'woocommerce_dynamic_pricing_process_product_discounts', 'wc_dynamic_pricing_is_product_eligible', 10, 4 );

    if ( $product->is_on_sale() ) {
        $eligible = false;
    }

    add_filter( 'woocommerce_dynamic_pricing_process_product_discounts', 'wc_dynamic_pricing_is_product_eligible', 10, 4 );
    add_action( 'woocommerce_product_is_on_sale', array(
        WC_Dynamic_Pricing::instance(),
        'on_get_product_is_on_sale'
    ), 10, 2 );

    return $eligible;
}

Currently, I have not been able to do this with the standard plugin options.

I hope I was clear with everything.

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
skinnerjoe
  • 19
  • 4
  • 1
    Kindly, as you are using a commercial plugin that doesn't offer any serious developer documentation and doesn't seem to be opened as most plugins of this kind, you get very poor chances to get any useful answer. – LoicTheAztec Aug 15 '23 at 00:37

0 Answers0