PageSourceSearch

https://michters.com/wp-content/plugins/woo-product-bundle-premium/assets/js/frontend.js?ver=8.5.9

js michters.com collected 2026-09-24 20:36:44 UTC 35,215 bytes, 936 lines download raw bytes

1'use strict';
2
3(function ($) {
4    var woosb_timeout = null;
5
6    $(function () {
7        if ($('.woosb-wrap').length) {
8            $('.woosb-wrap').each(function () {
9                woosb_init($(this), 'ready');
10            });
11        }
12    });
13
14    $(document).on('woosq_loaded', function () {
15        // product bundles in the quick view popup
16        woosb_init($('#woosq-popup .woosb-wrap'), 'woosq');
17    });
18
19    $(document).on('woovr_selected', function (e, selected, variations) {
20        var $wrap = variations.closest('.woosb-wrap');
21        var $product = variations.closest('.woosb-product');
22
23        if ($product.length) {
24            var _id = selected.attr('data-id');
25            var _price = selected.attr('data-price');
26            var _regular_price = selected.attr('data-regular-price');
27            var _price_html = selected.attr('data-pricehtml');
28            var _image_src = selected.attr('data-imagesrc');
29            var _purchasable = selected.attr('data-purchasable');
30            var _attrs = selected.attr('data-attrs');
31            var _availability = selected.attr('data-availability');
32
33            if (_purchasable === 'yes' && _id >= 0) {
34                // change data
35                $product.attr('data-id', _id);
36
37                if (woosb_vars.bundled_price_from === 'regular_price') {
38                    $product.attr('data-price', _regular_price);
39                } else {
40                    $product.attr('data-price', _price);
41                }
42
43                // change price
44                woosb_change_price($product, _price, _regular_price, _price_html);
45
46                // change attributes
47                $product.attr('data-attrs', _attrs.replace(/\/$/, ''));
48
49                // WPC Price by Quantity - update wpcpq data from woovr variation
50                var _wpcpq = selected.attr('data-wpcpq');
51
52                if (_wpcpq) {
53                    try {
54                        $product.data('wpcpq', JSON.parse(_wpcpq));
55                    } catch (ex) {
56                        $product.data('wpcpq', {});
57                    }
58                } else if (_id > 0) {
59                    // fallback: look up from variations form data
60                    var $form = $product.find('.variations_form, .woosb_variations_form');
61                    var variations_data = $form.data('product_variations');
62
63                    if (variations_data && Array.isArray(variations_data)) {
64                        for (var i = 0; i < variations_data.length; i++) {
65                            if (parseInt(variations_data[i].variation_id) === parseInt(_id)) {
66                                if (variations_data[i].woosb_wpcpq !== undefined) {
67                                    $product.data('wpcpq', variations_data[i].woosb_wpcpq);
68                                }
69
70                                break;
71                            }
72                        }
73                    }
74                }
75            } else {
76                // reset data
77                $product.attr('data-id', 0);
78                $product.attr('data-price', $product.data('o_price'));
79                $product.attr('data-attrs', '');
80
81                // reset price
82                $product.find('.woosb-price-ori').show();
83                $product.find('.woosb-price-new').html('').hide();
84
85                // WPC Price by Quantity - reset wpcpq data
86                $product.data('wpcpq', {});
87            }
88
89            // change image
90            if (_image_src && _image_src !== '') {
91                $product.find('.woosb-thumb-ori').hide();
92                $product.find('.woosb-thumb-new').html('<img src="' + _image_src + '"/>').show();
93            } else {
94                $product.find('.woosb-thumb-ori').show();
95                $product.find('.woosb-thumb-new').html('').hide();
96            }
97
98            // change availability
99            if (_availability && _availability !== '') {
100                $product.find('.woosb-availability').html(_availability).show();
101            } else {
102                $product.find('.woosb-availability').html('').hide();
103            }
104
105            // reset sku, weight & dimensions
106            if (typeof wc_reset_content === 'function') {
107                $('.product_meta .sku').wc_reset_content();
108                $('.product_weight, .woocommerce-product-attributes-item--weight .woocommerce-product-attributes-item__value').wc_reset_content();
109                $('.product_dimensions, .woocommerce-product-attributes-item--dimensions .woocommerce-product-attributes-item__value').wc_reset_content();
110            }
111        }
112
113        woosb_init($wrap, 'woovr_selected');
114    });
115
116    $(document).on('found_variation', function (e, t) {
117        var $wrap = $(e['target']).closest('.woosb-wrap');
118        var $product = $(e['target']).closest('.woosb-product');
119
120        if ($product.length) {
121            if (t['woosb_image'] !== undefined && t['woosb_image'] !== '') {
122                // change image
123                $product.find('.woosb-thumb-ori').hide();
124                $product.find('.woosb-thumb-new').html(t['woosb_image']).show();
125            } else {
126                $product.find('.woosb-thumb-ori').show();
127                $product.find('.woosb-thumb-new').html('').hide();
128            }
129
130            if (t['price_html'] !== undefined && t['price_html'] !== '' && t['display_price'] !== undefined && t['display_price'] !== '') {
131                woosb_change_price($product, t['display_price'], t['display_regular_price'], t['price_html']);
132            }
133
134            if (t['variation_description'] !== undefined) {
135                $product.find('.woosb-variation-description').html(t['variation_description']).show();
136            } else {
137                $product.find('.woosb-variation-description').html('').hide();
138            }
139
140            if (t['max_qty'] !== undefined && t['max_qty'] !== '') {
141                $product.attr('data-stock', t['max_qty']);
142            } else {
143                $product.attr('data-stock', -1);
144            }
145
146            if (t['is_purchasable']) {
147                // change the price
148                if (woosb_vars.bundled_price_from === 'regular_price' && t['display_regular_price'] !== undefined) {
149                    $product.attr('data-price', t['display_regular_price']);
150                } else {
151                    $product.attr('data-price', t['display_price']);
152                }
153
154                // change stock notice
155                if (t['is_in_stock']) {
156                    $wrap.next('p.stock').show();
157                    $product.attr('data-id', t['variation_id']);
158                } else {
159                    $wrap.next('p.stock').hide();
160                    $product.attr('data-id', 0);
161                }
162
163                // change availability
164                if (t['availability_html'] && t['availability_html'] !== '') {
165                    $product.find('.woosb-availability').html(t['availability_html']).show();
166                } else {
167                    $product.find('.woosb-availability').html('').hide();
168                }
169
170                // change attributes
171                var attrs = {};
172
173                $product.find('select[name^="attribute_"]').each(function () {
174                    var attr_name = $(this).attr('name');
175
176                    attrs[attr_name] = $(this).val();
177                });
178
179                $product.attr('data-attrs', JSON.stringify(attrs));
180
181                // WPC Price by Quantity - update wpcpq data from variation
182                if (t['woosb_wpcpq'] !== undefined) {
183                    $product.data('wpcpq', t['woosb_wpcpq']);
184                }
185            }
186
187            if (woosb_vars.change_image === 'no') {
188                // prevent changing the main image
189                $(e['target']).closest('.variations_form').trigger('reset_image');
190            }
191
192            // reset sku, weight & dimensions
193            if (typeof wc_reset_content === 'function') {
194                $('.product_meta .sku').wc_reset_content();
195                $('.product_weight, .woocommerce-product-attributes-item--weight .woocommerce-product-attributes-item__value').wc_reset_content();
196                $('.product_dimensions, .woocommerce-product-attributes-item--dimensions .woocommerce-product-attributes-item__value').wc_reset_content();
197            }
198
199            $(document).trigger('woosb_found_variation', [$product, t]);
200
201            woosb_init($wrap, 'found_variation');
202        }
203    });
204
205    $(document).on('reset_data', function (e) {
206        var $wrap = $(e['target']).closest('.woosb-wrap');
207        var $product = $(e['target']).closest('.woosb-product');
208
209        if ($product.length) {
210            // reset thumb
211            $product.find('.woosb-thumb-new').hide();
212            $product.find('.woosb-thumb-ori').show();
213
214            // reset price
215            $product.find('.woosb-price-new').hide();
216            $product.find('.woosb-price-ori').show();
217
218            // reset availability
219            $product.find('.woosb-availability').html('').hide();
220
221            // reset desc
222            $product.find('.woosb-variation-description').html('').hide();
223
224            // reset data
225            $product.attr('data-id', 0);
226            $product.attr('data-price', $product.data('o_price'));
227            $product.attr('data-attrs', '');
228            $product.attr('data-stock', -1);
229
230            // WPC Price by Quantity - reset wpcpq data
231            $product.data('wpcpq', {});
232
233            $(document).trigger('woosb_reset_data', [$product]);
234
235            woosb_init($wrap, 'reset_data');
236        }
237    });
238
239    $(document).on('click touch', '.woosb-quantity-input-plus, .woosb-quantity-input-minus', function () {
240        // get values
241        var $qty = $(this).closest('.woosb-quantity').find('.woosb-qty');
242
243        if (!$qty.length) {
244            $qty = $(this).closest('.woosb-quantity').find('.qty');
245        }
246
247        var val = parseFloat($qty.val()), max = parseFloat($qty.attr('max')), min = parseFloat($qty.attr('min')),
248            step = $qty.attr('step');
249
250        // format values
251        if (!val || val === '' || val === 'NaN') {
252            val = 0;
253        }
254
255        if (max === '' || max === 'NaN') {
256            max = '';
257        }
258
259        if (min === '' || min === 'NaN') {
260            min = 0;
261        }
262
263        if (step === 'any' || step === '' || step === undefined || step === 'NaN') {
264            step = 1;
265        } else {
266            step = parseFloat(step);
267        }
268
269        // change the value
270        if ($(this).is('.woosb-quantity-input-plus')) {
271            if (max && (val >= max)) {
272                $qty.val(max);
273            } else {
274                $qty.val((val + step).toFixed(woosb_decimal_places(step)));
275            }
276        } else {
277            if (min && (val <= min)) {
278                $qty.val(min);
279            } else if (val > 0) {
280                $qty.val((val - step).toFixed(woosb_decimal_places(step)));
281            }
282        }
283
284        // trigger change event
285        $qty.trigger('change');
286    });
287
288    $(document).on('click touch', '.single_add_to_cart_button', function (e) {
289        var $this = $(this);
290
291        if ($this.hasClass('woosb-disabled')) {
292            e.preventDefault();
293        }
294    });
295
296    if ($('.woosb-qty').length) {
297        $(document).on('change', '.woosb-qty', function () {
298            var $this = $(this);
299
300            woosb_check_qty($this);
301        });
302
303        $(document).on('keyup', '.woosb-qty', function () {
304            var $this = $(this);
305
306            if (woosb_timeout != null) clearTimeout(woosb_timeout);
307            woosb_timeout = setTimeout(woosb_check_qty, 1000, $this);
308        });
309    } else {
310        $(document).on('change', '.woosb-quantity .qty', function () {
311            var $this = $(this);
312
313            woosb_check_qty($this);
314        });
315
316        $(document).on('keyup', '.woosb-quantity .qty', function () {
317            var $this = $(this);
318
319            if (woosb_timeout != null) clearTimeout(woosb_timeout);
320            woosb_timeout = setTimeout(woosb_check_qty, 1000, $this);
321        });
322    }
323})(jQuery);
324
325function woosb_init($wrap, context = null) {
326    woosb_check_ready($wrap, context);
327    woosb_check_stock($wrap, context);
328    woosb_save_ids($wrap, context);
329
330    jQuery(document).trigger('woosb_init', [$wrap, context]);
331}
332
333function woosb_check_ready($wrap, context = null) {
334    var qty = 0;
335    var total = 0;
336    var total_sale = 0;
337    var is_selection = false;
338    var selection_name = '';
339    var is_unpurchasable = false;
340    var unpurchasable_name = '';
341    var is_empty = true;
342    var is_min = false;
343    var is_max = false;
344    var is_total_min = false;
345    var is_total_max = false;
346    var wid = $wrap.attr('data-id');
347    var $products = $wrap.find('.woosb-products');
348    var $alert = $wrap.find('.woosb-alert');
349    var $ids = jQuery('.woosb-ids-' + wid);
350    var $btn = $ids.closest('form.cart').find('.single_add_to_cart_button');
351    var price_suffix = $products.attr('data-price-suffix');
352    var $total = $wrap.find('.woosb-total');
353    var $count = $wrap.find('.woosb-count');
354    var $price = jQuery('.woosb-price-' + wid);
355    var $woobt = jQuery('.woobt-wrap-' + wid);
356    var $woobt_products = $woobt.find('.woobt-products');
357    var woobt_total = parseFloat($woobt_products.length ? $woobt.attr('data-total') : 0);
358    var discount = parseFloat($products.attr('data-discount'));
359    var discount_amount = parseFloat($products.attr('data-discount-amount'));
360    var fixed_price = $products.attr('data-fixed-price') === 'yes';
361    var has_optional = $products.attr('data-optional') === 'yes';
362    var has_variables = $products.attr('data-variables') === 'yes';
363    var exclude_unpurchasable = $products.attr('data-exclude-unpurchasable') === 'yes';
364    var saved = '';
365    var is_discount = discount > 0 && discount < 100;
366    var is_discount_amount = discount_amount > 0;
367    var qty_min = parseFloat($products.attr('data-min'));
368    var qty_max = parseFloat($products.attr('data-max'));
369    var total_min = parseFloat($products.attr('data-total-min'));
370    var total_max = parseFloat($products.attr('data-total-max'));
371
372    if (!$products.length || (!has_variables && !has_optional && !woosb_vars.recalc_price)) {
373        // don't need to do anything - already calculated in PHP
374        return;
375    }
376
377    // calculate price
378
379    if (!fixed_price) {
380        $products.find('.woosb-product').each(function () {
381            var $this = jQuery(this);
382
383            if ($this.hasClass('woosb-product-unpurchasable') && exclude_unpurchasable) {
384                // don't count this product
385                return;
386            }
387
388            if (parseFloat($this.attr('data-price')) > 0) {
389                var _qty = parseFloat($this.attr('data-qty'));
390                var _price = parseFloat($this.attr('data-price'));
391                var _regular_price = _price;
392
393                // WPC Price by Quantity compatibility
394                var wpcpq = $this.data('wpcpq');
395
396                if (wpcpq && (wpcpq.tiers !== undefined) && wpcpq.tiers.length && (_qty > 0)) {
397                    var wpcpq_method = wpcpq.method || 'volume';
398                    var wpcpq_price = woosb_wpcpq_get_price(wpcpq_method, wpcpq.tiers, _qty, _price);
399
400                    if (wpcpq_price !== _price) {
401                        _price = wpcpq_price;
402
403                        // update product item price display with bundle discount
404                        var _display_price = _price;
405                        var _item_price_suffix = $this.attr('data-price-suffix') || '';
406
407                        if (!is_discount_amount && is_discount) {
408                            _display_price = woosb_round(_price * (100 - discount) / 100);
409                        }
410
411                        if (woosb_vars.bundled_price === 'subtotal' || woosb_vars.bundled_price === 'subtotal_under_name') {
412                            var price_html = woosb_price_html(_regular_price * _qty, _display_price * _qty) + _item_price_suffix;
413                        } else {
414                            var price_html = woosb_price_html(_regular_price, _display_price) + _item_price_suffix;
415                        }
416
417                        $this.find('.woosb-price-ori').hide();
418                        $this.find('.woosb-price-new').html(price_html).show();
419                    }
420                }
421
422                total += _price * _qty;
423
424                if (!is_discount_amount && is_discount && woosb_vars.roun
424d_price) {
425                    _price = woosb_round(_price * (100 - discount) / 100);
426                }
427
428                total_sale += _price * _qty;
429            }
430        });
431
432        if (is_discount_amount && discount_amount < total) {
433            total_sale = total - discount_amount;
434            saved = woosb_format_price(discount_amount);
435        } else if (is_discount) {
436            if (!woosb_vars.round_price) {
437                total_sale = woosb_round(total * (100 - discount) / 100);
438            }
439
440            saved = woosb_round(discount, 2) + '%';
441        } else {
442            total_sale = total;
443        }
444
445        var total_html = woosb_price_html(total, total_sale);
446        var total_all_html = woosb_price_html(total + woobt_total, total_sale + woobt_total);
447
448        if (saved !== '') {
449            total_html += ' <small class="woocommerce-price-suffix">' + woosb_vars.saved_text.replace('[d]', saved) + '</small>';
450        }
451
452        // change the bundle total
453        $total.html('<span class="woosb-total-label">' + woosb_vars.price_text + '</span> <span class="woosb-total-value">' + total_html + price_suffix + '</span>').slideDown();
454        jQuery(document).trigger('woosb_change_total', [$total, total_html, price_suffix]);
455
456        if (woosb_vars.change_price !== 'no') {
457            // change the main price
458
459            if (woosb_vars.change_price === 'yes_custom' && woosb_vars.price_selector != null && woosb_vars.price_selector !== '') {
460                $price = jQuery(woosb_vars.price_selector);
461            }
462
463            if ($woobt_products.length) {
464                // woobt
465                $price.html(total_all_html + price_suffix);
466            } else {
467                if (typeof $price.attr('data-o_price') === 'undefined') {
468                    $price.attr('data-o_price', woosb_encode_entities($price.html()));
469                }
470
471                $price.html(total_html + price_suffix);
472            }
473        }
474
475        if ($woobt_products.length) {
476            // woobt
477            $woobt_products.attr('data-product-price-html', total_html);
478            $woobt_products.find('.woobt-product-this').attr('data-price', total_sale).attr('data-regular-price', total);
479
480            woobt_init($woobt);
481        }
482
483        jQuery(document).trigger('woosb_calc_price', [total_sale, total, total_html, price_suffix, $wrap]);
484    }
485
486    // check ready
487
488    $products.find('.woosb-product').each(function () {
489        var $this = jQuery(this);
490
491        if (parseFloat($this.attr('data-qty')) > 0) {
492            is_empty = false;
493            qty += parseFloat($this.attr('data-qty'));
494
495            if (parseInt($this.attr('data-id')) === 0) {
496                is_selection = true;
497
498                if (selection_name === '') {
499                    selection_name = $this.attr('data-name');
500                }
501            }
502
503            if ($this.hasClass('woosb-product-optional') && $this.hasClass('woosb-product-unpurchasable')) {
504                is_unpurchasable = true;
505
506                if (unpurchasable_name === '') {
507                    unpurchasable_name = $this.attr('data-name');
508                }
509            }
510        }
511    });
512
513    if (has_optional) {
514        // check min
515        if (qty_min > 0 && qty < qty_min) {
516            is_min = true;
517        }
518
519        // check max
520        if (qty_max > 0 && qty > qty_max) {
521            is_max = true;
522        }
523
524        $count.html('<span class="woosb-count-label">' + woosb_vars.selected_text + '</span> <span class="woosb-count-value">' + qty + '</span>').slideDown();
525        jQuery(document).trigger('woosb_change_count', [$count, qty, qty_min, qty_max]);
526    }
527
528    if (!fixed_price) {
529        // check total min
530        if (total_min > 0 && total_sale < total_min) {
531            is_total_min = true;
532        }
533
534        // check total max
535        if (total_max > 0 && total_sale > total_max) {
536            is_total_max = true;
537        }
538    }
539
540    if (is_selection || is_unpurchasable || is_empty || is_min || is_max || is_total_min || is_total_max) {
541        $btn.addClass('woosb-disabled');
542
543        if (is_selection) {
544            $alert.html(woosb_vars.alert_selection.replace('[name]', '<strong>' + selection_name + '</strong>')).slideDown();
545        } else if (is_unpurchasable) {
546            $alert.html(woosb_vars.alert_unpurchasable.replace('[name]', '<strong>' + unpurchasable_name + '</strong>')).slideDown();
547        } else if (is_empty) {
548            $alert.html(woosb_vars.alert_empty).slideDown();
549        } else if (is_min) {
550            $alert.html(woosb_vars.alert_min.replace('[min]', qty_min).replace('[selected]', qty)).slideDown();
551        } else if (is_max) {
552            $alert.html(woosb_vars.alert_max.replace('[max]', qty_max).replace('[selected]', qty)).slideDown();
553        } else if (is_total_min) {
554            $alert.html(woosb_vars.alert_total_min.replace('[min]', woosb_format_price(total_min)).replace('[total]', wo
554osb_format_price(total_sale))).slideDown();
555        } else if (is_total_max) {
556            $alert.html(woosb_vars.alert_total_max.replace('[max]', woosb_format_price(total_max)).replace('[total]', woosb_format_price(total_sale))).slideDown();
557        }
558
559        jQuery(document).trigger('woosb_check_ready', [false, is_selection, is_unpurchasable, is_empty, is_min, is_max, is_total_min, is_total_max, $wrap]);
560    } else {
561        $alert.html('').slideUp();
562        $btn.removeClass('woosb-disabled');
563
564        // ready
565        jQuery(document).trigger('woosb_check_ready', [true, is_selection, is_unpurchasable, is_empty, is_min, is_max, is_total_min, is_total_max, $wrap]);
566    }
567}
568
569function woosb_check_stock($wrap, context = null) {
570    var wid = $wrap.attr('data-id');
571    var $ids = jQuery('.woosb-ids-' + wid);
572    var $products = $wrap.find('.woosb-products');
573    var $qty = $ids.closest('form.cart').find('[name="quantity"]');
574    var stock_arr = Array();
575    var stock_min = 0;
576
577    $products.find('.woosb-product').each(function () {
578        var $this = jQuery(this);
579        var id = parseInt($this.attr('data-id'));
580        var qty = parseFloat($this.attr('data-qty'));
581        var stock = parseFloat($this.attr('data-stock'));
582
583        if (id > 0 && qty > 0 && (stock >= 0)) {
584            stock_arr.push(Math.floor(stock / qty));
585        }
586    });
587
588    stock_min = Math.min.apply(null, stock_arr);
589    stock_min = isNaN(stock_min) ? 0 : stock_min;
590
591    $qty.attr('max', stock_min);
592
593    if ($qty.val() > stock_min) {
594        $qty.val(stock_min).trigger('change');
595    }
596
597    jQuery(document).trigger('woosb_check_stock', [$wrap, context]);
598}
599
600function woosb_save_ids($wrap, context = null) {
601    var ids = Array();
602    var wid = $wrap.attr('data-id');
603    var $ids = jQuery('.woosb-ids-' + wid);
604    var $products = $wrap.find('.woosb-products');
605
606    $products.find('.woosb-product').each(function () {
607        var $this = jQuery(this);
608        var id = parseInt($this.attr('data-id'));
609        var key = $this.attr('data-key');
610        var qty = parseFloat($this.attr('data-qty'));
611        var attrs = $this.attr('data-attrs');
612
613        if (id > 0 && qty > 0) {
614            if (attrs !== undefined) {
615                attrs = encodeURIComponent(attrs);
616            } else {
617                attrs = '';
618            }
619
620            ids.push(id + '/' + key + '/' + qty + '/' + attrs);
621        }
622    });
623
624    $ids.val(ids.join(','));
625
626    jQuery(document).trigger('woosb_save_ids', [ids, $wrap]);
627}
628
629function woosb_check_qty($qty) {
630    var $wrap = $qty.closest('.woosb-wrap');
631    var qty = parseFloat($qty.val());
632    var min = parseFloat($qty.attr('min'));
633    var max = parseFloat($qty.attr('max'));
634
635    if (qty === '' || isNaN(qty)) {
636        qty = 0;
637    }
638
639    if (!isNaN(min) && qty < min) {
640        qty = min;
641    }
642
643    if (!isNaN(max) && qty > max) {
644        qty = max;
645    }
646
647    $qty.val(qty);
648    $qty.closest('.woosb-product').attr('data-qty', qty);
649
650    // change subtotal
651    if (woosb_vars.bundled_price === 'subtotal' || woosb_vars.bundled_price === 'subtotal_under_name') {
652        var $products = $wrap.find('.woosb-products');
653        var $product = $qty.closest('.woosb-product');
654        var price_suffix = $product.attr('data-price-suffix');
655        var ori_price = parseFloat($product.attr('data-price'));
656        var qty = parseFloat($product.attr('data-qty'));
657        var discount = parseFloat($products.attr('data-discount'));
658
659        // WPC Price by Quantity compatibility
660        var wpcpq = $product.data('wpcpq');
661
662        if (wpcpq && (wpcpq.tiers !== undefined) && wpcpq.tiers.length && (qty > 0)) {
663            var wpcpq_method = wpcpq.method || 'volume';
664            var wpcpq_price = woosb_wpcpq_get_price(wpcpq_method, wpcpq.tiers, qty, ori_price);
665
666            if (wpcpq_price !== ori_price) {
667                ori_price = wpcpq_price;
668            }
669        }
670
671        $product.find('.woosb-price-ori').hide();
672
673        if (discount > 0 && $products.attr('data-fixed-price') === 'no') {
674            var new_price = woosb_round(ori_price * (100 - discount) / 100);
675
676            $product.find('.woosb-price-new').html(woosb_price_html(ori_price * qty, new_price * qty) + price_suffix
676).show();
677        } else {
678            $product.find('.woosb-price-new').html(woosb_price_html(ori_price * qty) + price_suffix).show();
679        }
680    }
681
682    jQuery(document).trigger('woosb_check_qty', [qty, $qty]);
683
684    woosb_init($wrap, 'woosb_check_qty');
685}
686
687function woosb_change_price($product, price, regular_price, price_html) {
688    var $products = $product.closest('.woosb-products');
689    var price_suffix = $product.attr('data-price-suffix');
690    var qty = parseFloat($product.attr('data-qty'));
691    var discount = parseFloat($products.attr('data-discount'));
692    var new_price_html = '';
693
694    // hide ori price
695    $product.find('.woosb-price-ori').hide();
696
697    // calculate new price
698    if (woosb_vars.bundled_price === 'subtotal' || woosb_vars.bundled_price === 'subtotal_under_name') {
699        var ori_price = parseFloat(price);
700
701        if (woosb_vars.bundled_price_from === 'regular_price' && regular_price !== undefined) {
702            ori_price = parseFloat(regular_price);
703        }
704
705        var new_price = ori_price;
706
707        if (discount > 0) {
708            new_price = woosb_round(ori_price * (100 - discount) / 100);
709        }
710
711        new_price_html = woosb_price_html(ori_price * qty, new_price * qty) + price_suffix;
712    } else {
713        if (discount > 0) {
714            var ori_price = parseFloat(price);
715
716            if (woosb_vars.bundled_price_from === 'regular_price' && regular_price !== undefined) {
717                ori_price = parseFloat(regular_price);
718            }
719
720            var new_price = woosb_round(ori_price * (100 - discount) / 100);
721
722            new_price_html = woosb_price_html(ori_price, new_price) + price_suffix;
723        } else {
724            if (woosb_vars.bundled_price_from === 'regular_price' && regular_price !== undefined) {
725                new_price_html = woosb_price_html(regular_price) + price_suffix;
726            } else if (price_html !== '') {
727                new_price_html = price_html;
728            }
729        }
730    }
731
732    $product.find('.woosb-price-new').html(new_price_html).show();
733    jQuery(document).trigger('woosb_change_price', [$product, new_price_html]);
734}
735
736function woosb_round(value, decimals = -1) {
737    if (decimals < 0) {
738        decimals = woosb_vars.price_decimals;
739    }
740
741    return Number(Math.round(value + 'e' + decimals) + 'e-' + decimals);
742}
743
744function woosb_format_money(number, places, symbol, thousand, decimal) {
745    number = number || 0;
746    places = !isNaN(places = Math.abs(places)) ? places : 2;
747    symbol = symbol !== undefined ? symbol : '$';
748    thousand = thousand !== undefined ? thousand : ',';
749    decimal = decimal !== undefined ? decimal : '.';
750
751    var negative = number < 0 ? '-' : '', i = parseInt(number = Math.abs(+number || 0).toFixed(places), 10) + '', j = 0;
752
753    if (i.length > 3) {
754        j = i.length % 3;
755    }
756
757    if (woosb_vars.trim_zeros === '1') {
758        return symbol + negative + (j ? i.substr(0, j) + thousand : '') + i.substr(j).replace(/(\d{3})(?=\d)/g, '$1' + thousand) + (places && (parseFloat(number) > parseFloat(i)) ? decimal + Math.abs(number - i).toFixed(places).slice(2).replace(/(\d*?[1-9])0+$/g, '$1') : '');
759    } else {
760        return symbol + negative + (j ? i.substr(0, j) + thousand : '') + i.substr(j).replace(/(\d{3})(?=\d)/g, '$1' + thousand) + (places ? decimal + Math.abs(number - i).toFixed(places).slice(2) : '');
761    }
762}
763
764function woosb_format_price(price) {
765    var price_html = '<span class="woocommerce-Price-amount amount">';
766    var price_formatted = woosb_format_money(price, woosb_vars.wc_price_decimals, '', woosb_vars.wc_price_thousand_separator, woosb_vars.wc_price_decimal_separator);
767
768    switch (woosb_vars.wc_price_format) {
769        case '%1$s%2$s':
770            //left
771            price_html += '<span class="woocommerce-Price-currencySymbol">' + woosb_vars.wc_currency_symbol + '</span>' + price_formatted;
772            break;
773        case '%1$s %2$s':
774            //left with space
775            price_html += '<span class="woocommerce-Price-currencySymbol">' + woosb_vars.wc_currency_symbol + '</span> ' + price_formatted;
776            break;
777        case '%2$s%1$s':
778            //right
779            price_html += price_formatted + '<span class="woocommerce-Price-currencySymbol">' + woosb_vars.wc_currency_symbol + '</span>';
780            break;
781        case '%2$s %1$s':
782            //right with space
783            price_html += price_formatted + ' <span class="woocommerce-Price-currencySymbol">' + woosb_vars.wc_currency_symbol + '</span>';
784            break;
785        default:
786            //default
787            price_html += '<span class="woocommerce-Price-currencySymbol">' + woosb_vars.wc_currency_symbol + '</span> ' + price_formatted;
788    }
789
790    price_html += '</span>';
791
792    return price_html;
793}
794
795function woosb_price_html(regular_price, sale_price) {
796    var price_html = '';
797
798    if (woosb_round(sale_price) < woosb_round(regular_price)) {
799        price_html = '<del>' + woosb_format_price(regular_price) + '</del> <ins>' + woosb_format_price(sale_price) + '</ins>';
800    } else {
801        price_html = woosb_format_price(regular_price);
802    }
803
804    return price_html;
805}
806
807function woosb_decimal_places(num) {
808    var match = ('' + num).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);
809
810    if (!match) {
811        return 0;
812    }
813
814    return Math.max(0, // Number of digits right of decimal point.
815        (match[1] ? match[1].length : 0) - // Adjust for scientific notation.
816        (match[2] ? +match[2] : 0));
817}
818
819function woosb_encode_entities(str) {
820    return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
821}
822
823function woosb_decode_entities(str) {
824    var textArea = document.createElement('textarea');
825    textArea.innerHTML = str;
826    return textArea.value;
827}
828
829/**
830 * WPC Price by Quantity - calculate price from tier value.
831 * Supports: percentage (e.g. "90%"), fixed (e.g. "10"), decrease (e.g. "-5"), increase (e.g. "+5").
832 */
833function woosb_wpcpq_calculate_price(price, current_price) {
834    if (price === '' || price === '100%') {
835        return current_price;
836    }
837
838    var price_str = String(price);
839
840    if (price_str.charAt(0) === '-') {
841        // decrease
842        return current_price - parseFloat(price_str.replace('-', ''));
843    }
844
845    if (price_str.charAt(0) === '+') {
846        // increase
847        return current_price + parseFloat(price_str.replace('+', ''));
848    }
849
850    if (price_str.charAt(price_str.length - 1) === '%') {
851        // percentage
852        return current_price * parseFloat(price_str.replace('%', '')) / 100;
853    }
854
855    return parseFloat(price);
856}
857
858/**
859 * WPC Price by Quantity - get price based on method and tiers.
860 * Supports: volume (default), tiered, tiered_block.
861 */
862function woosb_wpcpq_get_price(method, tiers, quantity, old_price) {
863    quantity = parseFloat(quantity);
864    var step = 1;
865
866    if (!tiers || !tiers.length) {
867        return old_price;
868    }
869
870    if (method === 'tiered') {
871        var total = 0;
872
873        // tiers should be sorted ascending by quantity
874        var sorted_tiers = tiers.slice().sort(function (a, b) {
875            return parseFloat(a.quantity) - parseFloat(b.quantity);
876        });
877
878        for (var i = 0; i < sorted_tiers.length; i++) {
879            var tier = sorted_tiers[i];
880            var tier_price = (tier.price === '' || tier.price === undefined) ? '100%' : tier.price;
881            var tier_qty = parseFloat(tier.quantity);
882            var prev_price = (i > 0) ? sorted_tiers[i - 1].price : old_price;
883            var prev_qty = (i > 0) ? parseFloat(sorted_tiers[i - 1].quantity) : 1;
884
885            if (prev_price === '' || prev_price === undefined) {
886                prev_price = '100%';
887            }
888
889            if (quantity >= tier_qty) {
890                total += (tier_qty - prev_qty) * woosb_wpcpq_calculate_price(prev_price, old_price);
891
892                if (i === sorted_tiers.length - 1) {
893                    // last tier
894                    total += (quantity - tier_qty + step) * woosb_wpcpq_calculate_price(tier_price, old_price);
895                    break;
896                }
897            } else {
898                total += (quantity - prev_qty + step) * woosb_wpcpq_calculate_price(prev_price, old_price);
899                break;
900            }
901        }
902
903        return total / quantity;
904    } else if (method === 'tiered_block') {
905        // tiered block only supports 1 tier
906        var total = old_price;
907
908        if (tiers[0] && typeof tiers[0] === 'object') {
909            var tier = tiers[0];
910            var tier_price = (tier.price === '' || tier.price === undefined) ? '100%' : tier.price;
911            var tier_qty = parseFloat(tier.quantity);
912
913            if (quantity >= tier_qty) {
914                total += (quantity - tier_qty + step) * woosb_wpcpq_calculate_price(tier_price, old_price);
915            }
916        }
917
918        return total / quantity;
919    } else {
920        // volume (default) - sort descending, find matching tier
921        var sorted_tiers = tiers.slice().sort(function (a, b) {
922            return parseFloat(b.quantity) - parseFloat(a.quantity);
923        });
924
925        for (var i = 0; i < sorted_tiers.length; i++) {
926            var tier = sorted_tiers[i];
927            var tier_price = (tier.price === '' || tier.price === undefined) ? '100%' : tier.price;
928
929            if (quantity >= parseFloat(tier.quantity)) {
930                return woosb_wpcpq_calculate_price(tier_price, old_price);
931            }
932        }
933    }
934
935    return old_price;
936}

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.