2021-02-24 01:36:24 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
2022-12-19 15:30:13 +00:00
|
|
|
import type { Cart, CartMeta, ApiErrorResponse } from '@woocommerce/types';
|
2021-02-24 01:36:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
2021-08-13 13:28:41 +00:00
|
|
|
import {
|
|
|
|
EMPTY_CART_COUPONS,
|
|
|
|
EMPTY_CART_ITEMS,
|
2022-09-21 06:04:15 +00:00
|
|
|
EMPTY_CART_CROSS_SELLS,
|
2021-08-13 13:28:41 +00:00
|
|
|
EMPTY_CART_FEES,
|
|
|
|
EMPTY_CART_ITEM_ERRORS,
|
|
|
|
EMPTY_CART_ERRORS,
|
|
|
|
EMPTY_SHIPPING_RATES,
|
|
|
|
EMPTY_TAX_LINES,
|
2023-03-13 10:29:17 +00:00
|
|
|
EMPTY_PAYMENT_METHODS,
|
2021-08-13 13:28:41 +00:00
|
|
|
EMPTY_PAYMENT_REQUIREMENTS,
|
|
|
|
EMPTY_EXTENSIONS,
|
2022-07-08 05:53:24 +00:00
|
|
|
} from '../constants';
|
|
|
|
|
|
|
|
const EMPTY_PENDING_QUANTITY: [] = [];
|
|
|
|
const EMPTY_PENDING_DELETE: [] = [];
|
2021-02-24 01:36:24 +00:00
|
|
|
|
|
|
|
export interface CartState {
|
2022-12-19 15:30:13 +00:00
|
|
|
cartItemsPendingQuantity: string[];
|
|
|
|
cartItemsPendingDelete: string[];
|
2021-02-24 01:36:24 +00:00
|
|
|
cartData: Cart;
|
|
|
|
metaData: CartMeta;
|
2022-12-19 15:30:13 +00:00
|
|
|
errors: ApiErrorResponse[];
|
2021-02-24 01:36:24 +00:00
|
|
|
}
|
|
|
|
export const defaultCartState: CartState = {
|
2021-08-13 13:28:41 +00:00
|
|
|
cartItemsPendingQuantity: EMPTY_PENDING_QUANTITY,
|
|
|
|
cartItemsPendingDelete: EMPTY_PENDING_DELETE,
|
2020-06-10 18:21:34 +00:00
|
|
|
cartData: {
|
2021-08-13 13:28:41 +00:00
|
|
|
coupons: EMPTY_CART_COUPONS,
|
|
|
|
shippingRates: EMPTY_SHIPPING_RATES,
|
2020-06-10 18:21:34 +00:00
|
|
|
shippingAddress: {
|
|
|
|
first_name: '',
|
|
|
|
last_name: '',
|
|
|
|
company: '',
|
|
|
|
address_1: '',
|
|
|
|
address_2: '',
|
|
|
|
city: '',
|
|
|
|
state: '',
|
|
|
|
postcode: '',
|
|
|
|
country: '',
|
2021-07-22 11:03:00 +00:00
|
|
|
phone: '',
|
2020-06-10 18:21:34 +00:00
|
|
|
},
|
2021-02-24 01:36:24 +00:00
|
|
|
billingAddress: {
|
|
|
|
first_name: '',
|
|
|
|
last_name: '',
|
|
|
|
company: '',
|
|
|
|
address_1: '',
|
|
|
|
address_2: '',
|
|
|
|
city: '',
|
|
|
|
state: '',
|
|
|
|
postcode: '',
|
|
|
|
country: '',
|
|
|
|
phone: '',
|
|
|
|
email: '',
|
|
|
|
},
|
2021-08-13 13:28:41 +00:00
|
|
|
items: EMPTY_CART_ITEMS,
|
2020-06-10 18:21:34 +00:00
|
|
|
itemsCount: 0,
|
|
|
|
itemsWeight: 0,
|
2022-09-21 06:04:15 +00:00
|
|
|
crossSells: EMPTY_CART_CROSS_SELLS,
|
2020-06-10 18:21:34 +00:00
|
|
|
needsShipping: true,
|
2021-02-24 01:36:24 +00:00
|
|
|
needsPayment: false,
|
|
|
|
hasCalculatedShipping: true,
|
2021-08-13 13:28:41 +00:00
|
|
|
fees: EMPTY_CART_FEES,
|
2020-06-10 18:21:34 +00:00
|
|
|
totals: {
|
|
|
|
currency_code: '',
|
|
|
|
currency_symbol: '',
|
|
|
|
currency_minor_unit: 2,
|
|
|
|
currency_decimal_separator: '.',
|
|
|
|
currency_thousand_separator: ',',
|
|
|
|
currency_prefix: '',
|
|
|
|
currency_suffix: '',
|
|
|
|
total_items: '0',
|
|
|
|
total_items_tax: '0',
|
|
|
|
total_fees: '0',
|
|
|
|
total_fees_tax: '0',
|
|
|
|
total_discount: '0',
|
|
|
|
total_discount_tax: '0',
|
|
|
|
total_shipping: '0',
|
|
|
|
total_shipping_tax: '0',
|
|
|
|
total_price: '0',
|
|
|
|
total_tax: '0',
|
2021-08-13 13:28:41 +00:00
|
|
|
tax_lines: EMPTY_TAX_LINES,
|
2020-06-10 18:21:34 +00:00
|
|
|
},
|
2021-08-13 13:28:41 +00:00
|
|
|
errors: EMPTY_CART_ITEM_ERRORS,
|
2023-03-13 10:29:17 +00:00
|
|
|
paymentMethods: EMPTY_PAYMENT_METHODS,
|
2021-08-13 13:28:41 +00:00
|
|
|
paymentRequirements: EMPTY_PAYMENT_REQUIREMENTS,
|
|
|
|
extensions: EMPTY_EXTENSIONS,
|
2021-02-24 01:36:24 +00:00
|
|
|
},
|
|
|
|
metaData: {
|
|
|
|
updatingCustomerData: false,
|
|
|
|
updatingSelectedRate: false,
|
|
|
|
applyingCoupon: '',
|
|
|
|
removingCoupon: '',
|
2021-03-24 13:28:11 +00:00
|
|
|
isCartDataStale: false,
|
2020-06-10 18:21:34 +00:00
|
|
|
},
|
2021-08-13 13:28:41 +00:00
|
|
|
errors: EMPTY_CART_ERRORS,
|
2020-06-10 18:21:34 +00:00
|
|
|
};
|