mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-04-30 11:42:22 +08:00
https://stackoverflow.com/questions/63995559/woocommerce-cart-subtotal-display-free-instead-of-0-00/
17 lines
760 B
Text
17 lines
760 B
Text
// Cart and minicart
|
|
add_filter( 'woocommerce_cart_item_price', 'change_cart_item_price_html', 10, 3 );
|
|
function change_cart_item_price_html( $price_html, $cart_item, $cart_item_key ) {
|
|
if( $cart_item['data']->get_price() == 0 ) {
|
|
return '<span class="woocommerce-Price-amount amount">'.__("FREE", "woocommerce").'</span>';
|
|
}
|
|
return $price_html;
|
|
}
|
|
|
|
// Cart and Checkout
|
|
add_filter( 'woocommerce_cart_item_subtotal', 'change_checkout_item_subtotal_html', 10, 3 );
|
|
function change_checkout_item_subtotal_html( $subtotal_html, $cart_item, $cart_item_key ) {
|
|
if( $cart_item['data']->get_price() == 0 ) {
|
|
return '<span class="woocommerce-Price-amount amount">'.__("FREE", "woocommerce").'</span>';
|
|
}
|
|
return $subtotal_html;
|
|
}
|