Skip to content

Commit a7abe86

Browse files
authored
Merge branch 'yireo:master' into master
2 parents 3090ad2 + 966d3e0 commit a7abe86

24 files changed

+109
-172
lines changed

.github/workflows/extdn-phpstan-pre-install.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ composer require yireo/magento2-integration-test-helper --no-update
66

77
composer config --no-plugins allow-plugins true
88

9-
composer require --dev phpstan/extension-installer --no-update
10-
composer require --dev bitexpert/phpstan-magento --no-update
9+
composer require --dev phpstan/extension-installer:^1.0 --no-update
10+
composer require --dev bitexpert/phpstan-magento:^0.32 --no-update
1111

1212
composer require yireo/magento2-replace-bundled:^4.0 --no-update
1313
composer require yireo/magento2-replace-inventory:^4.0 --no-update

.module.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
EXTENSION_VENDOR="Yireo"
22
EXTENSION_NAME="GoogleTagManager2"
33
COMPOSER_NAME="yireo/magento2-googletagmanager2"
4-
PHP_VERSIONS=("7.4", "8.1", "8.2", "8.3")
4+
PHP_VERSIONS=("7.4", "8.1", "8.2", "8.3","8.4")
5+
PHPSTAN_LEVEL=2

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## [3.10.0] - 06 May 2025
10+
### Moved
11+
- Move Hyva Checkout compat into separate package
12+
13+
### Fixed
14+
- Do not use custom product provider by default anymore
15+
16+
## [3.9.18] - 23 April 2025
17+
### Fixed
18+
- PHP 8.4 compatibility issues
19+
20+
## [3.9.17] - 17 March 2025
21+
### Fixed
22+
- Issue with js minify, script not loaded #269 @taoufiqaitali
23+
- Fix type error when event name is empty #259
24+
25+
## [3.9.16] - 19 February 2025
26+
### Fixed
27+
- Make sure to apply Container URL to IFRAME URL as well #267 @rikwillems
28+
929
## [3.9.15] - 6 January 2025
1030
### Fixed
1131
- Subtract shipping discount amount from shipping amount #248

Config/Source/CustomerAttributes.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php declare(strict_types=1);
22

3+
// Disable PHPCS due to false positive in PHPCompatibility\Sniffs\NewClassesSniff
4+
// phpcs:disable
5+
36
namespace Yireo\GoogleTagManager2\Config\Source;
47

58
use Magento\Eav\Api\AttributeRepositoryInterface;
@@ -52,10 +55,6 @@ public function toOptionArray(): array
5255
return $options;
5356
}
5457

