• Resolved bobezac

    (@bobezac)


    What hook is best to used to adjust prices of items during cart and checkout, which should override the rules of this plugin (specific discounts for customer id)

    I’ve tried “wdp_before_apply_to_wc_cart” and “wdp_after_apply_to_wc_cart” but neither of these take effect on the final cart, it is only changed visually, there isn’t very good documentation on how to use “adp_before_apply_rule” or “adp_is_apply_rule” to do anything

    Could you make any suggestions what I should hook to change final prices in the cart and checkout? overriding the rules from the plugin

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter bobezac

    (@bobezac)

    add_filter( "wdp_custom_override_cents", function ( $custom_price, $price, $context, $product ) {
    	
    	//set custom price
    	
    	return $custom_price;
    	
    }, 10, 4 );

    I’ve been able to use this hook as a workaround, open to a more efficient better hook to use if anyone has a suggestion!

    Plugin Author algol.plus

    (@algolplus)

    hi

    Do you want to modify prices for cart items after our rules were applied ?

    Thread Starter bobezac

    (@bobezac)

    Do you want to modify prices for cart items after our rules were applied ?

    Yes, so I’d like the rules to apply as normal, but for specific customers I want to apply my own custom pricing list, but I’m not sure at what point I can hook the cart process to do this and make sure it applies to the actual order processing and not just visually

    Plugin Author algol.plus

    (@algolplus)

    so you tried this hook ?
    add_filter('adp_before_apply_rule', function($rule, $processor, $cart){
    return $rule;
    },10,3);

    Can you share your code and screenshot of the rule ?

    Thread Starter bobezac

    (@bobezac)

    I was not able to test adp_before_apply_rule because I think that would require me to have more complex knowledge of how ADP’s rules are structured in PHP, and I lack the time to reverse engineer that, my rules are thousands of simple bulk quantity discounts, then I have my own database with specific user ID prices in, that I want to lookup and apply different prices that over-ride the bulk discounts, my functions are rather long and complex to get the prices, cache them etc, but I was able to get the desired output using this function

    add_filter( "wdp_custom_override_cents", function ( $custom_price, $price, $context, $product ) {
    	
    	$user_price = lookup_customer_price($product);
    	
    	if ($user_price !== null){
    		$custom_price = $user_price;
    		return $custom_price;
    	}
    	
    }, 10, 4 );

    can you think of a more efficient way to do it? my lookup price function will return null if user is not logged in or is not in the list etc

    Plugin Author algol.plus

    (@algolplus)

    this hook is applied at the end of all calculations, so it’s definitely effective.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Modifying cart prices with php’ is closed to new replies.