
Coupons
One-time discount coupons reduce the total cart cost.
You create coupon groups with absolute or percent discount and optional expiry. Use unique prefixes to tell groups apart.
When a group runs out of coupons you can generate more in the same group by entering a larger count when editing and saving.
To avoid copying hundreds of codes by hand, export codes as CSV, which opens in common editors including MS Excel and LibreOffice. Exports can be used for activation stats or printed materials.
When a coupon is redeemed, the miniShop2 order ID and activation time are stored.
Adding coupons to the order
Coupons require miniShop2 1.11 stable. For 2.2-beta you can apply changes yourself or wait for the developers.
To let the customer enter a code at checkout, add a new field to the checkout chunk.
In miniShop2.2 use tpl.msOrder.outer:
<div class="form-group input-parent">
<label class="col-sm-4 control-label" for="coupon_code">Discount coupon</label>
<div class="col-sm-6">
<input type="coupon_code" id="coupon_code" placeholder="XXXXX-XXXX-XXXX-XXXX" name="coupon_code" value="[[+coupon_code]]" class="form-control">
</div>
</div>In 2.4 use tpl.msOrder:
<div class="form-group input-parent">
<label class="col-sm-4 control-label" for="coupon_code">Discount coupon</label>
<div class="col-sm-6">
<input type="coupon_code" id="coupon_code" placeholder="XXXXX-XXXX-XXXX-XXXX" name="coupon_code" value="{$order.coupon_code}" class="form-control">
</div>
</div>Example for standard Bootstrap 3 layout.
When a coupon is added it is validated; on error a message is shown and the field is not saved.
Message text can be changed in system lexicons.
When the coupon is valid, the price update looks like this (gif):
To recalculate order cost when the coupon field changes, add an MS2 callback.
For 2.2:
$(document).ready(function () {
miniShop2.Callbacks.Order.add.ajax.done = function (res) {
var res = res.responseJSON;
if (typeof res.data.coupon_code !== 'undefined' || !res.success) {
miniShop2.Order.getcost();
};
};
});For 2.4+:
$(document).ready(function () {
miniShop2.Callbacks.add('Order.add.ajax.done', 'msdiscount', function (res) {
var res = res.responseJSON;
if (typeof res.data.coupon_code !== 'undefined' || !res.success) {
miniShop2.Order.getcost();
};
});
});You can put this in site scripts or in the checkout chunk.





