Forked from plugin-republic/woocommerce_cart_item_price.php
Created
July 20, 2021 16:38
-
-
Save tamara-m/a0bcb7f3215ebf58f71aa91b5329e7b6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Return a blank instead of the product for products that contain child products | |
*/ | |
function my_prefix_cart_item_price( $price, $cart_item, $cart_item_key ) { | |
$product_id = $cart_item['data']->get_id(); | |
// Add the product IDs here that contain child products | |
if( in_array( $product_id, array( 5121, 2222 ) ) ) { | |
// You can enter different text below if you wish | |
return '-'; | |
} | |
return $price; | |
} | |
add_filter( 'woocommerce_cart_item_price', 'my_prefix_cart_item_price', 10, 3 ); | |
function my_prefix_cart_item_subtotal( $subtotal, $cart_item, $cart_item_key ) { | |
$product_id = $cart_item['data']->get_id(); | |
// Add the product IDs here that contain child products | |
if( in_array( $product_id, array( 5121, 2222 ) ) ) { | |
// You can enter different text below if you wish | |
return '-'; | |
} | |
$subtotal; | |
} | |
add_filter( 'woocommerce_cart_item_subtotal', 'my_prefix_cart_item_subtotal', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment