(function(t){t.extend({AdvanceWooDiscountRules:{form:null,product_id:null,quantity:0,options:[],target:null,getDynamicDiscountPriceFromCartForm:function(t,r,o){if(typeof o!=="undefined"){this.options=o}if(typeof r!=="undefined"){this.target=r}if(typeof t!=="undefined"&&t.is("form")){this.form=t}else{this.logError("Incorrect form provided")}this.product_id=this.getProductIdFromForm();this.quantity=this.getProductQuantityFromForm();this.getDiscountPriceForProduct()},getDiscountPriceForProduct:function(){if(this.product_id===null||this.product_id==0){this.logError("Invalid product");return[]}var r={action:"awdr_get_product_discount",product_id:this.product_id,qty:this.quantity,awdr_nonce:awdr_params.nonce};if(typeof this.options.custom_price!=="undefined"){r.custom_price=this.options.custom_price}var o=this.target;var i=this.options;t.ajax({url:awdr_params.ajaxurl,data:r,type:"POST",success:function(r){t(document.body).trigger("advanced_woo_discount_rules_on_get_response_for_dynamic_discount",[r,o,i])},error:function(t){}})},getProductIdFromForm:function(){var t=this.form.find('[name="variation_id"]');var r=this.form.find('[name="add-to-cart"]');if(t.length){return parseInt(t.val())}else if(r.length){return parseInt(r.val())}return false},getProductQuantityFromForm:function(){var t=this.form.find('input[name="quantity"]');if(t.length===0){return 0}return t.val()},logError:function(t){console.error("Advance discount rule error: %s",t)}}})})(jQuery);