Add the "limit usage to x items" field to follow up generated coupons
Currently any coupon generated by follow up emails is missing the option to set an item limit. This field is present in normal coupons under usage limits when using product or product% type coupons. This missing fields means coupons made by follow up emails are open to abuse and can be used on an infinite number of items in the cart.
To anyone still waiting, here's the backend part. Corresponding part of the plugin is class-fue-coupons.php.
DB needs to be updated to hold limit_usage_to_x_items value in table _followup_coupons, same as with usage_limit (eg 21 varchar(3) with no default value).
Changes need to be made to functions:
1. In add_variable_replacements() add to the rest of update_post_meta() functions:
update_post_meta( $coupon_id, 'limit_usage_to_x_items', $coupon->limit_usage_to_x_items );
2. In get_coupon_args_from_post() add to $data:
array('limit_usage_to_x_items' => ( isset( $_POST['limit_usage_to_x_items'] ) && ! empty( $_POST['limit_usage_to_x_items'] ) ) ? (int) $_POST['limit_usage_to_x_items'] : '')
3. In get_coupon_data() add to $defaults = array ('limit_usage_to_x_items' => '')
4. And finally in second $defaults in if ( $coupon ) add to $defaults = array('limit_usage_to_x_items' => $coupon->limit_usage_to_x_items,) }
Monthly Review commented
Yes, this an obvious oversight that seems like it could be easily remedied.
Rainer Scheerer commented