• Resolved danvssl

    (@danvssl)


    This plugin works great, except it doesn’t follow any of the pricing rules set up in the dynamic pricing plugin.

    Is this something on the roadmap?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author algol.plus

    (@algolplus)

    Hi Dan

    I’ve replied to the ticket in helpdesk.

    I’ll post the solution here.
    thanks, Alex

    Thread Starter danvssl

    (@danvssl)

    Thank you.

    Plugin Author algol.plus

    (@algolplus)

    Following code has solved the problem for role based pricing rules

    // Phone Orders + Dymamic Pricing 
    add_filter( 'woocommerce_dynamic_pricing_is_rule_set_valid_for_user', function($result, $condition, $rule_set){
    	// ajax request from Phone orders?
    	if ( is_admin() && is_ajax() && $condition['type'] == 'apply_to' ) {
    		$result = 0;
    		if ( $condition['args']['applies_to'] == 'everyone' ) {
    				$result = 1;
    		} elseif ( $condition['args']['applies_to'] == 'unauthenticated' ) {
    			if ( !isset($_POST['cart']['customer']['id']) ) {
    				$result = 1;
    			}
    		} elseif ( $condition['args']['applies_to'] == 'authenticated' ) {
    			if ( isset($_POST['cart']['customer']['id']) ) {
    				$result = 1;
    			}
    		} elseif ( $condition['args']['applies_to'] == 'roles' && isset( $condition['args']['roles'] ) && is_array( $condition['args']['roles'] ) && isset($_POST['cart']['customer']['id']) ) {
    			$user_id = intval( $_POST['cart']['customer']['id'] );
    			foreach ( $condition['args']['roles'] as $role ) {
    				if ( user_can( $user_id, $role ) ) {
    					$result = 1;
    					break;
    				}
    			}
    		}
    	}
    	return $result;
    }, 10, 3 );
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Work with Dynamic Pricing Plugin’ is closed to new replies.