From 1806f04354b599ff932d70baede8b4c71115b58f Mon Sep 17 00:00:00 2001 From: Florin Mandoc Date: Thu, 7 Nov 2024 13:55:06 +0200 Subject: [PATCH 1/2] Use price with currency instead base price --- DataLayer/Mapper/ProductDataMapper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DataLayer/Mapper/ProductDataMapper.php b/DataLayer/Mapper/ProductDataMapper.php index e727f77..d5f6f49 100644 --- a/DataLayer/Mapper/ProductDataMapper.php +++ b/DataLayer/Mapper/ProductDataMapper.php @@ -82,7 +82,7 @@ public function mapByProduct(ProductInterface $product): array } catch (NoSuchEntityException $noSuchEntityException) { } - $productData['price'] = $this->priceFormatter->format((float)$product->getFinalPrice()); + $productData['price'] = $this->priceFormatter->format((float) $product->getPriceInfo()->getPrice(FinalPrice::PRICE_CODE)->getValue()); $productData = $this->attachCategoriesData($product, $productData); $productData = $this->parseDataLayerMapping($product, $productData); From 4e29848acd29251de75369d72a4a1898561f71f8 Mon Sep 17 00:00:00 2001 From: Florin Mandoc Date: Thu, 7 Nov 2024 16:46:57 +0200 Subject: [PATCH 2/2] Update datalayer price to have keep working for add to cart event for configurable products (issue https://github.com/yireo/Yireo_GoogleTagManager2/issues/233) --- DataLayer/Mapper/ProductDataMapper.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/DataLayer/Mapper/ProductDataMapper.php b/DataLayer/Mapper/ProductDataMapper.php index d5f6f49..a710472 100644 --- a/DataLayer/Mapper/ProductDataMapper.php +++ b/DataLayer/Mapper/ProductDataMapper.php @@ -83,6 +83,10 @@ public function mapByProduct(ProductInterface $product): array } $productData['price'] = $this->priceFormatter->format((float) $product->getPriceInfo()->getPrice(FinalPrice::PRICE_CODE)->getValue()); + if ($product->getCustomOption('simple_product') && $product->getCustomOption('simple_product')->getProduct()) { + $simpleProduct = $product->getCustomOption('simple_product')->getProduct(); + $productData['price'] = $this->priceFormatter->format((float) $simpleProduct->getPriceInfo()->getPrice(FinalPrice::PRICE_CODE)->getValue()); + } $productData = $this->attachCategoriesData($product, $productData); $productData = $this->parseDataLayerMapping($product, $productData);