@asteby/storefront 0.7.0 → 0.9.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/dist/index.cjs +30 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +34 -3
- package/dist/index.d.ts +34 -3
- package/dist/index.js +27 -1
- package/dist/index.js.map +1 -1
- package/dist/mock.cjs +5 -1
- package/dist/mock.cjs.map +1 -1
- package/dist/mock.d.cts +8 -1
- package/dist/mock.d.ts +8 -1
- package/dist/mock.js +5 -1
- package/dist/mock.js.map +1 -1
- package/package.json +1 -1
package/dist/mock.cjs
CHANGED
|
@@ -674,6 +674,10 @@ function createMockStorefront(options = {}) {
|
|
|
674
674
|
function shippingRates(subtotalCents) {
|
|
675
675
|
const freeMin = state.shop.policies.free_shipping_min;
|
|
676
676
|
const free = freeMin !== null && subtotalCents >= toCents(freeMin.amount);
|
|
677
|
+
if (options.shippingRates?.length) {
|
|
678
|
+
const expires = new Date(Date.now() + 24 * 36e5).toISOString();
|
|
679
|
+
return options.shippingRates.map((r) => ({ ...r, expires_at: r.expires_at ?? expires, cost: free ? fromCents(0, r.cost.currency_code) : r.cost }));
|
|
680
|
+
}
|
|
677
681
|
return [
|
|
678
682
|
{ id: "flat", title: free ? "Env\xEDo est\xE1ndar (gratis)" : "Env\xEDo est\xE1ndar", cost: fromCents(free ? 0 : flatShippingCents, currency), eta: "2 a 5 d\xEDas h\xE1biles" },
|
|
679
683
|
{ id: "express", title: "Env\xEDo expr\xE9s", cost: fromCents(flatShippingCents + 1e4, currency), eta: "1 a 2 d\xEDas h\xE1biles" }
|
|
@@ -905,7 +909,7 @@ function createMockStorefront(options = {}) {
|
|
|
905
909
|
});
|
|
906
910
|
route("GET", "/carts/:id/payment-methods", "cart:write", ({ params }) => {
|
|
907
911
|
getCartRecord(params[0]);
|
|
908
|
-
return { body: { methods: [{ key: "mock", kind: "builtin", default: true }], market: null }, cache: "private" };
|
|
912
|
+
return { body: { methods: options.paymentMethods ?? [{ key: "mock", kind: "builtin", default: true }], market: null }, cache: "private" };
|
|
909
913
|
});
|
|
910
914
|
route("PUT", "/carts/:id/delivery", "cart:write", ({ params, body }) => {
|
|
911
915
|
const cart = getCartRecord(params[0]);
|