jQuery(function ($) {
	unify_checkout_content();

	function unify_checkout_content() { 
	            var el = document.getElementById('unify_iframe'); 
	            if (el != null) { 
	                $('#unify_iframe').nextAll().remove()
	            } 
	        }

	jQuery('#buy_now_button').click(function(){
		var product_id = $(this).val();
		var product_qty = $("input[name=quantity]").val();
			  jQuery.ajax({
			        url: clearCart.ajaxurl,
			        type: 'post',
			        data: {
			            action: 'clearcart',
			            product_id: product_id,
			            product_qty: product_qty,
			            _wpnonce: clearCart.nonce,
			        },
			        success: function (data) {
			        	console.log(data);
			        },
			        error: function (data) {
			        	console.log("error");
			        },
			        complete: function (data) {
			        	console.log("completd");
			        }
			    });
              jQuery('#is_buy_now').val('1');
              jQuery('form.cart').submit();
          });
});

iFrameResize({ log: false, heightCalculationMethod : 'lowestElement' }, '#unify_iframe')