function custom_woocommerce_product_add_to_cart_text() {
global $product;
$product_type = $product->product_type;
switch ( $product_type ) {
case 'external':
//return __( 'Take me to their site!', 'woocommerce' );
break;
case 'grouped':
//return __( 'VIEW THE GOOD STUFF', 'woocommerce' );
break;
case 'simple':
return __( 'מוצר זה לא זמין לתפריט הנבחר', 'woocommerce' );
break;
case 'variable':
//return __( 'Select the variations, yo!', 'woocommerce' );
break;
default:
//return __( 'Read more', 'woocommerce' );
}
}
add_action( 'woocommerce_is_purchasable', 'hide_add_to_cart_function', 10, 2 );
function hide_add_to_cart_function( $return_value, $product ){
$to_show_btu = false;
$terms = get_the_terms( $product->get_id(), 'menu' );
foreach ($terms as $term) {
if($_SESSION['field_4563e2d'] == $term->name){
$to_show_btu = true;
}
}
if ($to_show_btu == true) {
return $return_value;
}else{
add_filter( 'woocommerce_product_add_to_cart_text' , 'custom_woocommerce_product_add_to_cart_text' );
add_action('woocommerce_after_shop_loop_item','replace_add_to_cart');
// return true;
return false;
}
}
function replace_add_to_cart() {
global $product;
echo "<p>*לא ניתן להזמין מוצר לתפריט הנבחר</p>";
// $link = $product->get_permalink();
// echo do_shortcode('<a href="'.$link.'" class="button addtocartbutton">Skoða Vöru</a>');
}