Last active
July 20, 2021 16:38
-
-
Save plugin-republic/1450dff7d42a1a8dc57b5dfffac52921 to your computer and use it in GitHub Desktop.
This file contains 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