PageSourceSearch

https://saabblog.net/wp-content/cache/wpfc-minified/9l691t7e/4helq.js

js saabblog.net collected 2026-09-25 00:35:43 UTC 13,262 bytes, 291 lines download raw bytes

1jQuery(function($){
2var subscription_plan_selector='input[name=subscription_plans]'
3var $tax_container=$('.pms-price-breakdown__holder')
4var $tax_price=$('.pms-price-breakdown .pms-subtotal__value')
5var $tax_tax=$('.pms-price-breakdown .pms-tax__value')
6var $tax_label=$('.pms-price-breakdown .pms-tax__label')
7var $tax_total=$('.pms-price-breakdown .pms-total__value')
8var tax_country_selector='.pms-billing-details #pms_billing_country'
9var tax_state_selector='.pms-billing-details #pms_billing_state'
10var tax_city_selector='.pms-billing-details #pms_billing_city'
11var tax_vat_selector='.pms-billing-details #pms_vat_number'
12var checkedVatNumber=''
13$(document).ready(function(){
14$(document).on('click', subscription_plan_selector, function(){
15pms_tax_price_breakdown()
16pms_tax_show_euvat_field_only_for_eu_countries()
17})
18$(document).on('change', '#pms_billing_country, #pms_billing_state, #pms_billing_city, .pms_pwyw_pricing', function(){
19pms_tax_price_breakdown()
20pms_tax_show_euvat_field_only_for_eu_countries()
21})
22$(document).on('keyup', '.pms_pwyw_pricing', function(){
23pms_tax_price_breakdown()
24pms_tax_show_euvat_field_only_for_eu_countries()
25})
26$(document).on('change', '#pms_billing_country', pms_tax_validate_vat)
27$(document).on('input', '#pms_vat_number', pms_tax_validate_vat)
28$(document).on('pms_discount_success', pms_tax_price_breakdown)
29$(document).on('pms_discount_error', pms_tax_price_breakdown)
30$(document).on('wppb_msf_next_step', pms_tax_price_breakdown)
31$(document).on('wppb_msf_previous_step', pms_tax_price_breakdown)
32$(document).on("wppbAddRequiredAttributeEvent", pms_tax_price_breakdown)
33pms_tax_price_breakdown()
34pms_tax_show_euvat_field_only_for_eu_countries()
35})
36function pms_tax_price_breakdown(){
37let $pms_checked_subscription=jQuery(subscription_plan_selector + '[type=radio]').length > 0 ? jQuery(subscription_plan_selector + '[type=radio]:checked'):jQuery(subscription_plan_selector + '[type=hidden]')
38if(!jQuery($pms_checked_subscription).is(':visible')&&$pms_checked_subscription.attr('type')!='hidden'){
39$tax_container.hide()
40return
41}
42var price;
43if($pms_checked_subscription.data('mc_pwyw')){
44var planID=$pms_checked_subscription.val()
45price=jQuery('input[name="subscription_price_' + planID + '"]').val()
46}else{
47var pms_mc_price=$pms_checked_subscription.data('mc_price')
48price=(typeof pms_mc_price!=='undefined'&&pms_mc_price!==null) ? pms_mc_price:$pms_checked_subscription.data('price')
49}
50if($.pms_plan_is_prorated()){
51if(typeof $pms_checked_subscription.data('original_price')!='undefined'&&$pms_checked_subscription.data('original_price') > 0){
52if($.pms_checkout_is_recurring()){
53if(typeof $pms_checked_subscription.data('discountedPriceValue')!='undefined'&&typeof $pms_checked_subscription.data('discountRecurringPayments')&&$pms_checked_subscription.data('discountRecurringPayments')==1)
54price=$pms_checked_subscription.data('discountedPriceValue')
55else
56price=$pms_checked_subscription.data('original_price')
57}}
58}
59if(pms_tax_apply_sign_up_fee()){
60var pms_mc_sign_up_fee=$pms_checked_subscription.data('mc_sign_up_fee')
61var sign_up_fee
62if(typeof pms_mc_sign_up_fee!=='undefined'&&pms_mc_sign_up_fee!==null)
63sign_up_fee=pms_mc_sign_up_fee
64else
65sign_up_fee=$pms_checked_subscription.data('sign_up_fee')
66if($pms_checked_subscription.data('trial')&&$pms_checked_subscription.data('trial')=='1')
67price=parseFloat(sign_up_fee)
68else
69price=parseFloat(price) + parseFloat(sign_up_fee)
70}
71if(!(price > 0)||(typeof $pms_checked_subscription.data('tax-exempt')!='undefined'&&$pms_checked_subscription.data('tax-exempt')==1) ){
72$tax_container.hide()
73jQuery('.pms-tax-notice').hide()
74jQuery(document).trigger('pms_tax_removed')
75return
76}
77var tax_country=$(tax_country_selector).val()
78var tax_state=$(tax_state_selector).val()
79var tax_city=$(tax_city_selector).val()
80if(!tax_country||tax_country.length===0){
81$tax_container.hide()
82jQuery('.pms-tax-notice').hide()
83jQuery(document).trigger('pms_tax_removed')
84return
85}
86var tax_rate=pms_tax_get_rate(tax_country, tax_state, tax_city)
87if(tax_rate&&(tax_rate.tax_rate > 0||(PMSTaxOptions.zero_rate_enabled=='true'&&parseFloat(tax_rate.tax_rate)===0) )){
88var valid_vat=pms_tax_is_vat_number_valid()
89if(PMSTaxOptions.prices_include_tax=='true'){
90if(valid_vat&&PMSTaxOptions.euvat_merchant_country!=tax_country){
91var tax=0
92var actual_tax=price -(price /(tax_rate.tax_rate / 100 + 1) )
93var subtotal=price - actual_tax
94var total=price - actual_tax
95}else{
96var tax=price -(price /(tax_rate.tax_rate / 100 + 1) )
97var subtotal=price - tax
98var total=price
99}}else{
100if(valid_vat&&PMSTaxOptions.euvat_merchant_country!=tax_country){
101var subtotal=price
102var tax=0
103var total=price
104}else{
105var subtotal=price
106var tax=subtotal *(tax_rate.tax_rate / 100)
107var total=subtotal *(1 + tax_rate.tax_rate / 100)
108}}
109$tax_price.text(pms_tax_format_number(subtotal) )
110if(valid_vat&&PMSTaxOptions.euvat_merchant_country!=tax_country)
111$tax_label.text(tax_rate.tax_name + ':')
112else
113$tax_label.text(tax_rate.tax_rate + '% ' + tax_rate.tax_name + ':')
114$tax_tax.text(pms_tax_format_number(tax) )
115$tax_total.text(pms_tax_format_number(total) )
116$tax_container.show()
117let data={
118price:subtotal,
119tax:tax,
120total:total,
121tax_country: tax_country,
122tax_state:tax_state,
123tax_city:tax_city,
124tax_rate:tax_rate,
125valid_vat:valid_vat,
126}
127jQuery(document).trigger('pms_tax_applied', data)
128}else{
129$tax_container.hide()
130jQuery('.pms-tax-notice').hide()
131jQuery(document).trigger('pms_tax_removed')
132}}
133function pms_tax_get_rate(country, state='*', city='*'){
134if(!PMSTaxOptions)
135return false
136if(!country||country.length===0)
137return { tax_name:PMSTaxOptions.default_tax_name, tax_rate:PMSTaxOptions.default_tax_rate }
138if(!state||state.length===0)
139state='*'
140else
141state=state.toUpperCase()
142if(!city||city.length===0)
143city='*'
144else
145city=city.toLowerCase()
146var found_rate=pms_tax_find_rate(country, state, city)
147if(!found_rate&&city!='*')
148found_rate=pms_tax_find_rate(country, state, '*')
149if(!found_rate&&state!='*')
150found_rate=pms_tax_find_rate(country, '*', '*')
151if(!found_rate&&PMSTaxOptions.euvat_enabled=='true'&&PMSTaxOptions.euvat_country_rates){
152if(PMSTaxOptions.euvat_country_rates[country])
153found_rate={ tax_name: PMSTaxOptions.euvat_tax_name, tax_rate:PMSTaxOptions.euvat_country_rates[country].rate }}
154if(!found_rate&&(PMSTaxOptions.default_tax_rate!='0'||PMSTaxOptions.zero_rate_enabled=='true') )
155found_rate={ tax_name:PMSTaxOptions.default_tax_name, tax_rate:PMSTaxOptions.default_tax_rate }
156if(typeof jQuery!=='undefined'){
157let $pms_checked_subscription=jQuery(subscription_plan_selector + '[type=radio]').length > 0 ? jQuery(subscription_plan_selector + '[type=radio]:checked'):jQuery(subscription_plan_selector + '[type=hidden]')
158let subscription_plan_id=$pms_checked_subscription.val()
159jQuery(document).trigger('pms_tax_get_rate_filter', [found_rate, country, state, city, subscription_plan_id])
160let filtered_rate=jQuery(document).triggerHandler('pms_tax_get_rate_return_filter', [found_rate, country, state, city, subscription_plan_id])
161if(filtered_rate!==undefined&&filtered_rate!==null)
162found_rate=filtered_rate
163}
164return found_rate
165}
166function pms_tax_find_rate(country, state, city){
167var tax_rates=PMSTaxOptions.tax_rates
168if(!tax_rates||tax_rates.length===0)
169return false
170for(var i=0; i < tax_rates.length; i++){
171if(tax_rates[i].tax_country==country&&tax_rates[i].tax_state==state&&tax_rates[i].tax_city.toLowerCase()==city)
172return tax_rates[i]
173}
174return false
175}
176function pms_tax_format_number(value){
177var pms_mc_currency=$pms_checked_subscription.data('mc_currency')
178var pms_mc_currency_symbol=$pms_checked_subscription.data('mc_currency_symbol')
179var currency_code=(typeof pms_mc_currency!=='undefined'&&pms_mc_currency!==null) ? pms_mc_currency:PMSTaxOptions.currency
180var currency=(typeof pms_mc_currency_symbol!=='undefined'&&pms_mc_currency_symbol!==null) ? pms_mc_currency_symbol:PMSTaxOptions.currency_symbol;
181var decimals=pms_is_zero_decimal_currency(currency_code) ? 0:2
182if(!PMSTaxOptions.locale)
183return pms_tax_round_number(value, decimals)
184var option={
185maximumFractionDigits:decimals
186}
187if(PMSTaxOptions&&PMSTaxOptions.price_trim_zeroes=='false')
188option.minimumFractionDigits=decimals
189var formatter=new Intl.NumberFormat(PMSTaxOptions.locale, option)
190value=formatter.format(value)
191var separator=(PMSTaxOptions.currency_position=='before_with_space'||PMSTaxOptions.currency_position=='after_with_space') ? ' ':''
192if(PMSTaxOptions.currency_position=='before'||PMSTaxOptions.currency_position=='before_with_space')
193return currency + separator + value
194else
195return value + separator + currency
196}
197function pms_is_zero_decimal_currency(currency){
198if(!PMSTaxOptions||!PMSTaxOptions.zero_decimal_currencies)
199return false
200return PMSTaxOptions.zero_decimal_currencies.includes(String(currency).toUpperCase())
201}
202function pms_tax_round_number(value, precision){
203var multiplier=Math.pow(10, precision||0)
204return Math.round(value * multiplier) / multiplier
205}
206function pms_tax_is_vat_number_valid(){
207var validVat=jQuery('#pms_vat_number').data('vat-valid')
208if(typeof validVat!=='undefined'&&(validVat==true||validVat==1) )
209return true
210return false
211}
212function pms_tax_show_euvat_field_only_for_eu_countries(){
213if(jQuery('.pms-form').is('#pms-update-payment-method-form'))
214return
215var tax_country=$(tax_country_selector).val()
216if(PMSTaxOptions&&PMSTaxOptions.euvat_country_rates&&PMSTaxOptions.euvat_country_rates[tax_country]&&(PMSTaxOptions.euvat_country_rates[tax_country].rate > 0||PMSTaxOptions.zero_rate_enabled=='true') )
217jQuery('.pms-billing-details .pms-vat-number').show()
218else
219jQuery('.pms-billing-details .pms-vat-number').hide()
220}
221function pms_tax_validate_vat(vat_number){
222if(PMSTaxOptions&&PMSTaxOptions.euvat_enabled&&PMSTaxOptions.euvat_enabled!='true')
223return
224if(vat_number==checkedVatNumber)
225return
226$('.pms-vat-number .pms_field-success-wrapper').hide()
227$('.pms-vat-number .pms_field-errors-wrapper').remove()
228var tax_country=$(tax_country_selector).val(), default_length=8
229var vat_number=$(tax_vat_selector).val()
230checkedVatNumber=vat_number
231if(!(tax_country.length > 0))
232return
233if(PMSTaxOptions.euvat_numbers_minimum_char&&PMSTaxOptions.euvat_numbers_minimum_char[tax_country])
234default_length=PMSTaxOptions.euvat_numbers_minimum_char[tax_country]
235if(vat_number.indexOf(tax_country)==0)
236vat_number=vat_number.substring(tax_country.length)
237if(vat_number.length >=default_length){
238checkedVatNumber=vat_number
239var data={}
240data.action='pms_tax_validate_vat'
241data.pms_nonce=PMSTaxOptions.vat_validate_nonce
242data.vatNumber=vat_number
243data.vatCountry=tax_country
244$.post(PMSTaxOptions.ajax_url, data, function(response){
245if(!response)
246return
247response=JSON.parse(response)
248if(response.status){
249$('.pms-vat-number .pms_field-success-wrapper').hide()
250$('.pms-vat-number .pms_field-errors-wrapper').remove()
251if(response.status=='valid'){
252var message=PMSTaxOptions.euvat_number_valid_message
253if(PMSTaxOptions.euvat_merchant_country==tax_country)
254message=PMSTaxOptions.euvat_number_valid_message_same_country
255$('#pms_vat_number').data('vat-valid', true)
256if(!($('.pms-vat-number .pms_field-success-wrapper').length > 0) )
257$('#pms_vat_number').parent().after('<div class="pms_field-success-wrapper"><p>' + message + '</p></div>')
258else {
259$('.pms-vat-number .pms_field-success-wrapper').html('<p>' + message + '</p>')
260$('.pms-vat-number .pms_field-success-wrapper').show()
261}
262pms_tax_price_breakdown()
263}else if(response.status=='invalid'){
264$('#pms_vat_number').data('vat-valid', false)
265$.pms_add_field_error(PMSTaxOptions.euvat_number_invalid_message, 'pms_vat_number')
266pms_tax_price_breakdown()
267}}
268})
269}else{
270if(vat_number.length > 0)
271$.pms_add_field_error(PMSTaxOptions.euvat_number_short_message, 'pms_vat_number')
272$('#pms_vat_number').data('vat-valid', false)
273pms_tax_price_breakdown()
274}}
275function pms_tax_apply_sign_up_fee(){
276var locations=[ 'pms_register', 'pms_new_subscription', 'pms_confirm_retry_payment_subscription', 'register', 'pms_upgrade_subscription' ],
277checked_subscription=jQuery(subscription_plan_selector + '[type=radio]').length > 0 ? jQuery(subscription_plan_selector + '[type=radio]:checked'):jQuery(subscription_plan_selector + '[type=hidden]')
278if(locations.includes(jQuery('.pms-form .pms-form-submit').attr('name')) ||
279locations.includes(jQuery('.pms-form input[name="pms_new_subscription"]').attr('name')) ||
280locations.includes(jQuery('.wppb-user-forms .form-submit input[type="submit"]').attr('name')) ||
281locations.includes(jQuery('#pms-upgrade-subscription-form input[name="pms_upgrade_subscription"]').attr('name')) ){
282if(typeof checked_subscription.data('sign_up_fee')!='undefined'&&checked_subscription.data('sign_up_fee')!=0&&(!checked_subscription.data('discounted-price')||(checked_subscription.data('discounted-price')=='false'&&checked_subscription.data('sign_up_fee')!=0) ))
283return true
284}
285if(checked_subscription.closest('.pms-subscription-plan').parent().hasClass('pms-upgrade__group--change') ||
286checked_subscription.closest('.pms-subscription-plan').parent().hasClass('pms-upgrade__group--upgrade')){
287if(typeof checked_subscription.data('sign_up_fee')!='undefined'&&checked_subscription.data('sign_up_fee')!=0&&(!checked_subscription.data('discounted-price')||(checked_subscription.data('discounted-price')=='false'&&checked_subscription.data('sign_up_fee')!=0)))
288return true
289}
290return false
291}});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.