Shopify를 사용 중이며 고객 사이트에 Qubit을 추가해야합니다.프로그래밍 방식으로 JS 객체에 추가하는 방법은 무엇입니까?
언제든지 사용자 바구니에 어떤 제품이 있는지 보여주는 "바구니"개체가 있습니다.
이 json 구조에 개체를 어떻게 동적으로 삽입합니까? 어떻게 동적으로 (사이비 코드는 괜찮) 후 장바구니에서 사용할 수있는 제품을 통해 반복 것 ... 그것은 등 하나 개의 제품, 또는 두 개의 제품을 수 http://tools.qubitproducts.com/uv/demosite/guide.html
:
"line_items": [{
"product": {
"id": "1234567890",
"sku_code": "0987654321",
"url": "product.html",
"name": "Sparkly Shoes",
"description": "Description about this product",
"manufacturer": "The Shoe Co",
"category": "Shoe",
"subcategory": "Heels",
"color": "n/a",
"stock": 3,
"size": "6",
"currency": "GBP",
"unit_price": 130,
"unit_sale_price": 130,
"voucher": "MYVOUCHER1"
},
"quantity": 1,
"subtotal": 130,
"total_discount": 0
}, {
"product": {
"id": "1234567890",
"sku_code": "0987654321",
"url": "product-dress.html",
"name": "Red Dress",
"description": "Description about this product",
"manufacturer": "The Dress Co",
"category": "Dresses",
"subcategory": "Red dresses",
"color": "n/a",
"stock": 3,
"size": "6",
"currency": "GBP",
"unit_price": 200,
"unit_sale_price": 150,
"voucher": "MYVOUCHER1"
},
"quantity": 1,
"subtotal": 200,
"total_discount": 50
}, {
"product": {
"id": "1234567890",
"sku_code": "0987654321",
"url": "product-swimwear.html",
"name": "Bikini",
"description": "Description about this product",
"manufacturer": "The Bikini Co",
"category": "Swimwear",
"subcategory": "Bikini",
"color": "n/a",
"stock": 3,
"size": "6",
"currency": "GBP",
"unit_price": 100,
"unit_sale_price": 100,
"voucher": "MYVOUCHER1"
},
"quantity": 1,
"subtotal": 100,
"total_discount": 0
}]
},
은에서 촬영 몇 가지 값을 표시 하시겠습니까?
위의 json 구조를 어떻게 정의 할 수 있습니까? 코드 사이에 루프를 넣으시겠습니까? (더러운 느낌?)
JSON (직렬화 형식)을 Javascript 객체 (조작 할 수있는 런타임 객체)와 혼동스럽게 생각할 수 있습니다. 어떤 종류의 코드를 생각하고 있는지 몇 가지 예를 들려 줄 수 있습니까? – hugomg
이미 제품 데이터 필드를 가져온 후 장바구니에 제품을 추가하는 방법을 묻는 중입니까? –