Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix for order.order_id not being set #3398

Merged
merged 5 commits into from
Aug 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +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 (#3398)

## [1.10.0] - 2019.08.10

Expand Down
1 change: 1 addition & 0 deletions core/modules/order/store/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const actions: ActionTree<OrderState, RootState> = {
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()
Expand Down
1 change: 1 addition & 0 deletions core/modules/order/store/mutation-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
15 changes: 9 additions & 6 deletions core/modules/order/store/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -13,12 +14,8 @@ const mutations: MutationTree<OrderState> = {
*/
[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
Expand All @@ -31,6 +28,12 @@ const mutations: MutationTree<OrderState> = {
[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)
},
Expand Down