vue-storefront-1
vue-storefront-1 copied to clipboard
Order placement error
While submitting the order (integration with Magento 2), I get this error:
{"code":500,"result":"req.body.products is not iterable"}
although in the end the order was successfully created. What could be the problem?
Please check the payload your browser is sending to the api/order endpoint and let us know if it's all OK? I guess it's not a core-vsf issue
Thanks for the quick response. Here is the payload i am transferring
{
"newOrder": {
"user_id": "1",
"cart_id": "149",
"products": [{
"image": "/d/m/dmd_cr422_7.jpg",
"small_image": "/d/m/dmd_cr422_7.jpg",
"type_id": "virtual",
"tax_class_id": 2,
"url_key": "dmd_cr422-800",
"final_price": 550,
"price": 550,
"name": "DMD_CR422",
"id": 800,
"sku": "DMD_CR422",
"swatch_image": "/d/m/dmd_cr422_7.jpg",
"url_path": "dmd-cr422.html",
"status": 1,
"original_price": 550,
"original_price_tax": 0,
"original_price_incl_tax": 550,
"original_final_price": 550,
"price_tax": 0,
"price_incl_tax": 550,
"final_price_tax": 0,
"final_price_incl_tax": 550,
"special_price": 0,
"special_price_tax": 0,
"special_price_incl_tax": 0,
"_score": null,
"slug": "dmd_cr422-800",
"qty": 1,
"errors": {},
"info": {
"stock": "In stock!"
},
"parentSku": "DMD_CR422",
"parentId": 800,
"checksum": "228214dd5d4b5ace370c6405f2b79a3a1b23ba8f942fc388dd67e948",
"onlineStockCheckid": "1595081560565-0d177b63-ce79-b0bf-db3b-fe82b66177c7",
"is_in_stock": true,
"server_item_id": 54,
"server_cart_id": "149",
"prev_qty": 1,
"totals": {
"item_id": 54,
"price": 550,
"base_price": 550,
"qty": 1,
"row_total": 550,
"base_row_total": 550,
"row_total_with_discount": 0,
"tax_amount": 0,
"base_tax_amount": 0,
"tax_percent": 0,
"discount_amount": 0,
"base_discount_amount": 0,
"discount_percent": 0,
"price_incl_tax": 550,
"base_price_incl_tax": 550,
"row_total_incl_tax": 550,
"base_row_total_incl_tax": 550,
"options": [],
"weee_tax_applied_amount": null,
"weee_tax_applied": null,
"name": "DMD_CR422"
},
"stock": {
"item_id": 930,
"product_id": 800,
"stock_id": 1,
"qty": 1,
"is_in_stock": true,
"is_qty_decimal": false,
"show_default_notification_message": false,
"use_config_min_qty": true,
"min_qty": 0,
"use_config_min_sale_qty": 0,
"min_sale_qty": 1,
"use_config_max_sale_qty": false,
"max_sale_qty": 1,
"use_config_backorders": false,
"backorders": 0,
"use_config_notify_stock_qty": false,
"notify_stock_qty": 1,
"use_config_qty_increments": false,
"qty_increments": 0,
"use_config_enable_qty_inc": true,
"enable_qty_increments": false,
"use_config_manage_stock": false,
"manage_stock": true,
"low_stock_date": null,
"is_decimal_divided": false,
"stock_status_changed_auto": 0
}
}, {
"image": "/d/m/dmd_cr418_7.jpg",
"small_image": "/d/m/dmd_cr418_7.jpg",
"type_id": "virtual",
"tax_class_id": 2,
"url_key": "dmd_cr418-796",
"final_price": 550,
"price": 550,
"name": "DMD_CR418",
"id": 796,
"sku": "DMD_CR418",
"swatch_image": "/d/m/dmd_cr418_7.jpg",
"url_path": "dmd-cr418.html",
"status": 1,
"original_price": 550,
"original_price_tax": 0,
"original_price_incl_tax": 550,
"original_final_price": 550,
"price_tax": 0,
"price_incl_tax": 550,
"final_price_tax": 0,
"final_price_incl_tax": 550,
"special_price": 0,
"special_price_tax": 0,
"special_price_incl_tax": 0,
"_score": null,
"slug": "dmd_cr418-796",
"qty": 1,
"errors": {},
"info": {
"stock": "In stock!"
},
"parentSku": "DMD_CR418",
"parentId": 796,
"checksum": "228214dd5d4b5ace370c6405f2b79a3a1b23ba8f942fc388dd67e948",
"onlineStockCheckid": "1595086981256-c76abe42-b3d2-8b72-e525-9c532b8f8c97",
"is_in_stock": true,
"server_item_id": 55,
"server_cart_id": "149",
"prev_qty": 1,
"totals": {
"item_id": 55,
"price": 550,
"base_price": 550,
"qty": 1,
"row_total": 550,
"base_row_total": 550,
"row_total_with_discount": 0,
"tax_amount": 0,
"base_tax_amount": 0,
"tax_percent": 0,
"discount_amount": 0,
"base_discount_amount": 0,
"discount_percent": 0,
"price_incl_tax": 550,
"base_price_incl_tax": 550,
"row_total_incl_tax": 550,
"base_row_total_incl_tax": 550,
"options": [],
"weee_tax_applied_amount": null,
"weee_tax_applied": null,
"name": "DMD_CR418"
},
"stock": {
"item_id": 926,
"product_id": 796,
"stock_id": 1,
"qty": 1,
"is_in_stock": true,
"is_qty_decimal": false,
"show_default_notification_message": false,
"use_config_min_qty": true,
"min_qty": 0,
"use_config_min_sale_qty": 0,
"min_sale_qty": 1,
"use_config_max_sale_qty": false,
"max_sale_qty": 1,
"use_config_backorders": false,
"backorders": 0,
"use_config_notify_stock_qty": false,
"notify_stock_qty": 1,
"use_config_qty_increments": false,
"qty_increments": 0,
"use_config_enable_qty_inc": true,
"enable_qty_increments": false,
"use_config_manage_stock": false,
"manage_stock": true,
"low_stock_date": null,
"is_decimal_divided": false,
"stock_status_changed_auto": 0
}
}],
"addressInformation": {
"billingAddress": {
"region": "",
"region_id": 0,
"country_id": "NL",
"street": ["test", "44"],
"company": "",
"telephone": "00000000",
"postcode": "61000",
"city": "test",
"firstname": "test",
"lastname": "test",
"email": "[email protected]",
"region_code": "",
"vat_id": ""
},
"payment_method_code": "stripe_payments",
"payment_method_additional": {}
}
},
"transmited": true,
"order_id": "1595087362578-4d638300-8fc6-2034-0969-024c72555a39",
"created_at": "2020-07-18T15:49:22.578Z",
"updated_at": "2020-07-18T15:49:22.578Z",
"transmited_at": "2020-07-18T16:04:08.143Z"
}
vsf core bug. When api returns on place order action status 500, in my case VSF doesn't support regionId for countries which require it, then order is queued on browser side for re-processing and body is totally different.
catch logic in core/modules/order/store/actions.ts
try {
return await dispatch('processOrder', { newOrder: order, currentOrderHash })
} catch (error) {
dispatch('handlePlacingOrderFailed', { newOrder: order, currentOrderHash })
throw error
}
where handlePlacingOrderFailed has
const order = { newOrder, transmited: false }
....
dispatch('enqueueOrder', { newOrder: order }) // here is now newOrder.newOrder
Following seems to fix this
diff --git a/core/modules/order/store/actions.ts b/core/modules/order/store/actions.ts
index 21f304c43..19e396973 100644
--- a/core/modules/order/store/actions.ts
+++ b/core/modules/order/store/actions.ts
@@ -80,7 +80,7 @@ const actions: ActionTree<OrderState, RootState> = {
const order = { newOrder, transmited: false }
commit(types.ORDER_REMOVE_SESSION_ORDER_HASH, currentOrderHash)
dispatch('notification/spawnNotification', notifications.orderCannotTransfered(), { root: true })
- dispatch('enqueueOrder', { newOrder: order })
+ dispatch('enqueueOrder', order)
EventBus.$emit('notification-progress-stop')
},
@pkarw Got same problem here. Why is this labeled as a question instead of a bug? What should I do if this is not a bug?
i just realized that we have over 200 error events in sentry about this bug!! This is major! Orders not getting through in an e-commerce system should be PRIO 1! @cyzeal thanks for pr! will try immediately!
bin/magento setup:upgrade && bin/magento setup:di:compile
This solved it for me. (thanks to linkedin.com/in/nenadnovkovic)
@pogonik can you explain how running these Magento 2 commands fixed the issues in VSF?
I am experiencing the same issue.