PageSourceSearch

https://www.kwbs.org.tw/shop/plugins/j2store/app_flexivariable/app_flexivariable/js/flexivariable.js

js kwbs.org.tw collected 2026-10-01 12:26:59 UTC 5,910 bytes, 143 lines download raw bytes

1/**
2 * Setup (required for Joomla! 3)
3 */
4if(typeof(j2store) == 'undefined') {
5    var j2store = {};
6}
7if(typeof(j2store.jQuery) == 'undefined') {
8    j2store.jQuery = jQuery.noConflict();
9}
10
11function doFlexiAjaxPrice(product_id, id) {
12    (function($) {
13        /* Get input values from form */
14        var form = $(id).closest('form');
15        //sanity check
16        if(form.data('product_id') != product_id) return;
17
18        var values = form.serializeArray();
19        //pop these params from values-> task : add & view : mycart
20        values.pop({
21            name : "task",
22            value : 'addItem'
23        });
24
25        values.pop({
26            name : "view",
27            value : 'carts'
28        });
29
30        values.push({
31            name : "product_id",
32            value :product_id
33        });
34
35        var arrayClean = function(thisArray) {
36            "use strict";
37            $.each(thisArray, function(index, item) {
38                if (item.name == 'task' || item.name == 'view') {
39                    delete values[index];
40                }
41            });
42        };
43        arrayClean(values);
44
45        values = values.filter(function( element ) {
46            return element !== undefined;
47        });
48        $( 'body' ).trigger( 'before_doAjaxPrice', [ form, values ] );
49        $('.j2error').remove();
50        $.ajax({
51            url : j2storeURL+ 'index.php?option=com_j2store&view=product&task=update',
52            type : 'get',
53            data : values,
54            dataType : 'json',
55            success : function(response) {
56
57                var $product = $('.product-'+ product_id);
58
59                if ($product.length
60                    && typeof response.error == 'undefined' ) {
61                    //SKU
62                    if (response.sku) {
63                        $product.find('.sku').html(response.sku);
64                    }
65
66                    if(response.pricing){
67                        //base price
68                        if (response.pricing.base_price) {
69                            $product.find('.base-price').html(response.pricing.base_price);
70                            if(response.pricing.class){
71                                if(response.pricing.class == 'show'){
72                                    $product.find('.base-price').show();
73                                    $product.find('.base-price').addClass('strike')
74                                }else{
75                                    $product.find('.base-price').hide()
76                                }
77                            }
78                        }
79                        //price
80                        if (response.pricing.price) {
81                            $product.find('.sale-price').html(response.pricing.price);
82                        }
83
84                        // discount text
85                        $product.find('.discount-percentage').html(response.pricing.discount_text);
86                    }
87
88                    //afterDisplayPrice
89                    if (response.afterDisplayPrice) {
90                        $product.find('.afterDisplayPrice').html(response.afterDisplayPrice);
91                    }
92                    //qty
93                    if (response.quantity) {
94                        $product.find('input[name="product_qty"]').val(response.quantity);
95                        if(form.data('product_type') == 'variable' || form.data('product_type') == 'advancedvariable' || form.data('product_type') == 'variablesubscriptionproduct') {
96                            $product.find('input[name="product_qty"]').attr({
97                                value: response.quantity
98                            });
99                        }
100                    }
101                    if(response.main_image){
102
103                        /*$product.find('.j2store-product-thumb-image-'+product_id).attr("src", response.main_image);
104                        j2store.jQuery('.j2store-product-thumb-image-'+product_id).attr("src", response.main_image);*/
105                        j2store.jQuery('.j2store-product-main-image-'+product_id).attr("src", response.main_image);
106                        $product.find('.j2store-mainimage .j2store-img-responsive').attr("src", response.main_image);
107                        $product.find('.j2store-product-additional-images .additional-mainimage').attr("src", response.main_image);
108                    }
109                    //stock status
110
111                    if (typeof response.stock_status != 'undefined') {
112                        if (response.availability == 1) {
113                            $product.find('.product-stock-container').html('<span class="instock">' + response.stock_status + '</span>');
114                        }else {
115                            $product.find('.product-stock-container').html('<span class="outofstock">' + response.stock_status + '</span>');
116                        }
117                    }
118
119                    //dimensions
120                    if (response.dimensions) {
121                        $product.find('.product-dimensions').html(response.dimensions);
122                    }
123
124                    //weight
125                    if (response.weight) {
126                        $product.find('.product-weight').html(response.weight);
127                    }
128
129
130                    // Trigger event
131                    $( 'body' ).trigger( 'after_doAjaxFilter', [ $product, response ] );
132                    $( 'body' ).trigger( 'after_doAjaxPrice', [ $product, response ] );
133                }else {
134                    $product.find('#variable-options-'+product_id).after('<div class="j2error">'+response.error+'</div>');
135                }
136            },
137            error : function(xhr, ajaxOptions, thrownError) {
138                console.log(thrownError + "\r\n" + xhr.statusText + "\r\n"
139                    + xhr.responseText);
140            }
141        });
142    })(j2store.jQuery);
143}

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.