rerobe-js-orm 4.3.6 → 4.3.7
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
|
}
|
|
@@ -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,13 +705,17 @@ class ReRobeProductHelpers {
|
|
|
705
705
|
productObj.isOnSale === 'yes' &&
|
|
706
706
|
productObj.salePrice &&
|
|
707
707
|
productObj.clearanceTimestamp;
|
|
708
|
+
let price = Number(productObj.price).toFixed(2);
|
|
709
|
+
if (targetMarketTaxRate && productObj.isTaxable === 'yes') {
|
|
710
|
+
price = (Number(productObj.price) * (1 + targetMarketTaxRate)).toFixed(2);
|
|
711
|
+
}
|
|
708
712
|
return {
|
|
709
713
|
id: productObj.documentId,
|
|
710
714
|
title: productObj.metaDataTitle || productObj.title,
|
|
711
715
|
description: productObj.description || '',
|
|
712
716
|
link: `https://${primaryDomain}/products/${productObj.handle}`,
|
|
713
717
|
image_link: productObj.imageUrls && productObj.imageUrls.length > 0 ? productObj.imageUrls[0] : '',
|
|
714
|
-
price: `${
|
|
718
|
+
price: `${price} ${currency}`,
|
|
715
719
|
cost_of_goods_sold: productObj.costPerItem
|
|
716
720
|
? `${Number(productObj.costPerItem).toFixed(2)} ${currency}`
|
|
717
721
|
: undefined,
|
|
@@ -727,7 +731,7 @@ class ReRobeProductHelpers {
|
|
|
727
731
|
identifier_exists: 'no',
|
|
728
732
|
};
|
|
729
733
|
}
|
|
730
|
-
static convertToMetaCommerceProduct(productObj, merchantObj) {
|
|
734
|
+
static convertToMetaCommerceProduct(productObj, merchantObj, targetMarketTaxRate = 0) {
|
|
731
735
|
const { primaryDomain, currency } = merchantObj;
|
|
732
736
|
const availabilityMapper = (status) => {
|
|
733
737
|
if (!status)
|
|
@@ -786,13 +790,17 @@ class ReRobeProductHelpers {
|
|
|
786
790
|
productObj.isOnSale === 'yes' &&
|
|
787
791
|
productObj.salePrice &&
|
|
788
792
|
productObj.clearanceTimestamp;
|
|
793
|
+
let price = Number(productObj.price).toFixed(2);
|
|
794
|
+
if (targetMarketTaxRate && productObj.isTaxable === 'yes') {
|
|
795
|
+
price = (Number(productObj.price) * (1 + targetMarketTaxRate)).toFixed(2);
|
|
796
|
+
}
|
|
789
797
|
return {
|
|
790
798
|
id: productObj.documentId,
|
|
791
799
|
title: productObj.metaDataTitle || productObj.title,
|
|
792
800
|
description: productObj.metaDataDescription || this.autoCreateMetaDescription(productObj),
|
|
793
801
|
availability: availabilityMapper(productObj.status),
|
|
794
802
|
condition: 'used',
|
|
795
|
-
price: `${
|
|
803
|
+
price: `${price} ${currency}`,
|
|
796
804
|
link: `https://${primaryDomain}/products/${productObj.handle}`,
|
|
797
805
|
image_link: productObj.imageUrls && productObj.imageUrls.length > 0 ? productObj.imageUrls[0] : '',
|
|
798
806
|
sale_price: isOnSale ? `${Number(productObj.salePrice).toFixed(2)} ${currency}` : undefined,
|