Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
609 B
2
Indexable
add_filter('b2bking_applicable_rules_products', function($results, $rule_type, $product_id, $user_id, $categories_array){

	$account_type = get_user_meta(get_current_user_id(),'b2bking_account_type', true);		
	$parent_account_id = intval(get_user_meta(get_current_user_id(), 'b2bking_account_parent', true)); 

	if ($account_type !== 'subaccount' or $parent_account_id !== 1){
		// abort
		return $results;
	}

	$rules = $results[0];

	if ($rule_type == 'discount_everywhere'){
	    foreach ($rules as $index => $rule_id){
	    	unset($rules[$index]);
	    }
	}

	return array($rules, $results[1]);
}, 10, 5);