From 23d6edcdd76e827028bdc5aca751c8fcd591a7c0 Mon Sep 17 00:00:00 2001 From: pkarw Date: Wed, 21 Aug 2019 14:19:04 +0200 Subject: [PATCH 1/4] Hotfix - order.order_id was not assigned in the orders.directBackendSync mode --- core/modules/order/store/actions.ts | 1 + core/modules/order/store/mutation-types.ts | 1 + core/modules/order/store/mutations.ts | 15 +++++++++------ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/core/modules/order/store/actions.ts b/core/modules/order/store/actions.ts index a8b141d7f5..cce27044a8 100644 --- a/core/modules/order/store/actions.ts +++ b/core/modules/order/store/actions.ts @@ -23,6 +23,7 @@ const actions: ActionTree = { const currentOrderHash = sha3_224(JSON.stringify(order)) const isAlreadyProcessed = getters.getSessionOrderHashes.includes(currentOrderHash) if (isAlreadyProcessed) return + commit(types.ORDER_ADD_SESSION_STAMPS, order) commit(types.ORDER_ADD_SESSION_ORDER_HASH, currentOrderHash) const storeView = currentStoreView() diff --git a/core/modules/order/store/mutation-types.ts b/core/modules/order/store/mutation-types.ts index d253a4273f..8bdebb78db 100644 --- a/core/modules/order/store/mutation-types.ts +++ b/core/modules/order/store/mutation-types.ts @@ -4,3 +4,4 @@ export const ORDER_PROCESS_QUEUE = SN_ORDER + '/PROCESS_QUEUE' export const ORDER_LAST_ORDER_WITH_CONFIRMATION = SN_ORDER + '/LAST_ORDER_CONFIRMATION' export const ORDER_ADD_SESSION_ORDER_HASH = SN_ORDER + '/ADD_SESSION_ORDER_HASH' export const ORDER_REMOVE_SESSION_ORDER_HASH = SN_ORDER + '/REMOVE_SESSION_ORDER_HASH' +export const ORDER_ADD_SESSION_STAMPS = SN_ORDER + '/ADD_SESSION_STAMPS' \ No newline at end of file diff --git a/core/modules/order/store/mutations.ts b/core/modules/order/store/mutations.ts index 3e909fc749..680f1bc010 100644 --- a/core/modules/order/store/mutations.ts +++ b/core/modules/order/store/mutations.ts @@ -3,6 +3,7 @@ import { MutationTree } from 'vuex' import * as types from './mutation-types' import * as entities from '@vue-storefront/core/store/lib/entities' import OrderState from '../types/OrderState' +import { Order } from '../types/Order' import config from 'config' import { Logger } from '@vue-storefront/core/lib/logger' @@ -13,12 +14,8 @@ const mutations: MutationTree = { */ [types.ORDER_PLACE_ORDER] (state, order) { const ordersCollection = Vue.prototype.$db.ordersCollection - const orderId = entities.uniqueEntityId(order) // timestamp as a order id is not the best we can do but it's enough - order.order_id = orderId.toString() - order.created_at = new Date() - order.updated_at = new Date() - - ordersCollection.setItem(orderId.toString(), order, (err, resp) => { + const orderId = order.order_id ? order.order_id : entities.uniqueEntityId(order).toString() + ordersCollection.setItem(orderId, order, (err, resp) => { if (err) Logger.error(err, 'order')() if (!order.transmited) { Vue.prototype.$bus.$emit('order/PROCESS_QUEUE', { config: config }) // process checkout queue @@ -31,6 +28,12 @@ const mutations: MutationTree = { [types.ORDER_LAST_ORDER_WITH_CONFIRMATION] (state, payload) { state.last_order_confirmation = payload }, + [types.ORDER_ADD_SESSION_STAMPS] (state, order: Order) { + const orderId = entities.uniqueEntityId(order) // timestamp as a order id is not the best we can do but it's enough + order.order_id = orderId.toString() + order.created_at = new Date().toString() + order.updated_at = new Date().toString() + }, [types.ORDER_ADD_SESSION_ORDER_HASH] (state, hash: string) { state.session_order_hashes.push(hash) }, From f164851c1640465e666ac8ff202cfdc0e4091c3b Mon Sep 17 00:00:00 2001 From: pkarw Date: Wed, 21 Aug 2019 14:19:16 +0200 Subject: [PATCH 2/4] Update mutation-types.ts --- core/modules/order/store/mutation-types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/modules/order/store/mutation-types.ts b/core/modules/order/store/mutation-types.ts index 8bdebb78db..bfa880b2a5 100644 --- a/core/modules/order/store/mutation-types.ts +++ b/core/modules/order/store/mutation-types.ts @@ -4,4 +4,4 @@ export const ORDER_PROCESS_QUEUE = SN_ORDER + '/PROCESS_QUEUE' export const ORDER_LAST_ORDER_WITH_CONFIRMATION = SN_ORDER + '/LAST_ORDER_CONFIRMATION' export const ORDER_ADD_SESSION_ORDER_HASH = SN_ORDER + '/ADD_SESSION_ORDER_HASH' export const ORDER_REMOVE_SESSION_ORDER_HASH = SN_ORDER + '/REMOVE_SESSION_ORDER_HASH' -export const ORDER_ADD_SESSION_STAMPS = SN_ORDER + '/ADD_SESSION_STAMPS' \ No newline at end of file +export const ORDER_ADD_SESSION_STAMPS = SN_ORDER + '/ADD_SESSION_STAMPS' From 7ae1fb0fe1d75290b4899e7f20be3104bf59b5cc Mon Sep 17 00:00:00 2001 From: pkarw Date: Wed, 21 Aug 2019 14:20:05 +0200 Subject: [PATCH 3/4] Update CHANGELOG.md --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b3105c42c..00c6e8115c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.10.1] - not released + +### Fixed + - Hotfix - `order.order_id` was not assigned in the `orders.directBackendSync` mode - @pkarw + ## [1.10.0] - 2019.08.10 ### Added From 668de08e345d9b37f5a71df993600315b61d5a2a Mon Sep 17 00:00:00 2001 From: Patryk Tomczyk <13100280+patzick@users.noreply.github.com> Date: Fri, 23 Aug 2019 15:30:25 +0200 Subject: [PATCH 4/4] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4aaafed475..6ff4c6c65e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Invalid Discount code error handled by theme - @grimasod (#3385) -- Hotfix - `order.order_id` was not assigned in the `orders.directBackendSync` mode - @pkarw +- Hotfix - `order.order_id` was not assigned in the `orders.directBackendSync` mode - @pkarw (#3398) ## [1.10.0] - 2019.08.10