Is it possible to recalculate cart prices?


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;
Albert 4 years 2017-09-01T04:14:07-05:00 0 Answers 73 views 0

Leave an answer