Khandaker Toihidul Islam
Front-end Developer
React Js | Javascript | HTML | CSS | Bootstrap | Wordpress | PHP | Mysql

woocommerce_cart_item_price customization

Need to add the above hook in function.php of active theme

   // Mini cart: Display custom price 
add_filter( 'woocommerce_cart_item_price', 'filter_cart_item_price', 10, 3 );

function filter_cart_item_price( $price_html, $cart_item, $cart_item_key ) {
    if(isset($_COOKIE["momsType"]) && $_COOKIE["momsType"] == "business"  ){			
        $product_price = wc_get_price_excluding_tax( $cart_item['data'] );
    }else{
        $product_price = wc_get_price_including_tax( $cart_item['data'] );
    }
    return wc_price( $product_price );
   
}

You may also like...