@viur/shop-components 0.0.1-dev.60 → 0.0.1-dev.61
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/old/client/HttpClient.js +111 -0
- package/old/client/ViURShopClient.js +472 -0
- package/old/client/index.js +23 -0
- package/old/client/types.js +10 -0
- package/old/components/ExampleUsage.vue +95 -0
- package/old/components/ShopCart.vue +91 -0
- package/old/components/ShopOrderConfirm.vue +311 -0
- package/{src → old}/components/ShopOrderStepper.vue +111 -23
- package/old/components/ShopPaymentProvider.vue +113 -0
- package/old/components/ShopShippingMethod.vue +52 -0
- package/{src/components/ui → old/components}/ShopSummary.vue +28 -35
- package/{src → old}/components/ShopUserData.vue +51 -65
- package/{src → old}/components/cart/CartLeafModel.vue +24 -16
- package/{src → old}/components/cart/CartNode.vue +1 -0
- package/{src → old}/components/cart/CartTree.vue +13 -0
- package/old/components/cart/CartView.vue +82 -0
- package/{src → old}/components/cart/Discount.vue +8 -8
- package/old/components/generic/loadinghandler.vue +76 -0
- package/old/components/paymentProvider/prepayment.vue +0 -0
- package/old/components/paymentProvider/unzerPayment.vue +140 -0
- package/old/components/simple/ShopUserData.vue +161 -0
- package/old/components/simple/SimpleDefaultLayout.vue +116 -0
- package/old/components/ui/generic/CardSelector.vue +52 -0
- package/old/components/ui/generic/CartList.vue +69 -0
- package/old/components/ui/generic/ShippingInfo.vue +56 -0
- package/old/components/ui/generic/alerts/ShopAlert.vue +30 -0
- package/old/components/ui/payment/PaymentOption.vue +79 -0
- package/old/components/ui/payment/PaymentSelector.vue +158 -0
- package/old/components/ui/stepper/StepperItem.vue +90 -0
- package/{src → old}/components/ui/stepper/StepperTab.vue +30 -2
- package/old/components/ui/stepper/StepperTrigger.vue +69 -0
- package/old/components/ui/userdata/AddForm.vue +160 -0
- package/old/components/ui/userdata/AddressBox.vue +137 -0
- package/{src → old}/components/ui/userdata/BaseLayout.vue +15 -32
- package/old/stores/address.js +122 -0
- package/old/stores/cart.js +266 -0
- package/old/stores/message.js +21 -0
- package/old/stores/order.js +202 -0
- package/old/stores/payment.js +79 -0
- package/old/stores/shipping.js +78 -0
- package/package.json +3 -5
- package/src/Shop.vue +212 -0
- package/src/ShopOrderStepper.vue +89 -0
- package/src/ShopSummary.vue +170 -0
- package/src/Steps/ShopCart.vue +60 -0
- package/src/Steps/ShopOrderComplete.vue +24 -0
- package/src/Steps/ShopOrderConfirm.vue +295 -0
- package/src/Steps/ShopPaymentProvider.vue +53 -0
- package/src/Steps/ShopShippingMethod.vue +53 -0
- package/src/Steps/ShopUserDataGuest.vue +78 -0
- package/src/Steps/index.js +15 -0
- package/src/components/AddressForm.vue +84 -0
- package/src/components/AddressFormLayout.vue +107 -0
- package/src/components/CardSelector.vue +68 -0
- package/src/components/CartItem.vue +325 -0
- package/src/components/CartItemSmall.vue +257 -0
- package/src/components/LoadingHandler.vue +76 -0
- package/src/components/PaymentOption.vue +78 -0
- package/src/components/PaymentProviderUnzer.vue +201 -0
- package/src/components/PaymentSelector.vue +55 -0
- package/src/components/ShopAlert.vue +30 -0
- package/src/components/StepperTab.vue +132 -0
- package/src/components/dialogButton.vue +49 -0
- package/src/composables/address.js +95 -0
- package/src/composables/cart.js +132 -0
- package/src/composables/order.js +80 -0
- package/src/composables/payment.js +75 -0
- package/src/composables/shipping.js +32 -0
- package/src/main.js +32 -38
- package/src/shop.js +251 -0
- package/src/translations/de.js +15 -0
- package/src/translations/en.js +5 -0
- package/src/utils.js +49 -0
- package/vite.config.js +0 -2
- package/src/components/ShopCart.vue +0 -512
- package/src/components/ShopOrderConfirm.vue +0 -291
- package/src/components/cart/CartView.vue +0 -723
- package/src/components/order/OrderSidebar.vue +0 -102
- package/src/components/order/category/CategoryList.vue +0 -83
- package/src/components/order/category/CategoryView.vue +0 -143
- package/src/components/order/information/adress/ShippingAdress.vue +0 -143
- package/src/components/order/item/ItemCard.vue +0 -168
- package/src/components/order/item/ItemView.vue +0 -232
- package/src/components/order/process/ConfirmView.vue +0 -312
- package/src/components/order/process/ExampleUsage.vue +0 -113
- package/src/components/order/process/OrderTabHeader.vue +0 -16
- package/src/components/order/process/SelectPaymentProvider.vue +0 -62
- package/src/components/order/process/Shipping.vue +0 -46
- package/src/components/ui/generic/ArticleList.vue +0 -222
- package/src/components/ui/generic/ExamplePagination.vue +0 -236
- package/src/components/ui/generic/alerts/ShopAlert.vue +0 -19
- package/src/components/ui/generic/makeData.js +0 -39
- package/src/components/ui/stepper/StepperItem.vue +0 -39
- package/src/components/ui/stepper/StepperTrigger.vue +0 -35
- package/src/components/ui/userdata/AddForm.vue +0 -125
- package/src/components/ui/userdata/AddressBox.vue +0 -117
- package/src/router/index.js +0 -103
- package/src/stores/cart.js +0 -336
- package/src/views/ViewMissing.vue +0 -20
- /package/{src → old}/components/ShopOrderComplete.vue +0 -0
- /package/{src → old}/components/cart/CartLeaf.vue +0 -0
- /package/{src → old}/components/cart/CartTreeWrapper.vue +0 -0
- /package/{src/components/lib/utils.js → old/components/paymentProvider/paypalplus.vue} +0 -0
- /package/{src → old}/components/ui/generic/ShopPriceFormatter.vue +0 -0
- /package/{src → old}/components/ui/userdata/CustomBooleanBone.vue +0 -0
- /package/{src → old}/components/ui/userdata/CustomSelectBone.vue +0 -0
- /package/{src → old}/components/ui/userdata/CustomStringBone.vue +0 -0
- /package/{src → old}/components/ui/userdata/DefaultLayout.vue +0 -0
- /package/{src → old}/components/ui/userdata/SelectAddress.vue +0 -0
- /package/{src → old}/components/ui/userdata/multi/ActionBar.vue +0 -0
- /package/{src → old}/components/ui/userdata/multi/CartSelection.vue +0 -0
- /package/{src/style → old}/ignite/.editorconfig +0 -0
- /package/{src/style → old}/ignite/.github/workflows/ignite.yml +0 -0
- /package/{src/style → old}/ignite/.github/workflows/node.yml +0 -0
- /package/{src/style → old}/ignite/.postcssrc.cjs +0 -0
- /package/{src/style → old}/ignite/CHANGELOG.md +0 -0
- /package/{src/style → old}/ignite/LICENSE +0 -0
- /package/{src/style → old}/ignite/README.md +0 -0
- /package/{src/style → old}/ignite/dist/ignite.css +0 -0
- /package/{src/style → old}/ignite/dist/ignite.min.css +0 -0
- /package/{src/style → old}/ignite/foundation/basic.css +0 -0
- /package/{src/style → old}/ignite/foundation/color.css +0 -0
- /package/{src/style → old}/ignite/foundation/config.css +0 -0
- /package/{src/style → old}/ignite/foundation/grid.css +0 -0
- /package/{src/style → old}/ignite/foundation/mediaqueries.css +0 -0
- /package/{src/style → old}/ignite/foundation/reset.css +0 -0
- /package/{src/style → old}/ignite/ignite.css +0 -0
- /package/{src/style → old}/ignite/ignite.css.map +0 -0
- /package/{src/style → old}/ignite/package-lock.json +0 -0
- /package/{src/style → old}/ignite/package.json +0 -0
- /package/{src/style → old}/ignite/shoelace.css +0 -0
- /package/{src/style → old}/ignite/themes/dark.css +0 -0
- /package/{src/style → old}/ignite/themes/light.css +0 -0
- /package/{src/style → old}/ignite/utilities/shoelace.css +0 -0
- /package/{src/style → old}/ignite/utilities/utilities.css +0 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
class HTTPError extends Error {
|
|
2
|
+
constructor(code, statusText, message, response) {
|
|
3
|
+
super(message || statusText);
|
|
4
|
+
if (arguments.length >= 4 && response) {
|
|
5
|
+
Object.assign(this, response);
|
|
6
|
+
}
|
|
7
|
+
this.statusText = statusText;
|
|
8
|
+
this.statusCode = code;
|
|
9
|
+
this.response = response;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Wrapper for fetch.
|
|
15
|
+
* Inspired by https://kentcdodds.com/blog/replace-axios-with-a-simple-custom-fetch-wrapper
|
|
16
|
+
*
|
|
17
|
+
* @param {String} url The url of the ressource to fetch.
|
|
18
|
+
* @param {Object=} json Optional. Data used as json-serialized payload.
|
|
19
|
+
* @param {String=} method Optional. The HTTP method, e.g. POST. Default: GET (if json is unset).
|
|
20
|
+
* @param {Object=} params Optional. Params used as body for POST and get-query-String for others.
|
|
21
|
+
* @param {Object=} customConfig Some custom values for the fetch call.
|
|
22
|
+
* @returns {Promise<Response>} Returns the raw request a promise, or throws a HTTPError.
|
|
23
|
+
*/
|
|
24
|
+
function request(url, {json, method, params, ...customConfig} = {}) {
|
|
25
|
+
if (!method) {
|
|
26
|
+
method = json ? 'POST' : 'GET'
|
|
27
|
+
}
|
|
28
|
+
const config = {
|
|
29
|
+
credentials: 'include',
|
|
30
|
+
method: method,
|
|
31
|
+
headers: {
|
|
32
|
+
...customConfig.headers,
|
|
33
|
+
},
|
|
34
|
+
...customConfig,
|
|
35
|
+
}
|
|
36
|
+
if (url.startsWith('/') || url.startsWith(window.location.origin)) {
|
|
37
|
+
// TODO: Additional headers causes CORS problems
|
|
38
|
+
// and preflight OPTION requests are not working with the current viur-core
|
|
39
|
+
config.headers['X-Requested-With'] = 'Fetch';
|
|
40
|
+
}
|
|
41
|
+
if (json) {
|
|
42
|
+
config.body = JSON.stringify(json);
|
|
43
|
+
config.headers['Content-Type'] = 'application/json';
|
|
44
|
+
} else if (params && method === 'POST') {
|
|
45
|
+
if (typeof params === 'string' || params instanceof String) {
|
|
46
|
+
// provided a query string, e.g.: foo=1&bar=2
|
|
47
|
+
config.body = new URLSearchParams(params);
|
|
48
|
+
} else if (params instanceof HTMLFormElement) {
|
|
49
|
+
// provided a HTML form element
|
|
50
|
+
config.body = new FormData(params);
|
|
51
|
+
} else {
|
|
52
|
+
// provided a object, e.g.: {foo: 1, bar: 2, baz: [3, 4]}
|
|
53
|
+
config.body = new FormData();
|
|
54
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
55
|
+
if (Array.isArray(value)) {
|
|
56
|
+
for (const val of value) {
|
|
57
|
+
config.body.append(key, val)
|
|
58
|
+
}
|
|
59
|
+
} else {
|
|
60
|
+
config.body.append(key, value)
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (params && (method === 'GET' || json)) {
|
|
66
|
+
const getParams = new URLSearchParams(params)
|
|
67
|
+
url += `?${getParams.toString()}`;
|
|
68
|
+
}
|
|
69
|
+
return window
|
|
70
|
+
.fetch(url, config)
|
|
71
|
+
.then(async response => {
|
|
72
|
+
if (response.ok || (config.mode === 'no-cors' && response.type === 'opaque')) {
|
|
73
|
+
return response
|
|
74
|
+
} else {
|
|
75
|
+
const errorMessage = `${response.status} ${response.statusText}: ${response.headers.get('x-viur-error')}`
|
|
76
|
+
return Promise.reject(new HTTPError(response.status, response.statusText, errorMessage, response))
|
|
77
|
+
}
|
|
78
|
+
}).catch((error) => {
|
|
79
|
+
const errorMessage = `${error.statusCode} ${error.statusText}: ${error.response.headers.get('x-viur-error')}`
|
|
80
|
+
return Promise.reject(new HTTPError(error.statusCode, error.statusText, errorMessage, error))
|
|
81
|
+
})
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Return a new skey.
|
|
86
|
+
* @returns {Promise<String>} The resolved json-Promise (the skey).
|
|
87
|
+
*/
|
|
88
|
+
function getSkey() {
|
|
89
|
+
return request('/json/skey')
|
|
90
|
+
.then(request => request.json())
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Shows a alert with an error-message.
|
|
95
|
+
* @param {any} error The exception. Could be an instance of HTTPError or any other error/value.
|
|
96
|
+
*/
|
|
97
|
+
function errorHandler(error) {
|
|
98
|
+
console.error(error);
|
|
99
|
+
let headline = `Error`;
|
|
100
|
+
if (error instanceof HTTPError) {
|
|
101
|
+
headline += ` ${error.statusCode} ${error.statusText}`;
|
|
102
|
+
}
|
|
103
|
+
alert(
|
|
104
|
+
`Sorry, an unexpected error occurred.
|
|
105
|
+
${headline}
|
|
106
|
+
${error}
|
|
107
|
+
Please try again our contact our customer service.`,
|
|
108
|
+
)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export {HTTPError, request, getSkey, errorHandler};
|
|
@@ -0,0 +1,472 @@
|
|
|
1
|
+
import {getSkey, request} from './HttpClient.js';
|
|
2
|
+
|
|
3
|
+
// Note: Order of functions should always be RCUD (this is NOT a typo of CRUD!)
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* ViUR Shop Client
|
|
7
|
+
*/
|
|
8
|
+
export class ViURShopClient {
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* URL to the shop-backend (ViUR server)
|
|
12
|
+
*/
|
|
13
|
+
host_url;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Name of the shop root module
|
|
17
|
+
*/
|
|
18
|
+
shop_module;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* URL to shop root module with the default renderer
|
|
22
|
+
*/
|
|
23
|
+
shop_url;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* URL to shop root module with the json renderer
|
|
27
|
+
*/
|
|
28
|
+
shop_json_url;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* URL to shop API module with the default renderer
|
|
32
|
+
*/
|
|
33
|
+
shop_api_url;
|
|
34
|
+
|
|
35
|
+
constructor({
|
|
36
|
+
host_url = null,
|
|
37
|
+
shop_module = 'shop',
|
|
38
|
+
} = {}) {
|
|
39
|
+
if (host_url === null) {
|
|
40
|
+
try {
|
|
41
|
+
this.host_url = import.meta.env.VITE_API_URL ? import.meta.env.VITE_API_URL : window.location.origin;
|
|
42
|
+
} catch (e) {
|
|
43
|
+
// The import crashes in a bundled runtime
|
|
44
|
+
this.host_url = window.location.origin;
|
|
45
|
+
}
|
|
46
|
+
} else {
|
|
47
|
+
this.host_url = host_url;
|
|
48
|
+
}
|
|
49
|
+
this.shop_module = shop_module;
|
|
50
|
+
this.shop_url = `${this.host_url}/${this.shop_module}`;
|
|
51
|
+
this.shop_json_url = `${this.host_url}/json/${this.shop_module}`;
|
|
52
|
+
this.shop_api_url = `${this.shop_url}/api`;
|
|
53
|
+
this.getStructure_url = `${this.host_url}/vi/getStructure`;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
// --- Article ------------------------------------------------------------
|
|
58
|
+
|
|
59
|
+
article_view({
|
|
60
|
+
article_key,
|
|
61
|
+
parent_cart_key,
|
|
62
|
+
} = {}) {
|
|
63
|
+
return request(`${this.shop_api_url}/article_view`, {
|
|
64
|
+
params: {
|
|
65
|
+
'article_key': article_key,
|
|
66
|
+
'parent_cart_key': parent_cart_key,
|
|
67
|
+
},
|
|
68
|
+
})
|
|
69
|
+
.then(req => req.json());
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
article_add({
|
|
74
|
+
article_key,
|
|
75
|
+
parent_cart_key,
|
|
76
|
+
quantity = 1,
|
|
77
|
+
quantity_mode = 'increase',
|
|
78
|
+
} = {}) {
|
|
79
|
+
return request(`${this.shop_api_url}/article_add`, {
|
|
80
|
+
method: 'POST',
|
|
81
|
+
params: {
|
|
82
|
+
article_key,
|
|
83
|
+
parent_cart_key,
|
|
84
|
+
quantity,
|
|
85
|
+
quantity_mode,
|
|
86
|
+
},
|
|
87
|
+
})
|
|
88
|
+
.then(req => req.json());
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
article_update({
|
|
92
|
+
article_key,
|
|
93
|
+
parent_cart_key,
|
|
94
|
+
quantity = 1,
|
|
95
|
+
quantity_mode = 'increase',
|
|
96
|
+
} = {}) {
|
|
97
|
+
return request(`${this.shop_api_url}/article_update`, {
|
|
98
|
+
method: 'POST',
|
|
99
|
+
params: {
|
|
100
|
+
article_key,
|
|
101
|
+
parent_cart_key,
|
|
102
|
+
quantity,
|
|
103
|
+
quantity_mode,
|
|
104
|
+
},
|
|
105
|
+
})
|
|
106
|
+
.then(req => req.json());
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
article_remove({
|
|
111
|
+
article_key,
|
|
112
|
+
parent_cart_key,
|
|
113
|
+
} = {}) {
|
|
114
|
+
return request(`${this.shop_api_url}/article_remove`, {
|
|
115
|
+
method: 'POST',
|
|
116
|
+
params: {
|
|
117
|
+
article_key,
|
|
118
|
+
parent_cart_key,
|
|
119
|
+
},
|
|
120
|
+
})
|
|
121
|
+
.then(req => req.json());
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// --- Basket ---------------------------------------------------------------
|
|
125
|
+
basket_list() {
|
|
126
|
+
return request(`${this.shop_api_url}/basket_list`).then(req => req.json());
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// --- Cart ---------------------------------------------------------------
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* List root nodes or children of a cart
|
|
133
|
+
*
|
|
134
|
+
* If a cart key is provided, the direct children (nodes and leafs) will
|
|
135
|
+
* be returned.
|
|
136
|
+
* Otherwise (without a key), the root nodes will be returned.
|
|
137
|
+
*
|
|
138
|
+
* @param {string} cart_key list direct children (nodes and leafs) of this parent node
|
|
139
|
+
* @returns {Promise<Response>}
|
|
140
|
+
*/
|
|
141
|
+
cart_list({cart_key = null} = {}) {
|
|
142
|
+
const self = this;
|
|
143
|
+
return request(`${this.shop_api_url}/cart_list`, {
|
|
144
|
+
params: cart_key === null ? {} : {cart_key},
|
|
145
|
+
})
|
|
146
|
+
.then(req => req.json());
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Add a new cart node
|
|
151
|
+
*
|
|
152
|
+
* @param {string} parent_cart_key Key of the parent cart
|
|
153
|
+
* @param {CartType} cart_type Type of the cart node, see `CartType`
|
|
154
|
+
* @param {string=} name Optional. Name of the cart node
|
|
155
|
+
* @param {string=} customer_comment Optional. Comment to this node, by customer.
|
|
156
|
+
* @param {string=} shipping_address_key Optional. Key of the address
|
|
157
|
+
* @param {string=} shipping_key Optional. Key of the shipping
|
|
158
|
+
* @param {string=} discount_key Optional. Key of the discount
|
|
159
|
+
* @returns {Promise<Response>}
|
|
160
|
+
*/
|
|
161
|
+
cart_add({
|
|
162
|
+
parent_cart_key,
|
|
163
|
+
cart_type,
|
|
164
|
+
name,
|
|
165
|
+
customer_comment,
|
|
166
|
+
shipping_address_key,
|
|
167
|
+
shipping_key,
|
|
168
|
+
discount_key,
|
|
169
|
+
} = {}) {
|
|
170
|
+
return request(`${this.shop_api_url}/cart_add`, {
|
|
171
|
+
method: 'POST',
|
|
172
|
+
params: this.removeUndefinedValues({
|
|
173
|
+
parent_cart_key,
|
|
174
|
+
name,
|
|
175
|
+
cart_type,
|
|
176
|
+
customer_comment,
|
|
177
|
+
shipping_address_key,
|
|
178
|
+
shipping_key,
|
|
179
|
+
discount_key,
|
|
180
|
+
}),
|
|
181
|
+
})
|
|
182
|
+
.then(req => req.json());
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Update an existing cart node
|
|
187
|
+
*
|
|
188
|
+
* @param {string} cart_key Key of the cart node to be updated
|
|
189
|
+
* @param {CartType} cart_type Type of the cart node, see `CartType`
|
|
190
|
+
* @param {string=} name Optional. Name of the cart node
|
|
191
|
+
* @param {string=} customer_comment Optional. Comment to this node, by customer.
|
|
192
|
+
* @param {string=} shipping_address_key Optional. Key of the address
|
|
193
|
+
* @param {string=} shipping_key Optional. Key of the shipping
|
|
194
|
+
* @param {string=} discount_key Optional. Key of the discount
|
|
195
|
+
* @returns {Promise<Response>}
|
|
196
|
+
*/
|
|
197
|
+
cart_update({
|
|
198
|
+
cart_key,
|
|
199
|
+
cart_type,
|
|
200
|
+
name,
|
|
201
|
+
customer_comment,
|
|
202
|
+
shipping_address_key,
|
|
203
|
+
shipping_key,
|
|
204
|
+
discount_key,
|
|
205
|
+
} = {}) {
|
|
206
|
+
return request(`${this.shop_api_url}/cart_update`, {
|
|
207
|
+
method: 'POST',
|
|
208
|
+
params: this.removeUndefinedValues({
|
|
209
|
+
cart_key,
|
|
210
|
+
cart_type,
|
|
211
|
+
name,
|
|
212
|
+
customer_comment,
|
|
213
|
+
shipping_address_key,
|
|
214
|
+
shipping_key,
|
|
215
|
+
discount_key,
|
|
216
|
+
}),
|
|
217
|
+
})
|
|
218
|
+
.then(req => req.json());
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Remove a cart node.
|
|
223
|
+
* Removes itself and all children
|
|
224
|
+
*
|
|
225
|
+
* @param {string} cart_key Key of the cart node to be removed
|
|
226
|
+
* @returns {Promise<Response>}
|
|
227
|
+
*/
|
|
228
|
+
cart_remove({cart_key} = {}) {
|
|
229
|
+
return request(`${this.shop_api_url}/cart_remove`, {
|
|
230
|
+
method: 'POST',
|
|
231
|
+
params: {
|
|
232
|
+
cart_key,
|
|
233
|
+
},
|
|
234
|
+
})
|
|
235
|
+
.then(req => req.json());
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
cart_structure() {
|
|
239
|
+
return request(`${this.getStructure_url}/${this.shop_module}.cart`, {
|
|
240
|
+
method: 'GET',
|
|
241
|
+
})
|
|
242
|
+
.then(req => req.json());
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// --- Address ------------------------------------------------------------
|
|
246
|
+
|
|
247
|
+
address_list({} = {}) {
|
|
248
|
+
const self = this;
|
|
249
|
+
return request(`${this.shop_json_url}/address/list`, {
|
|
250
|
+
params: {
|
|
251
|
+
limit: 100,
|
|
252
|
+
},
|
|
253
|
+
})
|
|
254
|
+
.then(req => req.json())
|
|
255
|
+
.then(response => response.skellist);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
address_add({
|
|
259
|
+
customer_type,
|
|
260
|
+
salutation,
|
|
261
|
+
company_name,
|
|
262
|
+
firstname,
|
|
263
|
+
lastname,
|
|
264
|
+
street_name,
|
|
265
|
+
street_number,
|
|
266
|
+
address_addition,
|
|
267
|
+
zip_code,
|
|
268
|
+
city,
|
|
269
|
+
country,
|
|
270
|
+
customer_key,
|
|
271
|
+
is_default,
|
|
272
|
+
address_type,
|
|
273
|
+
} = {}) {
|
|
274
|
+
return getSkey()
|
|
275
|
+
.then(skey => {
|
|
276
|
+
return request(`${this.shop_json_url}/address/add`, {
|
|
277
|
+
method: 'POST',
|
|
278
|
+
params: this.removeUndefinedValues({
|
|
279
|
+
skey,
|
|
280
|
+
customer_type,
|
|
281
|
+
salutation,
|
|
282
|
+
company_name,
|
|
283
|
+
firstname,
|
|
284
|
+
lastname,
|
|
285
|
+
street_name,
|
|
286
|
+
street_number,
|
|
287
|
+
address_addition,
|
|
288
|
+
zip_code,
|
|
289
|
+
city,
|
|
290
|
+
country,
|
|
291
|
+
customer: customer_key,
|
|
292
|
+
is_default,
|
|
293
|
+
address_type,
|
|
294
|
+
}),
|
|
295
|
+
})
|
|
296
|
+
.then(req => req.json())
|
|
297
|
+
.then(response => response.values);
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
address_structure() {
|
|
302
|
+
return request(`${this.shop_json_url}/address/structure`, {
|
|
303
|
+
method: 'GET',
|
|
304
|
+
})
|
|
305
|
+
.then(req => req.json());
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
// --- Order --------------------------------------------------------------
|
|
309
|
+
|
|
310
|
+
payment_providers_list({} = {}) {
|
|
311
|
+
return request(`${this.shop_url}/order/payment_providers_list`)
|
|
312
|
+
.then(req => req.json());
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
order_add({
|
|
316
|
+
cart_key,
|
|
317
|
+
payment_provider,
|
|
318
|
+
billing_address_key,
|
|
319
|
+
email,
|
|
320
|
+
customer_key,
|
|
321
|
+
state_ordered,
|
|
322
|
+
state_paid,
|
|
323
|
+
state_rts,
|
|
324
|
+
} = {}) {
|
|
325
|
+
return request(`${this.shop_api_url}/order_add`, {
|
|
326
|
+
method: 'POST',
|
|
327
|
+
params: this.removeUndefinedValues({
|
|
328
|
+
cart_key,
|
|
329
|
+
payment_provider,
|
|
330
|
+
billing_address_key,
|
|
331
|
+
email,
|
|
332
|
+
customer_key,
|
|
333
|
+
state_ordered,
|
|
334
|
+
state_paid,
|
|
335
|
+
state_rts,
|
|
336
|
+
}),
|
|
337
|
+
})
|
|
338
|
+
.then(req => req.json());
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
order_update({
|
|
342
|
+
order_key,
|
|
343
|
+
payment_provider,
|
|
344
|
+
billing_address_key,
|
|
345
|
+
email,
|
|
346
|
+
customer_key,
|
|
347
|
+
state_ordered,
|
|
348
|
+
state_paid,
|
|
349
|
+
state_rts,
|
|
350
|
+
} = {}) {
|
|
351
|
+
return request(`${this.shop_api_url}/order_update`, {
|
|
352
|
+
method: 'POST',
|
|
353
|
+
params: this.removeUndefinedValues({
|
|
354
|
+
order_key,
|
|
355
|
+
payment_provider,
|
|
356
|
+
billing_address_key,
|
|
357
|
+
email,
|
|
358
|
+
customer_key,
|
|
359
|
+
state_ordered,
|
|
360
|
+
state_paid,
|
|
361
|
+
state_rts,
|
|
362
|
+
}),
|
|
363
|
+
})
|
|
364
|
+
.then(req => req.json());
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
order_checkout_start({
|
|
368
|
+
order_key,
|
|
369
|
+
} = {}) {
|
|
370
|
+
return request(`${this.shop_url}/order/checkout_start`, {
|
|
371
|
+
method: 'POST',
|
|
372
|
+
params: {order_key},
|
|
373
|
+
})
|
|
374
|
+
.then(req => req.json());
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
order_checkout_order({
|
|
378
|
+
order_key,
|
|
379
|
+
} = {}) {
|
|
380
|
+
return request(`${this.shop_url}/order/checkout_order`, {
|
|
381
|
+
method: 'POST',
|
|
382
|
+
params: {order_key},
|
|
383
|
+
})
|
|
384
|
+
.then(req => req.json());
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
order_pp_get_settings({
|
|
388
|
+
order_key,
|
|
389
|
+
} = {}) {
|
|
390
|
+
return request(`${this.shop_url}/order/checkout_order`, {
|
|
391
|
+
method: 'POST',
|
|
392
|
+
params: {order_key},
|
|
393
|
+
})
|
|
394
|
+
.then(req => req.json());
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
|
|
398
|
+
// --- User ---------------------------------------------------------------
|
|
399
|
+
|
|
400
|
+
user_view({
|
|
401
|
+
user_key = 'self',
|
|
402
|
+
} = {}) {
|
|
403
|
+
return request(`${this.host_url}/json/user/view/${user_key}`)
|
|
404
|
+
.then(req => req.json())
|
|
405
|
+
.then(response => response.values);
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
// --- Discount -----------------------------------------------------------
|
|
410
|
+
/**
|
|
411
|
+
* Add a Discount to the current Cart.
|
|
412
|
+
* @param {string} code Human readable Discount Code
|
|
413
|
+
* @param {string} discount_key Database Key from a Discount.
|
|
414
|
+
* @returns {Response<Response>}
|
|
415
|
+
*/
|
|
416
|
+
discount_add({
|
|
417
|
+
code,
|
|
418
|
+
discount_key,
|
|
419
|
+
} = {}) {
|
|
420
|
+
return request(`${this.shop_api_url}/discount_add`, {
|
|
421
|
+
method: 'POST',
|
|
422
|
+
params: this.removeUndefinedValues({
|
|
423
|
+
code,
|
|
424
|
+
discount_key,
|
|
425
|
+
}),
|
|
426
|
+
})
|
|
427
|
+
.then(req => req.json());
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* Removes a Discount by the Database Key
|
|
432
|
+
* @param {string} discount_key Database Key from a Discount.
|
|
433
|
+
* @returns {Promise<Response>}
|
|
434
|
+
*/
|
|
435
|
+
discount_remove({
|
|
436
|
+
discount_key,
|
|
437
|
+
} = {}) {
|
|
438
|
+
return request(`${this.shop_api_url}/discount_remove`, {
|
|
439
|
+
method: 'POST',
|
|
440
|
+
params: {discount_key},
|
|
441
|
+
})
|
|
442
|
+
.then(req => req.json());
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
// --- Shipping -----------------------------------------------------------
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* Lists available shipping options for a (sub)cart
|
|
450
|
+
* @param {string} cart_key Key of the parent cart
|
|
451
|
+
* @returns {Promise<Response>} List of ShippingsSkels
|
|
452
|
+
*/
|
|
453
|
+
shipping_list({
|
|
454
|
+
cart_key,
|
|
455
|
+
} = {}) {
|
|
456
|
+
return request(`${this.shop_api_url}/shipping_list`, {
|
|
457
|
+
method: 'GET',
|
|
458
|
+
params: {cart_key},
|
|
459
|
+
})
|
|
460
|
+
.then(req => req.json());
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
|
|
464
|
+
// --- Utils -------------------------------------------------------------
|
|
465
|
+
|
|
466
|
+
removeUndefinedValues(obj) {
|
|
467
|
+
return Object.fromEntries(
|
|
468
|
+
Object.entries(obj)
|
|
469
|
+
.filter(([key, value]) => value !== undefined),
|
|
470
|
+
);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
HTTPError,
|
|
3
|
+
request,
|
|
4
|
+
getSkey,
|
|
5
|
+
errorHandler,
|
|
6
|
+
} from './HttpClient.js'
|
|
7
|
+
import {
|
|
8
|
+
ViURShopClient,
|
|
9
|
+
} from './ViURShopClient.js'
|
|
10
|
+
import {
|
|
11
|
+
CartType,
|
|
12
|
+
CustomerType,
|
|
13
|
+
} from './types.js';
|
|
14
|
+
|
|
15
|
+
export {
|
|
16
|
+
HTTPError,
|
|
17
|
+
request,
|
|
18
|
+
getSkey,
|
|
19
|
+
errorHandler,
|
|
20
|
+
ViURShopClient,
|
|
21
|
+
CartType,
|
|
22
|
+
CustomerType,
|
|
23
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<sl-spinner v-if="!rootNode"></sl-spinner>
|
|
3
|
+
<shop-order-stepper
|
|
4
|
+
:tabs="state.tabs"
|
|
5
|
+
@tabChange="handleTabs"
|
|
6
|
+
:sidebar="true"
|
|
7
|
+
:sidebar-bottom="false"
|
|
8
|
+
:show-discount="true"
|
|
9
|
+
:custom-shipping-component="state.customShipping"
|
|
10
|
+
v-else
|
|
11
|
+
>
|
|
12
|
+
<!-- customize slots -->
|
|
13
|
+
<!-- <template #main> The Order Stepper </template> -->
|
|
14
|
+
<!-- <template #trigger> Buttons for Stepper control </template> -->
|
|
15
|
+
<!-- <template #sidebar> the side/bottom bar </template> -->
|
|
16
|
+
</shop-order-stepper>
|
|
17
|
+
</template>
|
|
18
|
+
|
|
19
|
+
<script setup>
|
|
20
|
+
import { onBeforeMount, reactive, shallowRef, computed } from "vue";
|
|
21
|
+
|
|
22
|
+
import ShopCart from "./ShopCart.vue";
|
|
23
|
+
import ShopOrderConfirm from "./ShopOrderConfirm.vue";
|
|
24
|
+
import ShopOrderStepper from "./ShopOrderStepper.vue";
|
|
25
|
+
import ShopOrderComplete from "./ShopOrderComplete.vue";
|
|
26
|
+
import ShopUserData from "./ShopUserData.vue";
|
|
27
|
+
import ShopPaymentProvider from "./ShopPaymentProvider.vue";
|
|
28
|
+
import ShopShippingMethod from "./ShopShippingMethod.vue";
|
|
29
|
+
|
|
30
|
+
import { useCartStore } from "../stores/cart";
|
|
31
|
+
|
|
32
|
+
const cartStore = useCartStore();
|
|
33
|
+
|
|
34
|
+
const rootNode = computed(() =>
|
|
35
|
+
cartStore.state.basket.key ? cartStore.state.basket.key : "",
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
const state = reactive({
|
|
39
|
+
tabs: {
|
|
40
|
+
cart: {
|
|
41
|
+
component: shallowRef(ShopCart),
|
|
42
|
+
displayName: "Warenkorb",
|
|
43
|
+
props: {
|
|
44
|
+
standalone: false,
|
|
45
|
+
cartKey: rootNode,
|
|
46
|
+
},
|
|
47
|
+
icon: { name: "bag" },
|
|
48
|
+
position: 1,
|
|
49
|
+
},
|
|
50
|
+
userData: {
|
|
51
|
+
component: shallowRef(ShopUserData),
|
|
52
|
+
props: {
|
|
53
|
+
multiMode: false,
|
|
54
|
+
},
|
|
55
|
+
displayName: "Daten Eingeben",
|
|
56
|
+
icon: { name: "card-list" },
|
|
57
|
+
position: 2, //reihfolge ändern
|
|
58
|
+
},
|
|
59
|
+
selectShippingMethod: {
|
|
60
|
+
component: shallowRef(ShopShippingMethod),
|
|
61
|
+
displayName: "Versandart wählen",
|
|
62
|
+
icon: { name: "truck" },
|
|
63
|
+
position: 3,
|
|
64
|
+
},
|
|
65
|
+
selectPaymentProvider: {
|
|
66
|
+
component: shallowRef(ShopPaymentProvider),
|
|
67
|
+
props: {},
|
|
68
|
+
displayName: "Zahlungsart auswählen",
|
|
69
|
+
icon: { name: "card-list" },
|
|
70
|
+
position: 4, //reihfolge ändern
|
|
71
|
+
},
|
|
72
|
+
orderConfirm: {
|
|
73
|
+
component: shallowRef(ShopOrderConfirm),
|
|
74
|
+
props: {},
|
|
75
|
+
displayName: "Bestellung prüfen",
|
|
76
|
+
icon: { name: "clipboard-check" },
|
|
77
|
+
position: 5,
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
orderComplete: {
|
|
81
|
+
component: shallowRef(ShopOrderComplete),
|
|
82
|
+
props: {},
|
|
83
|
+
displayName: "Bestellung Abgeschlossen",
|
|
84
|
+
icon: { name: "bag-check" },
|
|
85
|
+
position: 6,
|
|
86
|
+
showNext: false,
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
onBeforeMount(async () => {
|
|
92
|
+
await cartStore.setConfig("shop", "path/to/placeholder");
|
|
93
|
+
await cartStore.init(false, false);
|
|
94
|
+
});
|
|
95
|
+
</script>
|