@lovata/shopaholic-coupon
v1.0.0
Published
Package adds helper methods for integration with [Coupons for Shopaholic](https://octobercms.com/plugin/lovata-couponsshopaholic) and [Shopaholic](https://octobercms.com/plugin/lovata-shopaholic) plugins.
Downloads
8
Readme
Coupon for Shopaholic package
Package adds helper methods for integration with Coupons for Shopaholic and Shopaholic plugins.
Package will allow you to quickly "apply coupon" button to checkout page.
installation
npm install @lovata/shopaholic-coupon
Basic usage
<input type="text" name="coupon" value="">
<button class="_shopaholic-coupon-add">Apply coupon</button>
<button class="_shopaholic-coupon-remove">Remove coupon</button>
Simple example:
import ShopaholicCouponAdd from "@lovata/shopaholic-coupon/shopaholic-coupon-add";
import ShopaholicCouponRemove from "@lovata/shopaholic-coupon/shopaholic-coupon-remove";
const obShopaholicCouponAdd = new ShopaholicCouponAdd();
const obShopaholicCouponRemove = new ShopaholicCouponRemove();
obShopaholicCouponAdd.init();
obShopaholicCouponRemove.init();
Advanced example:
import ShopaholicCouponAdd from "@lovata/shopaholic-coupon/shopaholic-coupon-add";
import ShopaholicCouponRemove from "@lovata/shopaholic-coupon/shopaholic-coupon-remove";
const obShopaholicCouponAdd = new ShopaholicCouponAdd();
const obShopaholicCouponRemove = new ShopaholicCouponRemove();
obShopaholicCouponAdd
.setAjaxRequestCallback(function(obRequestData, obInput, obButton) {
obRequestData.loading = '.preloader';
return obRequestData;
})
.init();
obShopaholicCouponRemove
.setAjaxRequestCallback(function(obRequestData, obInput, obButton) {
obRequestData.loading = '.preloader';
return obRequestData;
})
.init();
Methods
init()
Method adds 'click' event listener on buttons with classes "_shopaholic-coupon-add", "_shopaholic-coupon-remove".
setAjaxRequestCallback()
You can set callback function. This callback function will be called before sending ajax request.
You can change request object inside callback function. For example: add called partial and selector, add preloader class, etc.