Increment price for Woocommerce Minicart [closed]

I developing a script who increment prices based on specific custom fields.

I finished with products and cart but prices dont change in widget cart.

This is my code (Cart hook):

//INCREMENT PRICE IN CART FOR _NAV_PP FIELDS 
add_action( 'woocommerce_before_calculate_totals', 'nav_pp_cart_price', 10, 1);
add_action( 'woocommerce_before_mini_cart_contents', 'nav_pp_cart_price', 10, 1);

function nav_pp_cart_price( $cart_obj ) {
    //  This is necessary for WC 3.0+
    if ( is_admin() && ! defined( 'DOING_AJAX' ) )
        return;

    foreach ( $cart_obj->get_cart() as $key => $value ) {
        $metas = get_post_meta($value['product_id']);
        $price = $value['data']->get_price();

        $final_price = nav_increment_price($price, $metas);
        $value['data']->set_price($final_price);
    }
}

How can i manipulate the woocommerce widget cart prices?

0

Leave a Comment