rerobe-js-orm 4.3.6 → 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.
|
@@ -29,6 +29,6 @@ export default class ReRobeProductHelpers {
|
|
|
29
29
|
static mapToOldSizesToStandardSize(productObj: CompleteProduct): string;
|
|
30
30
|
static buildLineItem(productObj: CompleteProduct, quantity?: number): ProductLineItem;
|
|
31
31
|
static productStatusPretty(status: string): any;
|
|
32
|
-
static convertToGoogleMerchantCenterProduct(productObj: CompleteProduct, merchantObj: MerchantObj): GoogleMerchantCenterProductObj;
|
|
33
|
-
static convertToMetaCommerceProduct(productObj: CompleteProduct, merchantObj: MerchantObj): MetaCommerceProductObj;
|
|
32
|
+
static convertToGoogleMerchantCenterProduct(productObj: CompleteProduct, merchantObj: MerchantObj, targetMarketTaxRate?: number): GoogleMerchantCenterProductObj;
|
|
33
|
+
static convertToMetaCommerceProduct(productObj: CompleteProduct, merchantObj: MerchantObj, targetMarketTaxRate?: number): MetaCommerceProductObj;
|
|
34
34
|
}
|
|
@@ -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>
|
|
@@ -644,7 +644,7 @@ class ReRobeProductHelpers {
|
|
|
644
644
|
return product_constants_1.PRODUCT_STATE_LABELS[toCamelCase(status)] || status;
|
|
645
645
|
}
|
|
646
646
|
}
|
|
647
|
-
static convertToGoogleMerchantCenterProduct(productObj, merchantObj) {
|
|
647
|
+
static convertToGoogleMerchantCenterProduct(productObj, merchantObj, targetMarketTaxRate = 0) {
|
|
648
648
|
const { primaryDomain, currency } = merchantObj;
|
|
649
649
|
const availabilityMapper = (status) => {
|
|
650
650
|
if (!status)
|
|
@@ -705,17 +705,34 @@ class ReRobeProductHelpers {
|
|
|
705
705
|
productObj.isOnSale === 'yes' &&
|
|
706
706
|
productObj.salePrice &&
|
|
707
707
|
productObj.clearanceTimestamp;
|
|
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
|
|
724
|
+
}
|
|
708
725
|
return {
|
|
709
|
-
id: productObj.documentId,
|
|
710
|
-
title: productObj.metaDataTitle || productObj.title,
|
|
726
|
+
id: String(productObj.documentId || ''),
|
|
727
|
+
title: productObj.metaDataTitle || productObj.title || '',
|
|
711
728
|
description: productObj.description || '',
|
|
712
729
|
link: `https://${primaryDomain}/products/${productObj.handle}`,
|
|
713
730
|
image_link: productObj.imageUrls && productObj.imageUrls.length > 0 ? productObj.imageUrls[0] : '',
|
|
714
|
-
price: `${
|
|
731
|
+
price: `${price} ${currency}`,
|
|
715
732
|
cost_of_goods_sold: productObj.costPerItem
|
|
716
733
|
? `${Number(productObj.costPerItem).toFixed(2)} ${currency}`
|
|
717
734
|
: undefined,
|
|
718
|
-
sale_price: isOnSale ? `${
|
|
735
|
+
sale_price: isOnSale ? `${salePrice} ${currency}` : undefined,
|
|
719
736
|
brand: productObj.brand || 'Unknown',
|
|
720
737
|
condition: 'used',
|
|
721
738
|
availability: availabilityMapper(productObj.status),
|
|
@@ -727,7 +744,7 @@ class ReRobeProductHelpers {
|
|
|
727
744
|
identifier_exists: 'no',
|
|
728
745
|
};
|
|
729
746
|
}
|
|
730
|
-
static convertToMetaCommerceProduct(productObj, merchantObj) {
|
|
747
|
+
static convertToMetaCommerceProduct(productObj, merchantObj, targetMarketTaxRate = 0) {
|
|
731
748
|
const { primaryDomain, currency } = merchantObj;
|
|
732
749
|
const availabilityMapper = (status) => {
|
|
733
750
|
if (!status)
|
|
@@ -786,16 +803,33 @@ class ReRobeProductHelpers {
|
|
|
786
803
|
productObj.isOnSale === 'yes' &&
|
|
787
804
|
productObj.salePrice &&
|
|
788
805
|
productObj.clearanceTimestamp;
|
|
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
|
|
822
|
+
}
|
|
789
823
|
return {
|
|
790
|
-
id: productObj.documentId,
|
|
791
|
-
title: productObj.metaDataTitle || productObj.title,
|
|
792
|
-
description: productObj.metaDataDescription || this.autoCreateMetaDescription(productObj),
|
|
824
|
+
id: String(productObj.documentId || ''),
|
|
825
|
+
title: productObj.metaDataTitle || productObj.title || '',
|
|
826
|
+
description: productObj.metaDataDescription || this.autoCreateMetaDescription(productObj) || '',
|
|
793
827
|
availability: availabilityMapper(productObj.status),
|
|
794
828
|
condition: 'used',
|
|
795
|
-
price: `${
|
|
829
|
+
price: `${price} ${currency}`,
|
|
796
830
|
link: `https://${primaryDomain}/products/${productObj.handle}`,
|
|
797
831
|
image_link: productObj.imageUrls && productObj.imageUrls.length > 0 ? productObj.imageUrls[0] : '',
|
|
798
|
-
sale_price: isOnSale ? `${
|
|
832
|
+
sale_price: isOnSale ? `${salePrice} ${currency}` : undefined,
|
|
799
833
|
brand: productObj.brand || 'Unknown',
|
|
800
834
|
color: productObj.color || 'various',
|
|
801
835
|
gender: genderMapper(productObj.gender),
|