No Partying Mariachis

    @lovata/shopaholic-coupon

    1.0.0 • Public • Published

    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.

    Install

    npm i @lovata/shopaholic-coupon

    DownloadsWeekly Downloads

    20

    Version

    1.0.0

    License

    GPL-3.0-or-later

    Unpacked Size

    8.03 kB

    Total Files

    4

    Last publish

    Collaborators

    • lautsevich
    • andrey_kharanenka