Skip to content

Commit f91d3af

Browse files
committed
rest cart after place order
1 parent 68bcfb2 commit f91d3af

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed

src/actions/RestActions.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import {
5656
RESET_FILTERS_DATA,
5757
MAGENTO_ADD_ACCOUNT_ADDRESS_ERROR,
5858
MAGENTO_GET_CUSTOM_OPTIONS,
59+
MAGENTO_CART_RESET,
5960
} from './types';
6061
import { logError } from '../helper/logger';
6162
import { priceSignByCode } from '../helper/price';
@@ -418,6 +419,19 @@ export const createCustomerCart = customerId => async dispatch => {
418419
}
419420
};
420421

422+
export const resetCart = () => {
423+
return async dispatch => {
424+
try {
425+
await AsyncStorage.removeItem('cartId');
426+
} catch (error) {
427+
logError(error);
428+
}
429+
return dispatch({
430+
type: MAGENTO_CART_RESET,
431+
});
432+
};
433+
};
434+
421435
export const getCart =
422436
(refreshing = false) =>
423437
async (dispatch, getState) => {

src/actions/types.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export const MAGENTO_CURRENT_CUSTOMER = 'magento_current_customer';
5757

5858
export const MAGENTO_AUTH = 'magento_auth';
5959
export const MAGENTO_LOGOUT = 'magento_logout';
60+
export const MAGENTO_CART_RESET = 'MAGENTO_CART_RESET';
6061
export const MAGENTO_LOGIN_SUCCESS = 'magento_login_success';
6162
export const MAGENTO_AUTH_ERROR = 'magento_auth_error';
6263
export const MAGENTO_AUTH_LOADING = 'magento_auth_loading';

src/components/checkout/CheckoutTotals.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
checkoutOrderPopupShown,
99
placeGuestCartOrder,
1010
getCart,
11+
resetCart,
1112
checkoutSetActiveSection,
1213
removeCouponFromCart,
1314
addCouponToCart,
@@ -172,7 +173,7 @@ class CheckoutTotals extends Component {
172173

173174
showPopup(title, message) {
174175
this.props.checkoutSetActiveSection(1);
175-
this.props.getCart();
176+
this.props.resetCart();
176177
// this.props.checkoutOrderPopupShown();
177178
Alert.alert(
178179
title,
@@ -307,6 +308,7 @@ export default connect(mapStateToProps, {
307308
checkoutOrderPopupShown,
308309
placeGuestCartOrder,
309310
getCart,
311+
resetCart,
310312
addCouponToCart,
311313
removeCouponFromCart,
312314
})(CheckoutTotals);

src/reducers/CartReducer.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
MAGENTO_CURRENT_PRODUCT,
1313
MAGENTO_LOGIN_SUCCESS,
1414
MAGENTO_COUPON_LOADING,
15-
MAGENTO_COUPON_ERROR,
15+
MAGENTO_COUPON_ERROR, MAGENTO_CART_RESET,
1616
} from '../actions/types';
1717

1818
const INITIAL_STATE = {
@@ -44,6 +44,7 @@ export default (state = INITIAL_STATE, action) => {
4444
case MAGENTO_CURRENT_PRODUCT:
4545
return { ...state, errorMessage: false };
4646
case MAGENTO_LOGOUT:
47+
case MAGENTO_CART_RESET:
4748
return { ...INITIAL_STATE };
4849
case MAGENTO_ADD_TO_CART:
4950
return {

0 commit comments

Comments
 (0)