HEX
Server: Apache/2.4.57 (Debian)
System: Linux web-server-k8s-e92jnr3j-6f99bff6b6-rp2wg 6.1.0-22-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.94-1 (2024-06-21) x86_64
User: apache (48)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
Upload Files
File: /var/www/sites/1250.info/wp-content/themes/savoy/assets/js/dev/nm-shop-cart.js
(function($) {
	
	'use strict';
	
	// Extend core script
	$.extend($.nmTheme, {
		
		/**
		 *	Initialize cart scripts
		 */
		cart_init: function() {
			var self = this;
			
            
			// Init quantity buttons
            self.quantityInputsBindButtons($('.woocommerce'));
            
            
            /* Bind: "added_to_cart" event (products can be added via cross sells) */
            self.$body.on('added_to_cart', function() {
                // Is the quick-view visible?
                if ($('#nm-quickview').is(':visible')) {
                    self.cartTriggerUpdate();
                }
            });
            
            
            /* Coupon - Bind: Coupon toggle button */
            $('#nm-coupon-btn').on('click', function(e) {
                e.preventDefault();
                
                $(this).next('.nm-coupon').slideToggle(300);
            });
            
            
            /* Coupon - Bind: "Apply coupon" button */
            $('#nm-apply-coupon-btn').on('click', function(e) {
                e.preventDefault();
                
                var couponInputVal = $('#nm-coupon-code').val();
                
                //if (couponInputVal && couponInputVal.length > 0) {
                    var $woocommerceCouponField = $('#coupon_code');
                    
                    // Add coupon code to original WooCommerce coupon field
                    $woocommerceCouponField.val(couponInputVal);
                    // Trigger "click" event on original WooCommerce "Apply coupon" button to submit form
                    $woocommerceCouponField.next('.button').trigger('click');
                    
                    // Scroll to page top (so loading-overlay and notice is visible)
                    setTimeout(function() {
                        $('html, body').animate({'scrollTop': 0}, self.shopScrollSpeed);
                    }, 200);
                //}
            });
		},
        
        
        /**
		 *	Trigger update button
		 */
        cartTriggerUpdate: function() {
            // Get original update button
            var $wooUpdateButton = $('div.woocommerce > form button[name="update_cart"]');

            // Trigger "click" event
            setTimeout(function() { // Use a small timeout to make sure the element isn't disabled
                $wooUpdateButton.trigger('click');
            }, 100);
        }
		
	});
	
	// Add extension so it can be called from $.nmThemeExtensions
	$.nmThemeExtensions.cart = $.nmTheme.cart_init;
	
})(jQuery);