Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

is it possible to change product price in Woocommerce Mini Cart Widget? I've overrided price in cart using tips from WooCommerce: Add product to cart with price override? but it only works for cart page. Prices in widget are not changed.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
851 views
Welcome To Ask or Share your Answers For Others

1 Answer

Instead of using "woocommerce_before_calculate_totals" you can use "woocommerce_cart_item_price" filter, some thing like

add_filter('woocommerce_cart_item_price','modify_cart_product_price',10,3);

function modify_cart_product_price( $price, $cart_item, $cart_item_key){
    $price = wc_price($custom_price, 4); 
    return $price;
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...