Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tamara-m/a0bcb7f3215ebf58f71aa91b5329e7b6 to your computer and use it in GitHub Desktop.
Save tamara-m/a0bcb7f3215ebf58f71aa91b5329e7b6 to your computer and use it in GitHub Desktop.
<?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