PageSourceSearch

https://www.calulu-dogwear.jp/html/plugin/Exp/assets/js/productList.js

js calulu-dogwear.jp collected 2026-10-02 14:32:51 UTC 8,840 bytes, 207 lines download raw bytes

1/*
2 * This file is part of EC-CUBE
3 *
4 * Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
5 *
6 * http://www.ec-cube.co.jp/
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10*/
11
12(function(window, undefined) {
13
14    // 名前空間の重複を防ぐ
15    if (window.eccube === undefined) {
16        window.eccube = {};
17    }
18
19    let eccube = window.eccube;
20
21    // グローバルに使用できるようにする
22    window.eccube = eccube;
23
24    /**
25     * 規格2のプルダウンを設定する.
26     */
27    eccube.setClassCategories = function($form, product_id, $sele1, $sele2, selected_id2) {
28        if ($sele1 && $sele1.length) {
29            let classcat_id1 = $sele1.val() ? $sele1.val() : '';
30            if ($sele2 && $sele2.length) {
31                let classcat2;
32
33                if (eccube.hasOwnProperty('productsClassCategories')) {
34                    // 商品一覧時
35                    classcat2 = eccube.productsClassCategories[product_id][classcat_id1];
36                } else {
37                    // 詳細表示時
38                    classcat2 = eccube.classCategories[classcat_id1];
39                }
40                // 規格2の要素を設定
41                for (let key in classcat2) {
42                    if (classcat2.hasOwnProperty(key)) {
43                        let id = classcat2[key].classcategory_id2;
44                        let name = classcat2[key].name;
45                        let classCategoryCode = classcat2[key].code;
46                        let div = $('<div/>').addClass('form__radio').css('margin-left', '20px');
47                        let input = $('<input>').attr('type', 'radio').attr('name', 'classcategory_id2').attr('id', 'product_'+product_id+'_cat1_' + classcat_id1 + 'cat2_' + id).val(id ? id : '');
48                        let label = $('<label/>').attr('for', id).attr('for', 'product_'+product_id+'_cat1_' + classcat_id1 + 'cat2_' + id).html(classCategoryCode + ' ' + name);
49                        if (eccube.stockShow === "1" && eccube.stocks !== undefined) {
50                            let span = $('<span/>').html(eccube.stocks[product_id][$sele1.val()]['#' + id].stock);
51                            label.append(span);
52                        }
53                        if (eccube.stockShow === "1" && eccube.stocks !== undefined) {
54                            if (eccube.stocks[product_id][$sele1.val()]['#' + id].stockButton === 'disabled') {
55                                $(input).attr('disabled', 'disabled');
56                            }
57                        }
58                        div.append(input).append(label);
59                        $sele2.append(div);
60                    }
61                }
62                eccube.checkStock($form, product_id, $sele1.val() ? $sele1.val() : '__unselected2',
63                    $sele2.val() ? $sele2.val() : '');
64            }
65        }
66    };
67
68    /**
69     * 規格の選択状態に応じて, フィールドを設定する.
70     */
71    let price02_origin = [];
72    eccube.checkStock = function($form, product_id, classcat_id1, classcat_id2) {
73
74        classcat_id2 = classcat_id2 ? classcat_id2 : '';
75
76        let classcat2;
77
78        if (eccube.hasOwnProperty('productsClassCategories')) {
79            // 商品一覧時
80            classcat2 = eccube.productsClassCategories[product_id][classcat_id1]['#' + classcat_id2];
81        } else {
82            // 詳細表示時
83            if (typeof eccube.classCategories[classcat_id1] !== 'undefined') {
84                classcat2 = eccube.classCategories[classcat_id1]['#' + classcat_id2];
85            }
86        }
87
88        if (typeof classcat2 === 'undefined') {
89            // 商品コード
90            let $product_code = $('.product-code-default');
91            if (typeof this.product_code_origin === 'undefined') {
92                // 初期値を保持しておく
93                this.product_code_origin = $product_code.text();
94            }
95            $product_code.text(this.product_code_origin);
96
97            // 通常価格
98            let $price01 = $form.parent().find('.price01-default').first();
99            if (typeof this.price01_origin === 'undefined') {
100                // 初期値を保持しておく
101                this.price01_origin = $price01.text();
102            }
103            $price01.text(this.price01_origin);
104
105            // 販売価格
106            let $price02 = $form.parent().find('.price02-default').first();
107            if (typeof price02_origin[product_id] === 'undefined') {
108                // 初期値を保持しておく
109                price02_origin[product_id] = $price02.text();
110            }
111            $price02.text(price02_origin[product_id]);
112
113            // 商品規格
114            let $product_class_id_dynamic = $form.find('[id^=ProductClass]');
115            $product_class_id_dynamic.val('');
116
117        } else {
118            // 商品コード
119            let $product_code = $('.product-code-default');
120            if (classcat2 && typeof classcat2.product_code !== 'undefined') {
121                $product_code.text(classcat2.product_code);
122            } else {
123                $product_code.text(this.product_code_origin);
124            }
125
126            // 通常価格
127            let $price01 = $form.parent().find('.price01-default').first();
128            if (typeof this.price01_origin === 'undefined') {
129                // 初期値を保持しておく
130                this.price01_origin = $price01.text();
131            }
132            if (classcat2 && typeof classcat2.price01_inc_tax !== 'undefined' && String(classcat2.price01_inc_tax).length >= 1) {
133                $price01.text('ï¿¥' + classcat2.price01_inc_tax);
134            } else {
135                $price01.text(this.price01_origin);
136            }
137
138            // 販売価格
139            let $price02 = $form.parent().find('.price02-default').first();
140            if (typeof price02_origin[product_id] === 'undefined') {
141                // 初期値を保持しておく
142                price02_origin[product_id] = $price02.text();
143            }
144            if (classcat2 && typeof classcat2.price02_inc_tax !== 'undefined' && String(classcat2.price02_inc_tax).length >= 1) {
145                $price02.text('ï¿¥' + classcat2.price02_inc_tax);
146            } else {
147                $price02.text(price02_origin[product_id]);
148            }
149
150            // ポイント
151            let $point_default = $form.find('[id^=point_default]');
152            let $point_dynamic = $form.find('[id^=point_dynamic]');
153            if (classcat2 && typeof classcat2.point !== 'undefined' && String(classcat2.point).length >= 1) {
154
155                $point_dynamic.text(classcat2.point).show();
156                $point_default.hide();
157            } else {
158                $point_dynamic.hide();
159                $point_default.show();
160            }
161
162            // 商品規格
163            let $product_class_id_dynamic = $form.find('[id^=ProductClass]');
164            if (classcat2 && typeof classcat2.product_class_id !== 'undefined' && String(classcat2.product_class_id).length >= 1) {
165                $product_class_id_dynamic.val(classcat2.product_class_id);
166            } else {
167                $product_class_id_dynamic.val('');
168            }
169        }
170    };
171
172
173    /**
174     * Initialize.
175     */
176    $(function() {
177        // 規格1選択時
178        $('input[name=classcategory_id1]')
179            .change(function() {
180                let $form = $(this).parents('form');
181                let product_id = $form.find('input[name=product_id]').val();
182                let $sele1 = $(this);
183                let $sele2 = $form.find('div[id=classcategory_id1_' + $($sele1).val() + '_classcategory_id2]');
184                // 規格2の選択肢をクリア
185                let classcategory_id2_box = $form.find('.classcategory_id2_box');
186                for (let i = 0; i < classcategory_id2_box.length; i++) {
187                    $(classcategory_id2_box[i]).empty();
188                }
189                // 規格1のみの場合
190                if (!$sele2.length) {
191                    eccube.checkStock($form, product_id, $sele1.val(), null);
192                    // 規格2ありの場合
193                } else {
194                    eccube.setClassCategories($form, product_id, $sele1, $sele2);
195                }
196            });
197
198        // 規格2選択時
199        $('.ec-blockRadio').on('change', 'input[name=classcategory_id2]',function () {
200            let $form = $(this).parents('form');
201            let product_id = $form.find('input[name=product_id]').val();
202            let $sele1 = $form.find('input[name=classcategory_id1]:checked');
203            let $sele2 = $(this);
204            eccube.checkStock($form, product_id, $sele1.val(), $sele2.val());
205        })
206    });
207})(window);

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.