質問編集履歴
4
補足を追加しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -20,7 +20,7 @@
|
|
20
20
|
|
21
21
|
### 該当のソースコード
|
22
22
|
|
23
|
-
|
23
|
+
jsの基本構造をよくわかっていないと思いますので、訳のわからないことしていると思います...汗
|
24
24
|
|
25
25
|
```
|
26
26
|
|
3
補足を追加しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -44,6 +44,10 @@
|
|
44
44
|
|
45
45
|
|
46
46
|
|
47
|
+
/////SKU取得以降のコードは問題なく動いています。
|
48
|
+
|
49
|
+
products.jsonで取得できる商品数が最大250商品のため、2ページ目以降に表示される商品情報の取得をなんとかして成功させたいです。
|
50
|
+
|
47
51
|
```
|
48
52
|
|
49
53
|
<script>
|
@@ -59,6 +63,10 @@
|
|
59
63
|
}
|
60
64
|
|
61
65
|
}
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
/////SKU取得
|
62
70
|
|
63
71
|
var obj_this_page = this;
|
64
72
|
|
2
コードの全文を追加しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -37,3 +37,121 @@
|
|
37
37
|
}
|
38
38
|
|
39
39
|
```
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
###ソースコードの全文
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
```
|
48
|
+
|
49
|
+
<script>
|
50
|
+
|
51
|
+
var num = 1;
|
52
|
+
|
53
|
+
var collection = for (let step == null; step !== null; step++) {
|
54
|
+
|
55
|
+
if ( str.indexOf('{{ product.handle }}') != -1) {
|
56
|
+
|
57
|
+
var page = 'https://shopname.myshopify.com/collections/{{ collection.handle }}/products.json?limit=250?page='+(num++);
|
58
|
+
|
59
|
+
}
|
60
|
+
|
61
|
+
}
|
62
|
+
|
63
|
+
var obj_this_page = this;
|
64
|
+
|
65
|
+
var obj_all_products = {};
|
66
|
+
|
67
|
+
jQuery.getJSON(collection, function(all_products) {
|
68
|
+
|
69
|
+
console.log(all_products);
|
70
|
+
|
71
|
+
obj_all_products = all_products;
|
72
|
+
|
73
|
+
}).then(
|
74
|
+
|
75
|
+
function( all_products ){
|
76
|
+
|
77
|
+
Object.keys(all_products.products).forEach(function (key) {
|
78
|
+
|
79
|
+
product = all_products.products[key]
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
var product_handle = product.handle;
|
84
|
+
|
85
|
+
var current_handle = "{{ product.handle }}";
|
86
|
+
|
87
|
+
var current_handle_array = current_handle.split("-",2);
|
88
|
+
|
89
|
+
var current_handle_prefix = current_handle_array[0];
|
90
|
+
|
91
|
+
var product_style_switch = current_handle_array[1];
|
92
|
+
|
93
|
+
var switch_handle = current_handle_prefix + '-' + product_style_switch;
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
console.log( "product_handle : "+product_handle );
|
98
|
+
|
99
|
+
console.log( "current_handle : "+current_handle );
|
100
|
+
|
101
|
+
console.log( "current_handle_prefix : "+current_handle_prefix );
|
102
|
+
|
103
|
+
console.log( "product_style_switch : "+product_style_switch );
|
104
|
+
|
105
|
+
console.log( "switch_handle : "+switch_handle );
|
106
|
+
|
107
|
+
console.log( "" );
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
var src_colorSelecter ="";
|
112
|
+
|
113
|
+
var product_img = product.images.length;
|
114
|
+
|
115
|
+
var title = product.title.split(" ");
|
116
|
+
|
117
|
+
if (product_handle.indexOf(current_handle_prefix) !== -1) {
|
118
|
+
|
119
|
+
console.log( product );
|
120
|
+
|
121
|
+
if ( product.handle == "{{ product.handle }}" ) {
|
122
|
+
|
123
|
+
src_colorSelecter += '<div class="other_color current_item">';
|
124
|
+
|
125
|
+
}else{
|
126
|
+
|
127
|
+
src_colorSelecter += '<div class="other_color">';
|
128
|
+
|
129
|
+
}
|
130
|
+
|
131
|
+
if ( product_img == 0){
|
132
|
+
|
133
|
+
src_colorSelecter += '<a href=\"/products/'+product.handle+'\"><img src=\"https://cdn.shopify.com/shopifycloud/shopify/assets/no-image-50-3d8cc48bd078edcd544c8d60f929ed2d8800a3fc52e0f602e84b1767e392bfcd_1728x.gif\"></a><br /><span>'+title[title.length - 1]+'</span></div>';
|
134
|
+
|
135
|
+
} else {
|
136
|
+
|
137
|
+
src_colorSelecter += '<a href=\"/products/'+product.handle+'\"><img src=\"'+product.images[0].src.replace(/-ue.jpg/,'-ue_360x.jpg')+'\"></a><br /><span>'+title[title.length - 1]+'</span></div>';
|
138
|
+
|
139
|
+
}
|
140
|
+
|
141
|
+
console.log(product.current_handle_switch);
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
$('#wrap_other_color').append(src_colorSelecter);
|
146
|
+
|
147
|
+
} else {}
|
148
|
+
|
149
|
+
});
|
150
|
+
|
151
|
+
}
|
152
|
+
|
153
|
+
)
|
154
|
+
|
155
|
+
</script>
|
156
|
+
|
157
|
+
```
|
1
教えていただいたコードに一部修正しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -30,7 +30,7 @@
|
|
30
30
|
|
31
31
|
if ( str.indexOf('{{ product.handle }}') != -1) {
|
32
32
|
|
33
|
-
var page = 'https://shopname.myshopify.com/collections/{{ collection.handle }}/products.json?limit=250?page=num++;
|
33
|
+
var page = 'https://shopname.myshopify.com/collections/{{ collection.handle }}/products.json?limit=250?page='+(num++);
|
34
34
|
|
35
35
|
}
|
36
36
|
|