@viur/shop-components 0.11.0 → 0.12.0
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/package.json +1 -1
- package/src/Shop.vue +2 -1
- package/src/components/DiscountInput.vue +10 -9
- package/src/composables/cart.js +9 -3
- package/src/shop.js +2 -1
- package/src/translations/de.js +1 -0
- package/src/translations/fr.js +1 -0
package/package.json
CHANGED
package/src/Shop.vue
CHANGED
|
@@ -52,7 +52,8 @@
|
|
|
52
52
|
readytoship: {{ shopStore.state.order?.['is_rts'] }}<br>
|
|
53
53
|
paid: {{ shopStore.state.order?.['is_paid'] }}<br><br>
|
|
54
54
|
|
|
55
|
-
OrderObject: {{shopStore.state.order}}
|
|
55
|
+
OrderObject: {{shopStore.state.order}}<br><br>
|
|
56
|
+
activeDiscounts: {{ shopStore.state.discounts }}
|
|
56
57
|
|
|
57
58
|
</sl-details>
|
|
58
59
|
</template>
|
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
{{ state.alert.msg }}
|
|
3
2
|
<shop-alert
|
|
4
3
|
v-if="state.alert.show"
|
|
5
4
|
:variant="state.alert.variant"
|
|
6
5
|
@onHide="state.alert = {}"
|
|
7
|
-
duration="
|
|
6
|
+
duration="5000"
|
|
8
7
|
>
|
|
9
8
|
<template #alertMsg>
|
|
10
9
|
{{ state.alert.msg }}
|
|
11
10
|
</template>
|
|
12
11
|
</shop-alert>
|
|
13
12
|
|
|
14
|
-
<template v-if="shopStore.state.
|
|
13
|
+
<template v-if="shopStore.state.discounts">
|
|
14
|
+
<template v-for="discount in shopStore.state.discounts">
|
|
15
15
|
<div class="viur-shop-discount-view">
|
|
16
|
-
<span>Code: {{
|
|
17
|
-
<sl-button size="small" outline variant="danger" @click="removeDiscountAction" :loading="state.loading">
|
|
16
|
+
<span>Code: {{ discount.dest.name }}</span>
|
|
17
|
+
<sl-button size="small" outline variant="danger" @click="removeDiscountAction(discount.dest.key)" :loading="state.loading">
|
|
18
18
|
<sl-icon name="x-lg" slot="prefix"></sl-icon>
|
|
19
19
|
|
|
20
20
|
</sl-button>
|
|
21
21
|
</div>
|
|
22
|
+
</template>
|
|
22
23
|
</template>
|
|
23
|
-
<sl-button-group
|
|
24
|
+
<sl-button-group>
|
|
24
25
|
<sl-input
|
|
25
26
|
class="viur-shop-discount-input"
|
|
26
27
|
:placeholder="$t('viur.shop.add_discount_placeholder')"
|
|
@@ -63,12 +64,12 @@ function addDiscountAction() {
|
|
|
63
64
|
});
|
|
64
65
|
}
|
|
65
66
|
|
|
66
|
-
function removeDiscountAction(){
|
|
67
|
+
function removeDiscountAction(key){
|
|
67
68
|
state.loading=true
|
|
68
|
-
removeDiscount()
|
|
69
|
+
removeDiscount(key)
|
|
69
70
|
.then(async (resp) => {
|
|
70
71
|
state.loading=false
|
|
71
|
-
state.alert.msg =
|
|
72
|
+
state.alert.msg = $t('viur.shop.discount_removed');
|
|
72
73
|
state.alert.show = true;
|
|
73
74
|
state.alert.variant = "success";
|
|
74
75
|
})
|
package/src/composables/cart.js
CHANGED
|
@@ -48,6 +48,7 @@ export function useCart() {
|
|
|
48
48
|
shopStore.state.cartReady = true;
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
|
+
shopStore.state.discounts = {}
|
|
51
52
|
return fetchCartRoot().then(() => {
|
|
52
53
|
if (!shopStore.state.cartRoot?.["key"]) return 0;
|
|
53
54
|
fetchCartItems(shopStore.state.cartRoot["key"]).then(() => { // TODO: duplicate code
|
|
@@ -59,10 +60,12 @@ export function useCart() {
|
|
|
59
60
|
|
|
60
61
|
function fetchCartRoot(){
|
|
61
62
|
// fetch list of Rootnodes and saves the first one
|
|
62
|
-
|
|
63
63
|
return Request.get(`${shopStore.state.shopUrl}/cart/listRootNodes`).then(async (resp)=>{
|
|
64
64
|
let data = await resp.clone().json()
|
|
65
65
|
shopStore.state.cartRoot = data.filter(i=>i['cart_type']==='basket')?.[0] ? data.filter(i=>i['cart_type']==='basket')[0]:[]
|
|
66
|
+
if (shopStore.state.cartRoot.discount){
|
|
67
|
+
shopStore.state.discounts = {[shopStore.state.cartRoot.discount.dest.key]:shopStore.state.cartRoot.discount}
|
|
68
|
+
}
|
|
66
69
|
return resp
|
|
67
70
|
})
|
|
68
71
|
}
|
|
@@ -82,6 +85,9 @@ export function useCart() {
|
|
|
82
85
|
if (item["skel_type"]==="leaf"){
|
|
83
86
|
currentLeafs.push(item)
|
|
84
87
|
}else{
|
|
88
|
+
if(item.discount){
|
|
89
|
+
shopStore.state.discounts[item.discount.dest.key] = item.discount
|
|
90
|
+
}
|
|
85
91
|
await fetchCartItems(item['key'])
|
|
86
92
|
}
|
|
87
93
|
}
|
|
@@ -168,11 +174,11 @@ export function useCart() {
|
|
|
168
174
|
});
|
|
169
175
|
}
|
|
170
176
|
|
|
171
|
-
function removeDiscount() {
|
|
177
|
+
function removeDiscount(key) {
|
|
172
178
|
return new Promise((resolve, reject) => {
|
|
173
179
|
Request.securePost(`${shopStore.state.shopApiUrl}/discount_remove`, {
|
|
174
180
|
dataObj: {
|
|
175
|
-
discount_key:
|
|
181
|
+
discount_key: key,
|
|
176
182
|
},
|
|
177
183
|
})
|
|
178
184
|
.then(async (resp) => {
|
package/src/shop.js
CHANGED
|
@@ -122,7 +122,8 @@ export const useViurShopStore = defineStore("viurshopStore", () => {
|
|
|
122
122
|
|
|
123
123
|
//checkout
|
|
124
124
|
paymentProviderData:null,
|
|
125
|
-
UserDataLayout: shallowRef(AddressFormLayout)
|
|
125
|
+
UserDataLayout: shallowRef(AddressFormLayout),
|
|
126
|
+
discounts:{}
|
|
126
127
|
})
|
|
127
128
|
|
|
128
129
|
function addTab({name, component, displayname, iconname, iconlibrary,active})
|
package/src/translations/de.js
CHANGED
|
@@ -43,6 +43,7 @@ export default {
|
|
|
43
43
|
'summary_total': 'Gesamtbetrag',
|
|
44
44
|
'summary_vat': 'inkl. {percentage} MwSt.',
|
|
45
45
|
'discount_not_found': 'Dieser Rabattcode existiert nicht.',
|
|
46
|
+
'discount_not_found': 'Rabattcode entfernt.',
|
|
46
47
|
'discount_not_active': 'Dieser Rabattcode ist nicht aktiv.',
|
|
47
48
|
'discount_not_available': 'Dieser Rabattcode ist für dieses Land nicht verfügbar.',
|
|
48
49
|
'discount_already_used': 'Dieser Rabattcode wurde bereits benutzt.',
|
package/src/translations/fr.js
CHANGED
|
@@ -43,6 +43,7 @@ export default {
|
|
|
43
43
|
'summary_total': 'Montant TTC',
|
|
44
44
|
'summary_vat': 'TVA incluse ({percentage})',
|
|
45
45
|
'discount_not_found': 'Ce code promo n’existe pas.',
|
|
46
|
+
'discount_removed': 'Code promo supprimé.',
|
|
46
47
|
'discount_not_active': 'Ce code promo n’est pas actif.',
|
|
47
48
|
'discount_not_available': 'Ce code promo n’est pas valable pour ce pays.',
|
|
48
49
|
'discount_already_used': 'Ce code promo a déjà été utilisé.',
|