Skip to content

Commit 5f3a287

Browse files
authored
fix: add variant name and overrides for JSON LD (#74)
1 parent a6a5f9d commit 5f3a287

File tree

5 files changed

+920
-992
lines changed

5 files changed

+920
-992
lines changed

src/templates/json/JSONTemplate.js

+1
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ export class JSONTemplate {
134134
'@type': 'Offer',
135135
sku: v.sku,
136136
mpn,
137+
name: v.name,
137138
url: offerUrl,
138139
image: v.images?.[0]?.url ?? image,
139140
availability: v.inStock ? 'InStock' : 'OutOfStock',

src/templates/json/overrides/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,6 @@
1616
export default {
1717
'thepixel--bul-eds': (await import('./thepixel--bul-eds.js')).default,
1818
'wilson-ecommerce--wilson': (await import('./wilson-ecommerce--wilson.js')).default,
19+
'visualcomfort--adobe-edge': (await import('./visualcomfort--adobe-edge.js')).default,
20+
'visualcomfort--adobe-edge-stage': (await import('./visualcomfort--adobe-edge.js')).default,
1921
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Copyright 2024 Adobe. All rights reserved.
3+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License. You may obtain a copy
5+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
6+
*
7+
* Unless required by applicable law or agreed to in writing, software distributed under
8+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9+
* OF ANY KIND, either express or implied. See the License for the specific language
10+
* governing permissions and limitations under the License.
11+
*/
12+
13+
import { JSONTemplate } from '../JSONTemplate.js';
14+
15+
export default class extends JSONTemplate {
16+
// eslint-disable-next-line class-methods-use-this
17+
renderBrand() {
18+
return {
19+
brand: {
20+
'@type': 'Brand',
21+
name: this.product.attributeMap?.brand ?? 'Visual Comfort',
22+
},
23+
};
24+
}
25+
26+
renderOffers() {
27+
const baseOffers = super.renderOffers();
28+
return baseOffers.map((o) => ({
29+
...o,
30+
shippingDetails: {
31+
'@type': 'OfferShippingDetails',
32+
shippingDestination: {
33+
'@type': 'DefinedRegion',
34+
addressCountry: {
35+
'@type': 'Country',
36+
name: 'US',
37+
},
38+
},
39+
deliveryTime: {
40+
'@type': 'ShippingDeliveryTime',
41+
businessDays: {
42+
'@type': 'OpeningHoursSpecification',
43+
},
44+
},
45+
},
46+
}));
47+
}
48+
}

0 commit comments

Comments
 (0)