rerobe-js-orm 4.3.7 → 4.3.8
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.
|
@@ -268,17 +268,17 @@ class ReRobeProductHelpers {
|
|
|
268
268
|
}
|
|
269
269
|
static autoCreateMetaDescription(productObj) {
|
|
270
270
|
var _a;
|
|
271
|
-
const { color, productType, productStyle, condition, size, standardSize, brand, sizeComment, materialComposition, gender, } = productObj;
|
|
271
|
+
const { color, productType, productStyle = [], condition, size, standardSize, brand, sizeComment, materialComposition, gender, } = productObj;
|
|
272
272
|
const materials = this.materialCompJoinedString(materialComposition);
|
|
273
273
|
const fit = ((_a = options_1.sizeCommentOptions.find((option) => option.value === sizeComment)) === null || _a === void 0 ? void 0 : _a.label) || '';
|
|
274
|
-
const joinedProductStyle = productStyle.join(', ');
|
|
274
|
+
const joinedProductStyle = Array.isArray(productStyle) ? productStyle.join(', ') : '';
|
|
275
275
|
const elements = [
|
|
276
276
|
gender && `Primary segment: ${gender}`,
|
|
277
277
|
brand && `Brand: ${brand}`,
|
|
278
278
|
size && `Size: ${standardSize ? standardSize : size}`,
|
|
279
279
|
color && `Color: ${color}`,
|
|
280
280
|
productType && `Type: ${productType}`,
|
|
281
|
-
|
|
281
|
+
joinedProductStyle && `Style: ${joinedProductStyle}`,
|
|
282
282
|
condition && `Condition: ${condition}`,
|
|
283
283
|
materials && `Material: ${materials}`,
|
|
284
284
|
fit && `Fit: ${fit}`,
|
|
@@ -317,7 +317,7 @@ class ReRobeProductHelpers {
|
|
|
317
317
|
Vi använder oss av "Tradera betalning" vilket innebär att du som köpare kan välja att betala med Swish, kort eller PayPal. ${merchantName}’s rabatter och erbjudanden gäller endast vid köp på vår hemsida samt via vår app.
|
|
318
318
|
<br>
|
|
319
319
|
<br>
|
|
320
|
-
Tänk på att produkter kan ligga i flera varukorgar samtidigt. Om din vara står som
|
|
320
|
+
Tänk på att produkter kan ligga i flera varukorgar samtidigt. Om din vara står som "slut/såld" vid utcheckningen beror det på att någon annan hunnit före.
|
|
321
321
|
</p>
|
|
322
322
|
|
|
323
323
|
<p>
|
|
@@ -705,13 +705,26 @@ class ReRobeProductHelpers {
|
|
|
705
705
|
productObj.isOnSale === 'yes' &&
|
|
706
706
|
productObj.salePrice &&
|
|
707
707
|
productObj.clearanceTimestamp;
|
|
708
|
-
let price =
|
|
709
|
-
|
|
710
|
-
|
|
708
|
+
let price = '0.00';
|
|
709
|
+
let salePrice = '0.00';
|
|
710
|
+
try {
|
|
711
|
+
const basePrice = Number(productObj.price);
|
|
712
|
+
const baseSalePrice = Number(productObj.salePrice || 0);
|
|
713
|
+
if (!isNaN(basePrice)) {
|
|
714
|
+
price = (targetMarketTaxRate && productObj.isTaxable === 'yes' ? basePrice * (1 + targetMarketTaxRate) : basePrice).toFixed(2);
|
|
715
|
+
}
|
|
716
|
+
if (!isNaN(baseSalePrice) && isOnSale) {
|
|
717
|
+
salePrice = (targetMarketTaxRate && productObj.isTaxable === 'yes'
|
|
718
|
+
? baseSalePrice * (1 + targetMarketTaxRate)
|
|
719
|
+
: baseSalePrice).toFixed(2);
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
catch (error) {
|
|
723
|
+
// Keep default values if parsing fails
|
|
711
724
|
}
|
|
712
725
|
return {
|
|
713
|
-
id: productObj.documentId,
|
|
714
|
-
title: productObj.metaDataTitle || productObj.title,
|
|
726
|
+
id: String(productObj.documentId || ''),
|
|
727
|
+
title: productObj.metaDataTitle || productObj.title || '',
|
|
715
728
|
description: productObj.description || '',
|
|
716
729
|
link: `https://${primaryDomain}/products/${productObj.handle}`,
|
|
717
730
|
image_link: productObj.imageUrls && productObj.imageUrls.length > 0 ? productObj.imageUrls[0] : '',
|
|
@@ -719,7 +732,7 @@ class ReRobeProductHelpers {
|
|
|
719
732
|
cost_of_goods_sold: productObj.costPerItem
|
|
720
733
|
? `${Number(productObj.costPerItem).toFixed(2)} ${currency}`
|
|
721
734
|
: undefined,
|
|
722
|
-
sale_price: isOnSale ? `${
|
|
735
|
+
sale_price: isOnSale ? `${salePrice} ${currency}` : undefined,
|
|
723
736
|
brand: productObj.brand || 'Unknown',
|
|
724
737
|
condition: 'used',
|
|
725
738
|
availability: availabilityMapper(productObj.status),
|
|
@@ -790,20 +803,33 @@ class ReRobeProductHelpers {
|
|
|
790
803
|
productObj.isOnSale === 'yes' &&
|
|
791
804
|
productObj.salePrice &&
|
|
792
805
|
productObj.clearanceTimestamp;
|
|
793
|
-
let price =
|
|
794
|
-
|
|
795
|
-
|
|
806
|
+
let price = '0.00';
|
|
807
|
+
let salePrice = '0.00';
|
|
808
|
+
try {
|
|
809
|
+
const basePrice = Number(productObj.price);
|
|
810
|
+
const baseSalePrice = Number(productObj.salePrice || 0);
|
|
811
|
+
if (!isNaN(basePrice)) {
|
|
812
|
+
price = (targetMarketTaxRate && productObj.isTaxable === 'yes' ? basePrice * (1 + targetMarketTaxRate) : basePrice).toFixed(2);
|
|
813
|
+
}
|
|
814
|
+
if (!isNaN(baseSalePrice) && isOnSale) {
|
|
815
|
+
salePrice = (targetMarketTaxRate && productObj.isTaxable === 'yes'
|
|
816
|
+
? baseSalePrice * (1 + targetMarketTaxRate)
|
|
817
|
+
: baseSalePrice).toFixed(2);
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
catch (error) {
|
|
821
|
+
// Keep default values if parsing fails
|
|
796
822
|
}
|
|
797
823
|
return {
|
|
798
|
-
id: productObj.documentId,
|
|
799
|
-
title: productObj.metaDataTitle || productObj.title,
|
|
800
|
-
description: productObj.metaDataDescription || this.autoCreateMetaDescription(productObj),
|
|
824
|
+
id: String(productObj.documentId || ''),
|
|
825
|
+
title: productObj.metaDataTitle || productObj.title || '',
|
|
826
|
+
description: productObj.metaDataDescription || this.autoCreateMetaDescription(productObj) || '',
|
|
801
827
|
availability: availabilityMapper(productObj.status),
|
|
802
828
|
condition: 'used',
|
|
803
829
|
price: `${price} ${currency}`,
|
|
804
830
|
link: `https://${primaryDomain}/products/${productObj.handle}`,
|
|
805
831
|
image_link: productObj.imageUrls && productObj.imageUrls.length > 0 ? productObj.imageUrls[0] : '',
|
|
806
|
-
sale_price: isOnSale ? `${
|
|
832
|
+
sale_price: isOnSale ? `${salePrice} ${currency}` : undefined,
|
|
807
833
|
brand: productObj.brand || 'Unknown',
|
|
808
834
|
color: productObj.color || 'various',
|
|
809
835
|
gender: genderMapper(productObj.gender),
|