Skip to content

Commit 9877e4f

Browse files
authored
fix: customizations (#43)
* fix: customizations * chore: fix test * chore: fix post-deploy test
1 parent 676df7b commit 9877e4f

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
lines changed

src/templates/html/overrides/wilson-ecommerce--wilson.js

+11
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,17 @@
1313
import { HTMLTemplate } from '../HTMLTemplate.js';
1414

1515
export default class extends HTMLTemplate {
16+
/**
17+
* @param {Context} ctx
18+
* @param {Product} product
19+
* @param {Variant[]} variants
20+
*/
21+
constructor(ctx, product, variants) {
22+
super(ctx, product, variants);
23+
// use description field for meta description, if not explicitly set
24+
this.product.metaDescription = this.product.metaDescription || this.product.description;
25+
}
26+
1627
/**
1728
* Create the document meta tags
1829
* @returns {string}

src/templates/json/JSONTemplate.js

+1
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ export class JSONTemplate {
163163
'@context': 'http://schema.org',
164164
'@type': 'Product',
165165
'@id': productUrl,
166+
url: productUrl,
166167
name,
167168
sku,
168169
mpn,

src/templates/json/overrides/wilson-ecommerce--wilson.js

+10
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,14 @@ export default class extends JSONTemplate {
3131
constructMPN(variant) {
3232
return variant ? variant.sku : this.product.sku;
3333
}
34+
35+
renderOffers() {
36+
const { offers: baseOffers } = super.renderOffers();
37+
return {
38+
offers: baseOffers.map((o) => ({
39+
...o,
40+
itemCondition: 'http://schema.org/NewCondition',
41+
})),
42+
};
43+
}
3444
}

test/fixtures/post-deploy/bella-tank.html

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"@context": "http://schema.org",
3737
"@type": "Product",
3838
"@id": "https://example.test/products/bella-tank/wt01",
39+
"url": "https://example.test/products/bella-tank/wt01",
3940
"name": "Bella Tank",
4041
"sku": "WT01",
4142
"description": "",

0 commit comments

Comments
 (0)