HEX
Server: Apache/2.4.65 (Ubuntu)
System: Linux ielts-store-v2 6.8.0-1036-gcp #38~22.04.1-Ubuntu SMP Thu Aug 14 01:19:18 UTC 2025 x86_64
User: root (0)
PHP: 7.2.34-54+ubuntu20.04.1+deb.sury.org+1
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/html/ielts-store/wp-content/themes/oceanwp/assets/js/third/woo/devs/wooQuantityButtons.js
var $j = jQuery.noConflict();

$j( window ).ready( function() {
	"use strict";
	// Woo quantity buttons
	oceanwpWooQuantityButtons();
} );

$j( document ).ajaxComplete( function() {
	"use strict";
	// Woo quantity buttons
	oceanwpWooQuantityButtons();
} );

/* ==============================================
WOOCOMMERCE QUANTITY BUTTONS
============================================== */
function oceanwpWooQuantityButtons( $quantitySelector ) {

	var $quantityBoxes
		$cart = $j( '.woocommerce div.product form.cart' );

	if ( ! $quantitySelector ) {
		$quantitySelector = '.qty';
	}

	$quantityBoxes = $j( 'div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)' ).find( $quantitySelector );

	if ( $quantityBoxes && 'date' !== $quantityBoxes.prop( 'type' ) && 'hidden' !== $quantityBoxes.prop( 'type' ) ) {

		// Add plus and minus icons
		$quantityBoxes.parent().addClass( 'buttons_added' ).prepend('<a href="javascript:void(0)" class="minus">-</a>');
        $quantityBoxes.after('<a href="javascript:void(0)" class="plus">+</a>');

		// Target quantity inputs on product pages
		$j( 'input' + $quantitySelector + ':not(.product-quantity input' + $quantitySelector + ')' ).each( function() {
			var $min = parseFloat( $j( this ).attr( 'min' ) );

			if ( $min && $min > 0 && parseFloat( $j( this ).val() ) < $min ) {
				$j( this ).val( $min );
			}
		});

		// Quantity input
		if ( $j( 'body' ).hasClass( 'single-product' )
			&& 'on' == oceanwpLocalize.floating_bar
			&& ! $cart.hasClass( 'grouped_form' )
			&& ! $cart.hasClass( 'cart_group' ) ) {
			var $quantityInput = $j( '.woocommerce form input[type=number].qty' );
			$quantityInput.on( 'keyup', function() {
				var qty_val = $j( this ).val();
				$quantityInput.val( qty_val );
			});
		}

		$j( '.plus, .minus' ).unbind( 'click' );

		$j( '.plus, .minus' ).on( 'click', function() {

			// Quantity
			var $quantityBox;

			// If floating bar is enabled
			if ( $j( 'body' ).hasClass( 'single-product' )
				&& 'on' == oceanwpLocalize.floating_bar
				&& ! $cart.hasClass( 'grouped_form' )
				&& ! $cart.hasClass( 'cart_group' ) ) {
				$quantityBox = $j( '.plus, .minus' ).closest( '.quantity' ).find( $quantitySelector );
			} else {
				$quantityBox = $j( this ).closest( '.quantity' ).find( $quantitySelector );
			}

			// Get values
			var $currentQuantity = parseFloat( $quantityBox.val() ),
			    $maxQuantity     = parseFloat( $quantityBox.attr( 'max' ) ),
			    $minQuantity     = parseFloat( $quantityBox.attr( 'min' ) ),
			    $step            = $quantityBox.attr( 'step' );

			// Fallback default values
			if ( ! $currentQuantity || '' === $currentQuantity  || 'NaN' === $currentQuantity ) {
				$currentQuantity = 0;
			}
			if ( '' === $maxQuantity || 'NaN' === $maxQuantity ) {
				$maxQuantity = '';
			}

			if ( '' === $minQuantity || 'NaN' === $minQuantity ) {
				$minQuantity = 0;
			}
			if ( 'any' === $step || '' === $step  || undefined === $step || 'NaN' === parseFloat( $step )  ) {
				$step = 1;
			}

			// Change the value
			if ( $j( this ).is( '.plus' ) ) {

				if ( $maxQuantity && ( $maxQuantity == $currentQuantity || $currentQuantity > $maxQuantity ) ) {
					$quantityBox.val( $maxQuantity );
				} else {
					$quantityBox.val( $currentQuantity + parseFloat( $step ) );
				}

			} else {

				if ( $minQuantity && ( $minQuantity == $currentQuantity || $currentQuantity < $minQuantity ) ) {
					$quantityBox.val( $minQuantity );
				} else if ( $currentQuantity > 0 ) {
					$quantityBox.val( $currentQuantity - parseFloat( $step ) );
				}

			}

			// Trigger change event
			$quantityBox.trigger( 'change' );

		} );
	}
}