@lovata/shopaholic-wish-list
v1.0.0
Published
Package adds helper methods for integration with [Wish list for Shopaholic](https://octobercms.com/plugin/lovata-wishlistshopaholic) and [Shopaholic](https://octobercms.com/plugin/lovata-shopaholic) plugins.
Downloads
132
Readme
Wish list for Shopaholic package
Package adds helper methods for integration with Wish list for Shopaholic and Shopaholic plugins.
Package will allow you to quickly add "Add to wish list", "Remove from wish list", "Clear wish list" buttons in your project.
installation
npm install @lovata/shopaholic-wish-list
shopaholic-add-wish-list
Class will allow you to quickly add "Add to wish list" button in your project.
Basic usage
<div class="_shopaholic-product-wrapper" data-product-id="{{ obProduct.id }}">
<h2>{{ obProduct.name }}</h2>
<button type="button" class="_shopaholic-add-wish-list-button" aria-label="Add to wish list">
</div>
Simple example:
import ShopaholicAddWishList from "@lovata/shopaholic-wish-list/shopaholic-add-wish-list";
const obHelper = new ShopaholicAddWishList();
obHelper.init();
Advanced example:
import ShopaholicAddWishList from "@lovata/shopaholic-wish-list/shopaholic-add-wish-list";
const obHelper = new ShopaholicAddWishList();
obHelper
.setButtonSelector('.add-wish-list-button')
.setAjaxRequestCallback((obRequestData, obButton) => {
obRequestData.loading = '.preloader';
obRequestData.update = {'wish-list/wish-list-info': '.wish-list-info-wrapper'};
obRequestData.complete = () => {
obButton.hide();
};
return obRequestData;
})
.init();
Methods
init()
Method adds 'click' event listener on "Add to wish list" button.
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.
import ShopaholicAddWishList from "@lovata/shopaholic-wish-list/shopaholic-add-wish-list";
const obHelper = new ShopaholicAddWishList();
obHelper.setAjaxRequestCallback((obRequestData, obButton) => {
obRequestData.loading = '.preloader';
obRequestData.update = {'wish-list/wish-list-info': '.wish-list-info-wrapper'};
obRequestData.complete = () => {
obButton.hide();
};
return obRequestData;
}).init();
setButtonSelector()
Redeclare default selector of "Add to wish list" button. Default value is "._shopaholic-add-wish-list-button".
import ShopaholicAddWishList from "@lovata/shopaholic-wish-list/shopaholic-add-wish-list";
const obHelper = new ShopaholicAddWishList();
obHelper.setButtonSelector('.add-wish-list-button').init();
shopaholic-remove-wish-list
Class will allow you to quickly add "Remove from wish list" button in your project.
Basic usage
<div class="_shopaholic-product-wrapper" data-product-id="{{ obProduct.id }}">
<h2>{{ obProduct.name }}</h2>
<button type="button" class="_shopaholic-remove-wish-list-button" aria-label="Remove from wish list">
</div>
Simple example:
import ShopaholicRemoveWishList from "@lovata/shopaholic-wish-list/shopaholic-remove-wish-list";
const obHelper = new ShopaholicRemoveWishList();
obHelper.init();
Advanced example:
import ShopaholicRemoveWishList from "@lovata/shopaholic-wish-list/shopaholic-remove-wish-list";
const obHelper = new ShopaholicRemoveWishList();
obHelper
.setButtonSelector('.remove-wish-list-button')
.setAjaxRequestCallback((obRequestData, obButton) => {
obRequestData.loading = '.preloader';
obRequestData.update = {'wish-list/wish-list-info': '.wish-list-info-wrapper'};
obRequestData.complete = () => {
obButton.hide();
};
return obRequestData;
})
.init();
Methods
init()
Method adds 'click' event listener on "Remove from wish list" button.
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.
import ShopaholicRemoveWishList from "@lovata/shopaholic-wish-list/shopaholic-remove-wish-list";
const obHelper = new ShopaholicRemoveWishList();
obHelper.setAjaxRequestCallback((obRequestData, obButton) => {
obRequestData.loading = '.preloader';
obRequestData.update = {'wish-list/wish-list-info': '.wish-list-info-wrapper'};
obRequestData.complete = () => {
obButton.hide();
};
return obRequestData;
}).init();
setButtonSelector()
Redeclare default selector of "Remove from wish list" button. Default value is "._shopaholic-remove-wish-list-button".
import ShopaholicRemoveWishList from "@lovata/shopaholic-wish-list/shopaholic-remove-wish-list";
const obHelper = new ShopaholicRemoveWishList();
obHelper.setButtonSelector('.remove-wish-list-button').init();
shopaholic-clear-wish-list
Class will allow you to quickly add "Clear wish list" button in your project.
Basic usage
<button type="button" class="_shopaholic-clear-wish-list-button" aria-label="Clear wish list">
Simple example:
import ShopaholicClearWishList from "@lovata/shopaholic-wish-list/shopaholic-clear-wish-list";
const obHelper = new ShopaholicClearWishList();
obHelper.init();
Advanced example:
import ShopaholicClearWishList from "@lovata/shopaholic-wish-list/shopaholic-clear-wish-list";
const obHelper = new ShopaholicClearWishList();
obHelper
.setButtonSelector('.clear-wish-list-button')
.setAjaxRequestCallback((obRequestData, obButton) => {
obRequestData.loading = '.preloader';
obRequestData.update = {'wish-list/wish-list-info': '.wish-list-info-wrapper'};
obRequestData.complete = () => {
obButton.hide();
};
return obRequestData;
})
.init();
Methods
init()
Method adds 'click' event listener on "Clear wish list" button.
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.
import ShopaholicClearWishList from "@lovata/shopaholic-wish-list/shopaholic-clear-wish-list";
const obHelper = new ShopaholicClearWishList();
obHelper.setAjaxRequestCallback((obRequestData, obButton) => {
obRequestData.loading = '.preloader';
obRequestData.update = {'wish-list/wish-list-info': '.wish-list-info-wrapper'};
obRequestData.complete = () => {
obButton.hide();
};
return obRequestData;
}).init();
setButtonSelector()
Redeclare default selector of "Clear from wish list" button. Default value is "._shopaholic-clear-wish-list-button".
import ShopaholicClearWishList from "@lovata/shopaholic-wish-list/shopaholic-clear-wish-list";
const obHelper = new ShopaholicClearWishList();
obHelper.setButtonSelector('.clear-wish-list-button').init();
License
© 2019, LOVATA Group, LLC under GNU GPL v3.
Developed by Andrey Kharanenka.