array intersect error when using coupon code allowed category

Started by Kuubs, September 27, 2023, 16:11:02 PM

Previous topic - Next topic

Kuubs

for( $i = 0; $i<$sizeof_cartitems_by_product; $i++ ) {

if( (!empty($allowed_product_ids) and in_array( $this->cartPrices[$i]['virtuemart_product_id'], $allowed_product_ids )) || (!empty($allowed_productcat_ids) and array_intersect( $this->products[$i]->categories, $allowed_productcat_ids )) ) {
$allow_coupon_byproduct = 1;
break;
}
}


This piece of code in the helper of the cart in /components/virtuemart/helpers/cart.php

sometimes gives an error because the array of products start at 1 instead of 0, which makes it error, because the first intersect is null instead of an array...