@techninja/staticart 0.1.11 → 0.1.12
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/components/molecules/related-products/related-products.js +1 -2
- package/src/components/molecules/series-gallery/series-gallery.js +1 -1
- package/src/pages/product-detail/helpers.js +10 -3
- package/vendor/components/molecules/related-products/related-products.js +1 -2
- package/vendor/components/molecules/series-gallery/series-gallery.js +1 -1
- package/vendor/pages/product-detail/helpers.js +3 -3
package/package.json
CHANGED
|
@@ -50,11 +50,10 @@ export default define({
|
|
|
50
50
|
.filter(
|
|
51
51
|
(p) =>
|
|
52
52
|
p.sku !== currentSku &&
|
|
53
|
-
p.stock
|
|
53
|
+
p.stock !== 0 &&
|
|
54
54
|
(!excludeSeries || p.metadata?.seriesTitle !== excludeSeries),
|
|
55
55
|
)
|
|
56
56
|
.map((p) => ({ product: p, score: relevanceScore(current, p) }))
|
|
57
|
-
.filter((r) => r.score > 0)
|
|
58
57
|
.sort((a, b) => b.score - a.score)
|
|
59
58
|
.slice(0, MAX_RELATED)
|
|
60
59
|
.map((r) => r.product);
|
|
@@ -26,7 +26,7 @@ export default define({
|
|
|
26
26
|
value: ({ series, currentSku, products }) => {
|
|
27
27
|
if (!series || !(/** @type {any} */ (store).ready(products))) return html``;
|
|
28
28
|
const related = /** @type {any[]} */ (products)
|
|
29
|
-
.filter((p) => p.metadata?.seriesTitle === series && p.sku !== currentSku && p.stock
|
|
29
|
+
.filter((p) => p.metadata?.seriesTitle === series && p.sku !== currentSku && p.stock !== 0)
|
|
30
30
|
.sort((a, b) => a.name.localeCompare(b.name));
|
|
31
31
|
if (!related.length) return html``;
|
|
32
32
|
return html`
|
|
@@ -49,8 +49,15 @@ export function renderNotFound(CatalogView) {
|
|
|
49
49
|
|
|
50
50
|
/** @param {number} s */
|
|
51
51
|
export function stockBadge(s) {
|
|
52
|
-
const label =
|
|
53
|
-
|
|
52
|
+
const label =
|
|
53
|
+
s < 0
|
|
54
|
+
? 'product.inStock'
|
|
55
|
+
: s === 0
|
|
56
|
+
? 'product.outOfStock'
|
|
57
|
+
: s <= 5
|
|
58
|
+
? 'product.lowStock'
|
|
59
|
+
: 'product.inStock';
|
|
60
|
+
const color = s < 0 ? 'success' : s === 0 ? 'danger' : s <= 5 ? 'warning' : 'success';
|
|
54
61
|
return html`<app-badge label="${t(label)}" color="${color}"></app-badge>`;
|
|
55
62
|
}
|
|
56
63
|
|
|
@@ -59,7 +66,7 @@ export function handleAdd(host) {
|
|
|
59
66
|
if (!store.ready(host.cart) || !store.ready(host.product)) return;
|
|
60
67
|
const { product: p, selectedVariant: vid, qty } = host;
|
|
61
68
|
const stock = vid ? (p.variants.find((v) => v.id === vid)?.stock ?? 0) : p.stock;
|
|
62
|
-
if (qty <= stock && stock > 0) addToCart(host.cart, p.sku, vid, qty);
|
|
69
|
+
if (stock < 0 || (qty <= stock && stock > 0)) addToCart(host.cart, p.sku, vid, qty);
|
|
63
70
|
}
|
|
64
71
|
|
|
65
72
|
/** @param {any} host */
|
|
@@ -50,11 +50,10 @@ export default define({
|
|
|
50
50
|
.filter(
|
|
51
51
|
(p) =>
|
|
52
52
|
p.sku !== currentSku &&
|
|
53
|
-
p.stock
|
|
53
|
+
p.stock !== 0 &&
|
|
54
54
|
(!excludeSeries || p.metadata?.seriesTitle !== excludeSeries),
|
|
55
55
|
)
|
|
56
56
|
.map((p) => ({ product: p, score: relevanceScore(current, p) }))
|
|
57
|
-
.filter((r) => r.score > 0)
|
|
58
57
|
.sort((a, b) => b.score - a.score)
|
|
59
58
|
.slice(0, MAX_RELATED)
|
|
60
59
|
.map((r) => r.product);
|
|
@@ -26,7 +26,7 @@ export default define({
|
|
|
26
26
|
value: ({ series, currentSku, products }) => {
|
|
27
27
|
if (!series || !(/** @type {any} */ (store).ready(products))) return html``;
|
|
28
28
|
const related = /** @type {any[]} */ (products)
|
|
29
|
-
.filter((p) => p.metadata?.seriesTitle === series && p.sku !== currentSku && p.stock
|
|
29
|
+
.filter((p) => p.metadata?.seriesTitle === series && p.sku !== currentSku && p.stock !== 0)
|
|
30
30
|
.sort((a, b) => a.name.localeCompare(b.name));
|
|
31
31
|
if (!related.length) return html``;
|
|
32
32
|
return html`
|
|
@@ -49,8 +49,8 @@ export function renderNotFound(CatalogView) {
|
|
|
49
49
|
|
|
50
50
|
/** @param {number} s */
|
|
51
51
|
export function stockBadge(s) {
|
|
52
|
-
const label = s
|
|
53
|
-
const color = s
|
|
52
|
+
const label = s < 0 ? 'product.inStock' : s === 0 ? 'product.outOfStock' : s <= 5 ? 'product.lowStock' : 'product.inStock';
|
|
53
|
+
const color = s < 0 ? 'success' : s === 0 ? 'danger' : s <= 5 ? 'warning' : 'success';
|
|
54
54
|
return html`<app-badge label="${t(label)}" color="${color}"></app-badge>`;
|
|
55
55
|
}
|
|
56
56
|
|
|
@@ -59,7 +59,7 @@ export function handleAdd(host) {
|
|
|
59
59
|
if (!store.ready(host.cart) || !store.ready(host.product)) return;
|
|
60
60
|
const { product: p, selectedVariant: vid, qty } = host;
|
|
61
61
|
const stock = vid ? (p.variants.find((v) => v.id === vid)?.stock ?? 0) : p.stock;
|
|
62
|
-
if (qty <= stock && stock > 0) addToCart(host.cart, p.sku, vid, qty);
|
|
62
|
+
if (stock < 0 || (qty <= stock && stock > 0)) addToCart(host.cart, p.sku, vid, qty);
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
/** @param {any} host */
|