@viur/shop-components 0.10.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/Steps/ShopCart.vue +1 -2
- package/src/components/DiscountInput.vue +14 -12
- package/src/composables/cart.js +23 -4
- package/src/shop.js +2 -1
- package/src/translations/de.js +2 -1
- package/src/translations/fr.js +2 -1
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>
|
package/src/Steps/ShopCart.vue
CHANGED
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
:nextfunction="nextStep"
|
|
6
6
|
>
|
|
7
7
|
</slot>
|
|
8
|
-
|
|
9
8
|
<loading-handler :isLoading="cartState.isLoading" :isUpdating="cartState.isUpdating">
|
|
10
9
|
<div class="viur-shop-item-wrapper" v-if="state.items.length>0">
|
|
11
10
|
<cart-item v-for="item in state.items" :item="item"
|
|
@@ -55,7 +54,7 @@ const props = defineProps({
|
|
|
55
54
|
})
|
|
56
55
|
|
|
57
56
|
const state = reactive({
|
|
58
|
-
items: computed(()=>shopStore.state.cartList
|
|
57
|
+
items: computed(()=>shopStore.state.cartList)
|
|
59
58
|
})
|
|
60
59
|
|
|
61
60
|
onBeforeMount(()=>{
|
|
@@ -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')"
|
|
@@ -36,9 +37,10 @@
|
|
|
36
37
|
import { reactive } from "vue";
|
|
37
38
|
import { useViurShopStore } from "../shop";
|
|
38
39
|
import { useCart } from '../composables/cart';
|
|
40
|
+
import {useI18n} from 'vue-i18n';
|
|
39
41
|
const shopStore = useViurShopStore();
|
|
40
42
|
const {addDiscount, removeDiscount} = useCart()
|
|
41
|
-
|
|
43
|
+
const i18n = useI18n();
|
|
42
44
|
import ShopAlert from "./ShopAlert.vue";
|
|
43
45
|
|
|
44
46
|
const state = reactive({
|
|
@@ -56,25 +58,25 @@ function addDiscountAction() {
|
|
|
56
58
|
.catch((error) => {
|
|
57
59
|
state.loading=false
|
|
58
60
|
console.log("error bei rabatt", error);
|
|
59
|
-
state.alert.msg =
|
|
61
|
+
state.alert.msg = i18n.t('viur.shop.discount_not_found');
|
|
60
62
|
state.alert.show = true;
|
|
61
63
|
state.alert.variant = "danger";
|
|
62
64
|
});
|
|
63
65
|
}
|
|
64
66
|
|
|
65
|
-
function removeDiscountAction(){
|
|
67
|
+
function removeDiscountAction(key){
|
|
66
68
|
state.loading=true
|
|
67
|
-
removeDiscount()
|
|
69
|
+
removeDiscount(key)
|
|
68
70
|
.then(async (resp) => {
|
|
69
71
|
state.loading=false
|
|
70
|
-
state.alert.msg =
|
|
72
|
+
state.alert.msg = $t('viur.shop.discount_removed');
|
|
71
73
|
state.alert.show = true;
|
|
72
74
|
state.alert.variant = "success";
|
|
73
75
|
})
|
|
74
76
|
.catch((error) => {
|
|
75
77
|
state.loading=false
|
|
76
78
|
console.log("error bei rabatt", error);
|
|
77
|
-
state.alert.msg =
|
|
79
|
+
state.alert.msg = $t('viur.shop.discount_not_found');
|
|
78
80
|
state.alert.show = true;
|
|
79
81
|
state.alert.variant = "danger";
|
|
80
82
|
});
|
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,21 +60,39 @@ 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
|
}
|
|
69
72
|
|
|
70
73
|
function fetchCartItems(key, parentKey=null){
|
|
71
74
|
//fetch cart items
|
|
75
|
+
if (key === shopStore.state.cartRoot["key"]){ // initial
|
|
76
|
+
shopStore.state.cartList = []
|
|
77
|
+
}
|
|
72
78
|
return Request.get(`${shopStore.state.shopApiUrl}/cart_list`,{dataObj:{
|
|
73
79
|
cart_key:key
|
|
74
80
|
}}).then(async( resp) =>{
|
|
75
81
|
let data = await resp.clone().json()
|
|
76
|
-
|
|
82
|
+
|
|
83
|
+
let currentLeafs = []
|
|
84
|
+
for (const item of data){
|
|
85
|
+
if (item["skel_type"]==="leaf"){
|
|
86
|
+
currentLeafs.push(item)
|
|
87
|
+
}else{
|
|
88
|
+
if(item.discount){
|
|
89
|
+
shopStore.state.discounts[item.discount.dest.key] = item.discount
|
|
90
|
+
}
|
|
91
|
+
await fetchCartItems(item['key'])
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
shopStore.state.cartList=shopStore.state.cartList.concat(currentLeafs)
|
|
77
96
|
return resp
|
|
78
97
|
})
|
|
79
98
|
}
|
|
@@ -155,11 +174,11 @@ export function useCart() {
|
|
|
155
174
|
});
|
|
156
175
|
}
|
|
157
176
|
|
|
158
|
-
function removeDiscount() {
|
|
177
|
+
function removeDiscount(key) {
|
|
159
178
|
return new Promise((resolve, reject) => {
|
|
160
179
|
Request.securePost(`${shopStore.state.shopApiUrl}/discount_remove`, {
|
|
161
180
|
dataObj: {
|
|
162
|
-
discount_key:
|
|
181
|
+
discount_key: key,
|
|
163
182
|
},
|
|
164
183
|
})
|
|
165
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
|
@@ -37,12 +37,13 @@ export default {
|
|
|
37
37
|
'summary_headline': 'Zusammenfassung',
|
|
38
38
|
'summary_subtotal': 'Zwischensumme',
|
|
39
39
|
'summary_shipping_total': 'Versand- und Bearbeitungspauschale',
|
|
40
|
-
'summary_delivery_time': 'Lieferzeit',
|
|
40
|
+
'summary_delivery_time': 'Voraussichtliche Lieferzeit',
|
|
41
41
|
'summary_discount': 'Sie sparen bei Ihrem Einkauf im Aktionszeitraum',
|
|
42
42
|
'summary_checkout': 'Zur Kasse gehen',
|
|
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
|
@@ -40,9 +40,10 @@ export default {
|
|
|
40
40
|
'summary_delivery_time': 'Délai de livraison estimé',
|
|
41
41
|
'summary_discount': 'Vous économisez sur votre achat',
|
|
42
42
|
'summary_checkout': 'Acheter cet article',
|
|
43
|
-
'summary_total': 'Montant
|
|
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é.',
|