Title: How to modify your javascript files or add functionality?
Last modified: April 12, 2020

---

# How to modify your javascript files or add functionality?

 *  Resolved [gruntek](https://wordpress.org/support/users/gruntek/)
 * (@gruntek)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/how-to-modify-your-javascript-files-or-add-functionality/)
 * 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 6 years, 1 month ago by [gruntek](https://wordpress.org/support/users/gruntek/).

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [xootix](https://wordpress.org/support/users/xootix/)
 * (@xootix)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/how-to-modify-your-javascript-files-or-add-functionality/#post-12667742)
 * Hello [@gruntek](https://wordpress.org/support/users/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](https://wordpress.org/support/users/gruntek/)
 * (@gruntek)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/how-to-modify-your-javascript-files-or-add-functionality/#post-12674192)
 * 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](https://wordpress.org/support/users/xootix/)
 * (@xootix)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/how-to-modify-your-javascript-files-or-add-functionality/#post-12679588)
 * Hello [@gruntek](https://wordpress.org/support/users/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](https://wordpress.org/support/users/gruntek/)
 * (@gruntek)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/how-to-modify-your-javascript-files-or-add-functionality/#post-12725663)
 * 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.

 * ![](https://ps.w.org/side-cart-woocommerce/assets/icon-256x256.gif?rev=3217170)
 * [Side Cart Woocommerce | Woocommerce Cart](https://wordpress.org/plugins/side-cart-woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/side-cart-woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/side-cart-woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/side-cart-woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/side-cart-woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/side-cart-woocommerce/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [gruntek](https://wordpress.org/support/users/gruntek/)
 * Last activity: [6 years, 1 month ago](https://wordpress.org/support/topic/how-to-modify-your-javascript-files-or-add-functionality/#post-12725663)
 * Status: resolved