Basically I'm trying to get the second IF statement to only trigger if the criteria of the first array is met. Array 1 is meant to check against a users role, if they are in the role “bba” or “duk” then array 2 disables a custom cart wide bulk discount for specific product ids. I know array 2 works as it works by itself but disables the bulk discount for all users when I need to specify which roles should be disabled for. This is my code:
if ( in_array( 'bba', 'duk' (array) $user->roles ) ) {
if( ! in_array($values['product_id'], array('493','387'))){
$quantiy_total += $values['quantity'];
//$price = get_post_meta($values['product_id'] , '_price', true);
$price = $values['line_subtotal'];
// echo "####".$price."####";
$cart_total += $price;
}
}
}
Or my second attempt that doesn’t work either:
if ( ! in_array($user['roles'], array('bba','duk'))){
if( ! in_array($values['product_id'], array('493','387'))){
$quantiy_total += $values['quantity'];
//$price = get_post_meta($values['product_id'] , '_price', true);
$price = $values['line_subtotal'];
// echo "####".$price."####";
$cart_total += $price;
}
}
}
Array 2 is triggering and disabling the bulk discount for product IDs 439 ansd 387 but it's not taking into account the first array and the users role.
Thanks in advance for any help!
Aucun commentaire:
Enregistrer un commentaire