kempo-commerce 0.1.0 → 0.1.2
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/admin/components/Settings.js +6 -1
- package/package.json +4 -4
- package/public/api/my/orders/[id]/GET.js +16 -16
- package/public/api/my/orders/[id]/cancel/POST.js +22 -22
- package/public/api/orders/[id]/guest/GET.js +13 -13
- package/public/api/orders/[id]/guest/cancel/POST.js +16 -16
- package/public/components/Checkout.js +669 -669
- package/public/components/checkoutSections.js +76 -76
- package/public/sdk.js +130 -130
- package/sdk.js +66 -66
- package/server/utils/checkout/tax.js +115 -115
|
@@ -48,7 +48,12 @@ export default class AdminSettings extends ShadowComponent {
|
|
|
48
48
|
|
|
49
49
|
connectedCallback(){
|
|
50
50
|
super.connectedCallback();
|
|
51
|
-
|
|
51
|
+
const pane = this.closest('k-tab-content');
|
|
52
|
+
// Loads when its tab is first opened, so a tab nobody opens makes no requests.
|
|
53
|
+
if(!pane || pane.active) this.load();
|
|
54
|
+
else this.closest('k-tabs')?.addEventListener('tabfirstshown', ({ detail }) => {
|
|
55
|
+
if(detail.tab === pane.name) this.load();
|
|
56
|
+
});
|
|
52
57
|
}
|
|
53
58
|
|
|
54
59
|
load = async () => {
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kempo-commerce",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Carts, orders and checkout for kempo: sells what kempo-products lists, takes payment through kempo-payments, and applies tax, store credit and credits when they are installed",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"author": "Dustin Poissant",
|
|
6
|
+
"author": "Dustin Poissant <dustinpoissant@gmail.com>",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "sdk.js",
|
|
9
9
|
"scripts": {
|
|
@@ -38,14 +38,14 @@
|
|
|
38
38
|
"drizzle-orm": "^0.45.2"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"kempo": ">=4.
|
|
41
|
+
"kempo": ">=4.9.6",
|
|
42
42
|
"kempo-credits": ">=0.3.0",
|
|
43
43
|
"kempo-payments": ">=0.4.0",
|
|
44
44
|
"kempo-products": ">=0.3.0",
|
|
45
45
|
"kempo-server": ">=3.3.0",
|
|
46
46
|
"kempo-store-credit": ">=0.1.0",
|
|
47
47
|
"kempo-tax": ">=0.3.0",
|
|
48
|
-
"kempo-ui": ">=0.6.
|
|
48
|
+
"kempo-ui": ">=0.6.2"
|
|
49
49
|
},
|
|
50
50
|
"peerDependenciesMeta": {
|
|
51
51
|
"kempo-credits": {
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { getOrderEvents } from '../../../../../server/utils/orders/events.js';
|
|
2
|
-
import { forCustomer } from '../../../../../server/utils/orders/read.js';
|
|
3
|
-
import withProductLinks from '../../../../../server/utils/orders/links.js';
|
|
4
|
-
import { customerOrder, refuse, requireSession } from '../../../../../server/http/gate.js';
|
|
5
|
-
|
|
6
|
-
/* One of the signed-in customer's orders, with the history they are meant to see. */
|
|
7
|
-
export default async (request, response) => {
|
|
8
|
-
const [sessionError] = await requireSession(request);
|
|
9
|
-
if(sessionError) return refuse(response, sessionError);
|
|
10
|
-
|
|
11
|
-
const [error, access] = await customerOrder(request, request.params.id, null);
|
|
12
|
-
if(error) return refuse(response, error);
|
|
13
|
-
|
|
14
|
-
const [, events] = await getOrderEvents(access.order.id, { customerVisibleOnly: true });
|
|
15
|
-
response.json({ order: await withProductLinks(forCustomer(access.order)), events: events ?? [] });
|
|
16
|
-
};
|
|
1
|
+
import { getOrderEvents } from '../../../../../server/utils/orders/events.js';
|
|
2
|
+
import { forCustomer } from '../../../../../server/utils/orders/read.js';
|
|
3
|
+
import withProductLinks from '../../../../../server/utils/orders/links.js';
|
|
4
|
+
import { customerOrder, refuse, requireSession } from '../../../../../server/http/gate.js';
|
|
5
|
+
|
|
6
|
+
/* One of the signed-in customer's orders, with the history they are meant to see. */
|
|
7
|
+
export default async (request, response) => {
|
|
8
|
+
const [sessionError] = await requireSession(request);
|
|
9
|
+
if(sessionError) return refuse(response, sessionError);
|
|
10
|
+
|
|
11
|
+
const [error, access] = await customerOrder(request, request.params.id, null);
|
|
12
|
+
if(error) return refuse(response, error);
|
|
13
|
+
|
|
14
|
+
const [, events] = await getOrderEvents(access.order.id, { customerVisibleOnly: true });
|
|
15
|
+
response.json({ order: await withProductLinks(forCustomer(access.order)), events: events ?? [] });
|
|
16
|
+
};
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { cancelUnpaidOrder } from '../../../../../../server/utils/checkout/unwind.js';
|
|
2
|
-
import { forCustomer, getOrder } from '../../../../../../server/utils/orders/read.js';
|
|
3
|
-
import withProductLinks from '../../../../../../server/utils/orders/links.js';
|
|
4
|
-
import { customerOrder, refuse, requireSession } from '../../../../../../server/http/gate.js';
|
|
5
|
-
|
|
6
|
-
/*
|
|
7
|
-
Cancels an order that has not been paid, as WooCommerce lets a customer do: immediately, with no
|
|
8
|
-
approval, because nothing was paid. A paid order is refunded by the shop, not cancelled by the customer.
|
|
9
|
-
*/
|
|
10
|
-
export default async (request, response) => {
|
|
11
|
-
const [sessionError] = await requireSession(request);
|
|
12
|
-
if(sessionError) return refuse(response, sessionError);
|
|
13
|
-
|
|
14
|
-
const [accessError, access] = await customerOrder(request, request.params.id, null);
|
|
15
|
-
if(accessError) return refuse(response, accessError);
|
|
16
|
-
|
|
17
|
-
const [error] = await cancelUnpaidOrder(access.order.id, { actor: 'customer', reason: 'Cancelled by the customer' });
|
|
18
|
-
if(error) return refuse(response, error);
|
|
19
|
-
|
|
20
|
-
const [, order] = await getOrder(access.order.id, { notes: true });
|
|
21
|
-
response.json({ order: await withProductLinks(forCustomer(order)) });
|
|
22
|
-
};
|
|
1
|
+
import { cancelUnpaidOrder } from '../../../../../../server/utils/checkout/unwind.js';
|
|
2
|
+
import { forCustomer, getOrder } from '../../../../../../server/utils/orders/read.js';
|
|
3
|
+
import withProductLinks from '../../../../../../server/utils/orders/links.js';
|
|
4
|
+
import { customerOrder, refuse, requireSession } from '../../../../../../server/http/gate.js';
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
Cancels an order that has not been paid, as WooCommerce lets a customer do: immediately, with no
|
|
8
|
+
approval, because nothing was paid. A paid order is refunded by the shop, not cancelled by the customer.
|
|
9
|
+
*/
|
|
10
|
+
export default async (request, response) => {
|
|
11
|
+
const [sessionError] = await requireSession(request);
|
|
12
|
+
if(sessionError) return refuse(response, sessionError);
|
|
13
|
+
|
|
14
|
+
const [accessError, access] = await customerOrder(request, request.params.id, null);
|
|
15
|
+
if(accessError) return refuse(response, accessError);
|
|
16
|
+
|
|
17
|
+
const [error] = await cancelUnpaidOrder(access.order.id, { actor: 'customer', reason: 'Cancelled by the customer' });
|
|
18
|
+
if(error) return refuse(response, error);
|
|
19
|
+
|
|
20
|
+
const [, order] = await getOrder(access.order.id, { notes: true });
|
|
21
|
+
response.json({ order: await withProductLinks(forCustomer(order)) });
|
|
22
|
+
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { getOrderEvents } from '../../../../../server/utils/orders/events.js';
|
|
2
|
-
import { forCustomer } from '../../../../../server/utils/orders/read.js';
|
|
3
|
-
import withProductLinks from '../../../../../server/utils/orders/links.js';
|
|
4
|
-
import { customerOrder, refuse } from '../../../../../server/http/gate.js';
|
|
5
|
-
|
|
6
|
-
/* A guest's order, reached with the key in their link. A wrong key is the same 404 as no order. */
|
|
7
|
-
export default async (request, response) => {
|
|
8
|
-
const [error, access] = await customerOrder(request, request.params.id, request.query.key);
|
|
9
|
-
if(error) return refuse(response, error);
|
|
10
|
-
|
|
11
|
-
const [, events] = await getOrderEvents(access.order.id, { customerVisibleOnly: true });
|
|
12
|
-
response.json({ order: await withProductLinks(forCustomer(access.order)), events: events ?? [] });
|
|
13
|
-
};
|
|
1
|
+
import { getOrderEvents } from '../../../../../server/utils/orders/events.js';
|
|
2
|
+
import { forCustomer } from '../../../../../server/utils/orders/read.js';
|
|
3
|
+
import withProductLinks from '../../../../../server/utils/orders/links.js';
|
|
4
|
+
import { customerOrder, refuse } from '../../../../../server/http/gate.js';
|
|
5
|
+
|
|
6
|
+
/* A guest's order, reached with the key in their link. A wrong key is the same 404 as no order. */
|
|
7
|
+
export default async (request, response) => {
|
|
8
|
+
const [error, access] = await customerOrder(request, request.params.id, request.query.key);
|
|
9
|
+
if(error) return refuse(response, error);
|
|
10
|
+
|
|
11
|
+
const [, events] = await getOrderEvents(access.order.id, { customerVisibleOnly: true });
|
|
12
|
+
response.json({ order: await withProductLinks(forCustomer(access.order)), events: events ?? [] });
|
|
13
|
+
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { cancelUnpaidOrder } from '../../../../../../server/utils/checkout/unwind.js';
|
|
2
|
-
import { forCustomer, getOrder } from '../../../../../../server/utils/orders/read.js';
|
|
3
|
-
import withProductLinks from '../../../../../../server/utils/orders/links.js';
|
|
4
|
-
import { body, customerOrder, refuse } from '../../../../../../server/http/gate.js';
|
|
5
|
-
|
|
6
|
-
/* A guest cancels their unpaid order with the key from their link. */
|
|
7
|
-
export default async (request, response) => {
|
|
8
|
-
const [accessError, access] = await customerOrder(request, request.params.id, body(request).key ?? request.query.key);
|
|
9
|
-
if(accessError) return refuse(response, accessError);
|
|
10
|
-
|
|
11
|
-
const [error] = await cancelUnpaidOrder(access.order.id, { actor: 'customer', reason: 'Cancelled by the customer' });
|
|
12
|
-
if(error) return refuse(response, error);
|
|
13
|
-
|
|
14
|
-
const [, order] = await getOrder(access.order.id, { notes: true });
|
|
15
|
-
response.json({ order: await withProductLinks(forCustomer(order)) });
|
|
16
|
-
};
|
|
1
|
+
import { cancelUnpaidOrder } from '../../../../../../server/utils/checkout/unwind.js';
|
|
2
|
+
import { forCustomer, getOrder } from '../../../../../../server/utils/orders/read.js';
|
|
3
|
+
import withProductLinks from '../../../../../../server/utils/orders/links.js';
|
|
4
|
+
import { body, customerOrder, refuse } from '../../../../../../server/http/gate.js';
|
|
5
|
+
|
|
6
|
+
/* A guest cancels their unpaid order with the key from their link. */
|
|
7
|
+
export default async (request, response) => {
|
|
8
|
+
const [accessError, access] = await customerOrder(request, request.params.id, body(request).key ?? request.query.key);
|
|
9
|
+
if(accessError) return refuse(response, accessError);
|
|
10
|
+
|
|
11
|
+
const [error] = await cancelUnpaidOrder(access.order.id, { actor: 'customer', reason: 'Cancelled by the customer' });
|
|
12
|
+
if(error) return refuse(response, error);
|
|
13
|
+
|
|
14
|
+
const [, order] = await getOrder(access.order.id, { notes: true });
|
|
15
|
+
response.json({ order: await withProductLinks(forCustomer(order)) });
|
|
16
|
+
};
|