@lancom/shared 0.0.223 → 0.0.225
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/assets/js/api/admin.js
CHANGED
|
@@ -4,8 +4,9 @@ import { sortSizes } from './../utils/sizes';
|
|
|
4
4
|
import { sortByName } from './../utils/filters';
|
|
5
5
|
|
|
6
6
|
export default {
|
|
7
|
-
updateInventoryFromLink(link) {
|
|
8
|
-
|
|
7
|
+
updateInventoryFromLink(link, warehouse) {
|
|
8
|
+
const url = `admin/products/inventory/link${warehouse ? `?warehouse=${warehouse}` : ''}`;
|
|
9
|
+
return _post(url, { link });
|
|
9
10
|
},
|
|
10
11
|
fetchPostcodes() {
|
|
11
12
|
return _get('admin/postcodes');
|
|
@@ -58,6 +59,12 @@ export default {
|
|
|
58
59
|
getCanonicalProductProducts(id) {
|
|
59
60
|
return _get(`admin/canonical-product/${id}/products`);
|
|
60
61
|
},
|
|
62
|
+
getCanonicalProductLocations(id) {
|
|
63
|
+
return _get(`admin/canonical-product/${id}/locations`);
|
|
64
|
+
},
|
|
65
|
+
saveWarehouseCanonicalProduct(warehouseCanonicalProduct) {
|
|
66
|
+
return warehouseCanonicalProduct._id ? _put(`admin/warehouse-canonical-product/${warehouseCanonicalProduct._id}`, warehouseCanonicalProduct) : _post('admin/warehouse-canonical-product', warehouseCanonicalProduct);
|
|
67
|
+
},
|
|
61
68
|
fetchShops(params) {
|
|
62
69
|
return _get('admin/shops', params);
|
|
63
70
|
},
|
|
@@ -115,7 +115,7 @@ export default {
|
|
|
115
115
|
};
|
|
116
116
|
},
|
|
117
117
|
computed: {
|
|
118
|
-
...mapGetters(['shop']),
|
|
118
|
+
...mapGetters(['shop', 'country', 'currency']),
|
|
119
119
|
...mapGetters('product', [
|
|
120
120
|
'layers',
|
|
121
121
|
'product',
|
|
@@ -177,7 +177,7 @@ export default {
|
|
|
177
177
|
},
|
|
178
178
|
proceedToCard() {
|
|
179
179
|
const entities = generateCartProducts(this.product, this.template.simpleProducts, this.template.layers, this.isPrintPricing, this.layerThumbnails);
|
|
180
|
-
this.addToCart({ entities, shop: this.shop, pricing: this.productPricing });
|
|
180
|
+
this.addToCart({ entities, shop: this.shop, pricing: this.productPricing, country: this.country, currency: this.currency });
|
|
181
181
|
this.showCartModal(async () => {
|
|
182
182
|
const message = 'Do you wish to continue with editing the current design or reset the editor?';
|
|
183
183
|
const reset = await this.showConfirmationModal(message, {
|
package/package.json
CHANGED
package/store/cart.js
CHANGED
|
@@ -68,14 +68,19 @@ export const getters = {
|
|
|
68
68
|
};
|
|
69
69
|
|
|
70
70
|
export const actions = {
|
|
71
|
-
async addToCart({ state, commit }, { entities, shop, pricing }) {
|
|
71
|
+
async addToCart({ state, commit }, { entities, shop, pricing, country, currency }) {
|
|
72
72
|
const addingEntities = [...entities];
|
|
73
73
|
const isSamePrints = (e, e2) => {
|
|
74
74
|
const samePrints = (e.prints || []).filter(p => (e2.prints || []).some(p2 => p2.guid === p.guid));
|
|
75
75
|
return (e.prints || []).length === samePrints.length;
|
|
76
76
|
};
|
|
77
|
+
const params = {
|
|
78
|
+
currency: currency?._id,
|
|
79
|
+
country: country?._id
|
|
80
|
+
};
|
|
81
|
+
const cartEntities = state.id ? (await api.fetchCartById(shop._id, state.id, params)).entities : state.entities;
|
|
77
82
|
entities = entities.map(e => {
|
|
78
|
-
const entitiy =
|
|
83
|
+
const entitiy = cartEntities.find(e2 => isSamePrints(e, e2) && e2?.product?._id === e?.product?._id);
|
|
79
84
|
if (entitiy) {
|
|
80
85
|
e.simpleProducts.forEach(sp => {
|
|
81
86
|
const simpleProduct = entitiy.simpleProducts.find(sp2 => sp2.SKU === sp.SKU);
|
|
@@ -91,7 +96,7 @@ export const actions = {
|
|
|
91
96
|
}).filter(e => !!e);
|
|
92
97
|
const payload = {
|
|
93
98
|
_id: state.id || undefined,
|
|
94
|
-
entities: [...
|
|
99
|
+
entities: [...cartEntities, ...entities]
|
|
95
100
|
};
|
|
96
101
|
const cart = await api.saveCart(payload, shop._id);
|
|
97
102
|
if (cart) {
|
|
@@ -224,7 +229,6 @@ export const mutations = {
|
|
|
224
229
|
};
|
|
225
230
|
|
|
226
231
|
function generateCalculatePriceData(entities, suburb, suppliersWithRates, coupon, selectedSuppliersWithRates) {
|
|
227
|
-
console.log('entities: ', entities);
|
|
228
232
|
const getSimpleObj = i => i && ({ _id: i._id, name: i.name });
|
|
229
233
|
return {
|
|
230
234
|
entities: entities.map(({ _id, guid, prints, simpleProducts, product }) => ({
|
|
@@ -247,6 +251,8 @@ function generateCalculatePriceData(entities, suburb, suppliersWithRates, coupon
|
|
|
247
251
|
prints: (prints || []).map(print => {
|
|
248
252
|
const { setupCost, freeSetupOver, printCost } = getPrintTypeSizePricing(print.printType, print.printSize?._id, coupon) || {};
|
|
249
253
|
return {
|
|
254
|
+
_id: print._id,
|
|
255
|
+
guid: print.guid,
|
|
250
256
|
costType: print.printType.costType,
|
|
251
257
|
setupCost,
|
|
252
258
|
printCost,
|