|
// Add this to the child theme's functions.php |
|
// This will hide the Price of the product, and swap it out with text of your choice. It will also remove the add to cart button. |
|
// It could probably be more elegant, since some of the code is duplicated between the 2 functions, but it works just fine as is. |
|
|
|
// Remove add to cart functionality for specific products |
|
|
|
add_filter('woocommerce_is_purchasable', 'my_woocommerce_is_purchasable', 10, 2); |
|
function my_woocommerce_is_purchasable($is_purchasable, $product) { |
|
$skus = array('40-50-134','40-50-132','RB1000','RB1008','RB1009','RP1000','90-15-008','RP1009','RB1010','RB1011','RB1014','RB1016','RP1034','RP1036','40-50-125','RB1013','DB5018','DB5016','DB5006','XR5048','RG1000','DB5025','40-50-115','40-50-114','40-50-117','40-50-110','40-50-136','40-50-121','40-50-108','40-50-113','40-50-111','40-50-105','40-50-106'); |
|
$id = array(); |
|
foreach ($skus as $sku) { |
|
$id[] = wc_get_product_id_by_sku( $sku ); |
|
} |
|
|
|
if(in_array($product->id, $id) && $is_purchasable) return false; |
|
else return true; |
|
} |
|
|
|
|
|
// Remove Price, swap with text |
|
add_filter('woocommerce_get_price_html', 'show_price_logged'); |
|
|
|
function show_price_logged($price){ |
|
global $product; |
|
$skus = array('40-50-134','40-50-132','RB1000','RB1008','RB1009','RP1000','90-15-008','RP1009','RB1010','RB1011','RB1014','RB1016','RP1034','RP1036','40-50-125','RB1013','DB5018','DB5016','DB5006','XR5048','RG1000','DB5025','40-50-115','40-50-114','40-50-117','40-50-110','40-50-136','40-50-121','40-50-108','40-50-113','40-50-111','40-50-105','40-50-106'); |
|
$id = array(); |
|
foreach ($skus as $sku) { |
|
$id[] = wc_get_product_id_by_sku( $sku ); |
|
} |
|
|
|
if(in_array($product->id, $id)){ |
|
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' ); |
|
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 ); |
|
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 ); |
|
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 ); |
|
$price = 'Call For Pricing'; |
|
return $price; |
|
} |
|
else |
|
{ |
|
return $price; |
|
} |
|
} |