• On our website we’ve got the function, which is displayed bellow, to change prices depending on user role. The problem is that if a customer logs in and has the premium role the prices will stay the same as if the customer isn’t in that role. Is there a way to recalculate the cart prices?

    add_filter('woocommerce_get_price', 'return_custom_price', $product, 2);
    add_filter('woocommerce_product_variation_get_price', 'return_custom_price', $product, 2);
    
    function return_custom_price($price, $product) {    
    if ( ! current_user_can('premium') || ! is_user_logged_in()) {
    		global $post, $woocommerce;
    		return $new_price = $price * 1.25;   
      }
      return $price;
    } 
  • The topic ‘recalculate cart prices after login’ is closed to new replies.