55-
/**
56-
* @param Attribute $attribute
57-
* @return bool
58-
*/
5958
private function isAttributeDisplayedInFrontend(Attribute $attribute): bool
6059
{
6160
$forms = $attribute->getUsedInForms();

DataLayer/Mapper/CartItemDataMapper.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class CartItemDataMapper
1717
private ProductProvider $productProvider;
1818
private PriceFormatter $priceFormatter;
1919
private ScopeConfigInterface $scopeConfig;
20+
private bool $useProductProvider = false;
2021

2122
/**
2223
* @param ProductDataMapper $productDataMapper
@@ -28,12 +29,14 @@ public function __construct(
2829
ProductDataMapper $productDataMapper,
2930
ProductProvider $productProvider,
3031
PriceFormatter $priceFormatter,
31-
ScopeConfigInterface $scopeConfig
32+
ScopeConfigInterface $scopeConfig,
33+
bool $useProductProvider = false
3234
) {
3335
$this->productDataMapper = $productDataMapper;
3436
$this->productProvider = $productProvider;
3537
$this->priceFormatter = $priceFormatter;
3638
$this->scopeConfig = $scopeConfig;
39+
$this->useProductProvider = $useProductProvider;
3740
}
3841

3942
/**
@@ -44,7 +47,12 @@ public function __construct(
4447
public function mapByCartItem(CartItem $cartItem): array
4548
{
4649
try {
47-
$product = $this->productProvider->getBySku($cartItem->getSku());
50+
if ($this->useProductProvider) {
51+
$product = $this->productProvider->getBySku($cartItem->getSku());
52+
} else {
53+
$product = $cartItem->getProduct();
54+
}
55+
4856
$cartItemData = $this->productDataMapper->mapByProduct($product);
4957
} catch (NoSuchEntityException $e) {
5058
$cartItemData = [];

DataLayer/Mapper/ProductDataMapper.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,10 @@ public function mapByProduct(ProductInterface $product): array
8383
}
8484

8585
$productData['price'] = $this->priceFormatter->format((float) $product->getPriceInfo()->getPrice(FinalPrice::PRICE_CODE)->getValue());
86-
if ($product->getCustomOption('simple_product') && $product->getCustomOption('simple_product')->getProduct()) {
87-
$simpleProduct = $product->getCustomOption('simple_product')->getProduct();
86+
87+
$simpleProductOption = $product->getCustomOption('simple_product');
88+
if ($simpleProductOption && method_exists($simpleProductOption, 'getProduct') && $simpleProductOption->getProduct()) {
89+
$simpleProduct = $simpleProductOption->getProduct();
8890
$productData['price'] = $this->priceFormatter->format((float) $simpleProduct->getPriceInfo()->getPrice(FinalPrice::PRICE_CODE)->getValue());
8991
}
9092

FAQ.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ First of all, make sure to upgrade to the latest version of this extension, befo
88

99
When making use of Server-Side Tracking, make sure to customize the setting **Orders states for purchase event** (`order_states_for_purchase_event`) and to manually trigger the `purchase` event where needed.
1010

11+
# The purchase event is fired when the order hasn't been completed yet
12+
The Yireo GoogleTagManager extension uses the core event `sales_order_place_after` to trigger the `purchase` event. And this event is passed on from the server-side (PHP) towards the client-side (JavaScript) whenever a page is hit again (for instance, the loading of the checkout success page) or whenever an AJAX call occurs. At this moment, it might be that the payment has not yet occurred, so that the order status is not yet complete, but still the `purchase` event is triggered. This is **not** a bug, this is where you step in as an integrator of this Yireo GoogleTagManager2 extension and your custom choice of PSPs.
13+
14+
How do you want this to work? Firing the `purchase` event on the success page will often **not** work either: It could be that a payment is delayed, so that the PSP only notifies the Magento application of the payment (so that the order can be completed) *after* the customer has left the shop. A similar scenario pops up when you are placing an order in the Magento Admin Panel. In these scenarios, there no longer is a scenario where client-side tracking (via JavaScript in the frontend) can be used. Instead, the solution is server-side tracking.
15+
16+
The Yireo GoogleTagManager2 extension does not offer server-side tracking as a functionality, but it does support it. Simply enable the setting **Server-Side Tracking**, configure the **Container URL** and select which order states should trigger the `purchase` event (most likely only the `complete` status).
17+
18+
If you need any additional help, the company of [Yireo](https://www.yireo.com/) is happy to help out with a custom (paid) consult as well.
19+
1120
# Does this extension work under PHP 8.2?
1221
Yes, version 3 does. Version 2 is no longer maintained, but you could use the following composer patch with `vaimo/composer-patches`:
1322
```bash

MageWire/Checkout.php

Lines changed: 0 additions & 52 deletions
This file was deleted.

MageWire/Component.php

Lines changed: 0 additions & 30 deletions
This file was deleted.

Plugin/TriggerAddGuestPaymentInfoDataLayerEvent.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function afterSavePaymentInformationAndPlaceOrder(
3131
$cartId,
3232
$email,
3333
PaymentInterface $paymentMethod,
34-
AddressInterface $billingAddress = null
34+
?AddressInterface $billingAddress = null
3535
) {
3636
$cartId = $this->maskedQuoteIdToQuoteId->execute($cartId);
3737
$addPaymentInfoEventData = $this->addPaymentInfo
@@ -49,7 +49,7 @@ public function afterSavePaymentInformation(
4949
$cartId,
5050
$email,
5151
PaymentInterface $paymentMethod,
52-
AddressInterface $billingAddress = null
52+
?AddressInterface $billingAddress = null
5353
) {
5454
$cartId = $this->maskedQuoteIdToQuoteId->execute($cartId);
5555
$addPaymentInfoEventData = $this->addPaymentInfo

0 commit comments

Comments
 (0)