// source --> https://sleepcomfort.com/wp-content/themes/tondaChild/js/custom_script.js?ver=6.9.4 
function gatewayFunction($this){
	console.log($this);
    console.log('get_form_value');
    return false;
}


jQuery( function($) {     
  $("form.woocommerce-checkout")
  .on('submit', function() { return gatewayFunction( this ); } ); 

  $('a.showcouponcart').click(function(ev) { // Pass in the event object to your function
    // do stuff
    ev.preventDefault();
	$(".checkout_coupon").slideToggle(400);
    return false;
	
});


} );

jQuery(document).ready(function($) {
 




	if($("body.single-product").length && $(window).width() > 1023)
	{
		// Get the parent of the sticky section.
		var parent = $('.qodef-single-product-content');
		var parentTop = parent.offset().top;

		// Get the sticky section.
		var sticky = $(".wpgs");
		var stickyWidth = sticky.outerWidth();

		// Set the max width of the sticky section.
		sticky.css("max-width", stickyWidth + "px");

		$(window).scroll(function() {
			var parentHeight = parent.height();
			var parentBottom = parentTop + parentHeight;
			var stickyHeight = sticky.height();

			// Get the window properties.
			var windowTop = $(window).scrollTop();
			var windowBottom = $(window).scrollTop() + $(window).height();

			if(windowTop > 0 && windowTop + stickyHeight + parentTop < parentBottom && !sticky.hasClass("is-fixed"))
			{
				sticky.addClass("is-fixed").removeClass("is-relative").css("position", 'fixed').css("top", "unset");
			} else if(windowTop + stickyHeight + parentTop >= parentBottom && !sticky.hasClass("is-relative")) {
		    	sticky.removeClass("is-fixed").addClass("is-relative").css('position', 'relative').css("top", parentHeight - stickyHeight);
			}
			// else {
			// 	sticky.removeClass("is-fixed").removeClass("is-relative").css("top", "unset");
			// 	console.log("3");
			// }
		});
	}
});