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