I've created a coupon and tried to set the "Maximum number of applicable products" to 1 while limiting the coupon to just 2 possible SKUs. When I submit the form, I get the validation error: "To use the maximum number of applicable products feature, you must restrict the coupon by product class, product node, SKU, or taxonomy term."

Looking at the code, line 641 of uc_coupon.module is

$restrictions = array_filter($form_state['values']['product_types'] + $form_state['values']['products'] + $form_state['values']['skus'] + $form_state['values']['terms']);

which doesn't make sense to me as I've never seen the '+' operator used on arrays like this. I tried replacing the line with this

$restrictions = array_filter(array_merge($form_state['values']['product_types'],$form_state['values']['products'],$form_state['values']['skus'],$form_state['values']['terms']));

and the validation now works in my case.

Comments

longwave’s picture

Status: Active » Fixed

Fixed, thanks for the report.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.