The coupons tab is where you can create, and delete coupons, as well as edit existing ones. Coupons, by default, are created one at a time in MemberMouse. However, there may be a situation where you need to create a large number of coupons at once. If you are familiar with PHP, coupons can be added to MemberMouse in bulk using a custom script.
Create A Large Number Of Coupons
To create a large number of coupons, you will need to use the following mySQL statement. Here's the insert SQL for inserting a single coupon:
INSERT INTO mm_coupons (`coupon_name`, `coupon_code`, `coupon_type`, `coupon_value`, `coupon_value_currency`, `description`, `quantity`, `start_date`, `end_date`, `recurring_billing_setting`, `is_gift`, `is_archived`, `gift_user_id`, `gift_order_item_id`, `date_modified`, `date_added`) VALUES ('Sample Coupon', 'sample', 'percentage', '20', 'USD', NULL, '-1', NOW(), NULL, 'all', '0', '0', '0', '0', NOW(), CURRENT_TIMESTAMP);
Note that ‘coupon_value-currency' can be omitted for free coupons, but should be specified for paid ones.
The three possible values for coupon_type are:
So a $10 off coupon would have values like this:
While a 25% off coupons would have values like this:
Once you have your single coupon statement, you will need to write a simple PHP script, iterate over each coupon from a CSV file and run the insert query.
Adding Product Restrictions to Coupons
If you need to add product restrictions to your coupons to ensure that they can only be used for particular products you can use the following query:
INSERT INTO `mm_coupon_restrictions` (`coupon_id`, `product_id`, `date_modified`, `date_added`) VALUES ('<coupon_id>', '<product_id>', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);
Just replace <coupon_id> with the ID of the desired coupon and <product_id> with the ID of the desired product.