• Resolved gruntek

    (@gruntek)


    Hi, plugin is awesome, thank you!

    I made that change in xoo-wsc-public.js file, it trigers closing my popups when “toggle side cart” and when “close side cart”.

    Is it possible to somehow do the same without editing your files soo an update won’t override my changes?

    Below is what I added:

    My code: $('a.evr-close').click();

    First change is here: `//Toggle Side Cart
    function toggle_sidecart(toggle_type){
    var toggle_element = $(‘.xoo-wsc-modal , body, html’),
    toggle_class = ‘xoo-wsc-active’;
    $(‘a.evr-close’).click();

    if(toggle_type == ‘show’){
    toggle_element.addClass(toggle_class);
    }
    else if(toggle_type == ‘hide’){
    toggle_element.removeClass(toggle_class);
    }
    else{
    toggle_element.toggleClass(‘xoo-wsc-active’);
    }

    unblock_cart();
    }

    $(‘.xoo-wsc-basket’).on(‘click’,toggle_sidecart);

    if(xoo_wsc_localize.trigger_class){
    $(‘.’+xoo_wsc_localize.trigger_class).on(‘click’,toggle_sidecart);
    }`

    Second change is here: ` //Close Side Cart
    function close_sidecart(e){
    $.each(e.target.classList,function(key,value){
    if(value != ‘xoo-wsc-container’ && (value == ‘xoo-wsc-close’ || value == ‘xoo-wsc-opac’ || value == ‘xoo-wsc-basket’ || value == ‘xoo-wsc-cont’)){
    $(‘.xoo-wsc-modal , body, html’).removeClass(‘xoo-wsc-active’);
    $(‘a.evr-close’).click();
    }
    })
    }`

    • This topic was modified 4 years, 7 months ago by gruntek.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author xootix

    (@xootix)

    Hello @gruntek

    Glad you like the plugin, would really appreciate if you leave a review.
    Regarding your custom code, from what I can understand is, you are trying to close something. You did not mention at what event/time you want to close.
    Try pasting this in your functions.php

    add_action( 'wp_footer', function(){
     ?>
     <script type="text/javascript">
     	jQuery(document).ready(function(){
     		$('body').on('click', '.xoo-wsc-close , .xoo-wsc-opac, .xoo-wsc-basket', function(){
    			$('a.evr-close').trigger('click');
    		})
    
    		$(document).on('added_to_cart', function(){
    			$('a.evr-close').trigger('click');
    		})
     	})
     </script>
     <?php
    } );
    Thread Starter gruntek

    (@gruntek)

    I use popups for Divi, I have add to cart buttons with variations placed in multipl popups. When popup is open you can add product to cart. When you add a product to cart the cart is sliding in – that’s the place where I want the open popup to close.

    Also I want my popups to be closed when the Side Cart is opened and user close the cart.

    You code is breaking my Divi theme – some modules doesn’t work properly including popups. There is jquery error in console:

    Uncaught TypeError: $ is not a function
        at HTMLDocument.<anonymous> ((index):1805)
        at i (jquery.js?ver=1.12.4-wp:2)
        at Object.fireWith [as resolveWith] (jquery.js?ver=1.12.4-wp:2)
        at Function.ready (jquery.js?ver=1.12.4-wp:2)
        at HTMLDocument.J (jquery.js?ver=1.12.4-wp:2)
    Plugin Author xootix

    (@xootix)

    Hello @gruntek

    I am sorry, the $ sign was missing in jQuery(document).ready(function(){

    add_action( 'wp_footer', function(){
     ?>
     <script type="text/javascript">
     	jQuery(document).ready(function($){
     		$('body').on('click', '.xoo-wsc-close , .xoo-wsc-opac, .xoo-wsc-basket', function(){
    			$('a.evr-close').trigger('click');
    		})
    
    		$(document).on('added_to_cart', function(){
    			$('a.evr-close').trigger('click');
    		})
     	})
     </script>
     <?php
    } );
    Thread Starter gruntek

    (@gruntek)

    Working great now ?? Thank you!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to modify your javascript files or add functionality?’ is closed to new replies.