Untitled
unknown
plain_text
3 months ago
1.3 kB
3
Indexable
add_filter( 'woocommerce_is_purchasable', 'b2bking_hidden_items_not_purchasable', 1000000, 2); add_filter( 'woocommerce_variation_is_purchasable', 'b2bking_hidden_items_not_purchasable', 1000000, 2); function b2bking_hidden_items_not_purchasable($purchasable, $product){ $current_product_id = intval($product->get_id()); $currentuserid = get_current_user_id(); if (!defined('ICL_LANGUAGE_NAME_EN')){ $allTheIDs = get_transient('b2bking_user_'.$currentuserid.'_ajax_visibility'); } else { $allTheIDs = get_transient('b2bking_user_'.$currentuserid.'_ajax_visibility'.ICL_LANGUAGE_NAME_EN); } if (!is_array($allTheIDs)){ $allTheIDs = array(); } $offer_id = intval(get_option('b2bking_offer_product_id_setting', 0)); $credit_id = intval(get_option('b2bking_credit_product_id_setting', 0)); $mkcredit_id = intval(get_option('marketking_credit_product_id_setting', 0)); $possible_parent_id = wp_get_post_parent_id($current_product_id); // if user is guest, or multisite b2b/b2b separation is enabled and user should be treated as guest if (!in_array($current_product_id, $allTheIDs) && $current_product_id !== $offer_id && $current_product_id !== $credit_id && $current_product_id !== $mkcredit_id && !in_array($possible_parent_id, $allTheIDs)){ $purchasable = false; } return $purchasable; }
Editor is loading...
Leave a Comment