Basically I'm trying to get the second IF
statement to work if the criteria of the first If
statement is met.
The fisrt IF
statement is meant to check against user roles and if it matches with "bba" or "duk", then then second IF
statement will check for specific product ids that should not match avoiding a custom cart wide bulk discount.
I know the second IF
statement works as it works by itself but it disables the bulk discount for all users instead of specific defined ones.
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;
}
}
}
With both codes the bulk discount is disabled for product IDs 439 and 387 without taking into account the First IF
statement.
How can I make the First IF
statement working and checking for the targeted user roles?
Any help is appreciated.