Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- (function() {
- /* cart counter different on mb and dt */
- //dt
- var cartCounter = document.querySelector('div.header-action-area.d-none p.v2-cart-counter');
- //mb
- var cartCounter = document.querySelector('div.header-mobile a.header-cart p');
- function adoricAddToCart(productId, addToCartButton) {
- /* add this ti add to cart function */
- addToCartButton.style.backgroundColor = 'rgb(255, 255, 255)';
- addToCartButton.style.border = '1px solid rgb(0, 158, 226)';
- addToCartButton.style.color = '#00adee';
- addToCartButton.textContent = 'Added to cart';
- addToCartButton.style.outline = 'none';
- setTimeout(() => {
- addToCartButton.style.backgroundColor = 'rgb(0, 158, 226)';
- addToCartButton.style.color = 'rgb(255, 255, 255)';
- }, 1500);
- window.adoricAddToCart = data;
- /*--------------*/
- xhr.addEventListener('readystatechange', function() {
- if (this.readyState === 4) {
- /* add here counting in the cart instead of reload */
- cartCounter.textContent = parseInt(cartCounter.textContent) + 1;
- if (cartCounter.classList.contains('d-none')) {
- cartCounter.classList.remove('d-none');
- }
- /*---------------*/
- }
- });
- }
- currentCampaignRepeater.addEventListener('click', function(event) {
- if (event.target.getAttribute('role') === 'button' && productItem) {
- /* here add an addToCartButton value and add it to adoricAddToCart function. Don't forget to
- add the second argument into function */
- var addToCartButton = event.target;
- adoricAddToCart(productId, addToCartButton);
- }
- });
- /* add this event listener on close campaign*/
- adoric.on('lightbox:before:close', function(e) {
- if (e.lightbox.options.campaignId === self.campaignId) {
- if (window.adoricAddToCart) {
- window.location.reload();
- }
- }
- });
- })();
- /* and add to the button link keep opened */
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement