Skip to content

Commit c529763

Browse files
authored
Merge pull request yireo#303 from stefliekens/add-shipping-info-event
Added value and currency to add_shipping_info event
2 parents 345f94a + 6774ab4 commit c529763

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

DataLayer/Event/AddShippingInfo.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,29 @@
1212
use Magento\Quote\Model\ShippingMethodManagementInterface;
1313
use Yireo\GoogleTagManager2\Api\Data\EventInterface;
1414
use Yireo\GoogleTagManager2\DataLayer\Tag\Cart\CartItems;
15+
use Yireo\GoogleTagManager2\DataLayer\Tag\Cart\CartValue;
1516

1617
class AddShippingInfo implements EventInterface
1718
{
1819
private CartItems $cartItems;
20+
private CartValue $cartValue;
1921
private ShippingMethodManagementInterface $shippingMethodManagement;
2022
private CheckoutSession $checkoutSession;
2123

2224
/**
2325
* @param CartItems $cartItems
26+
* @param CartValue $cartValue
2427
* @param ShippingMethodManagementInterface $shippingMethodManagement
2528
* @param CheckoutSession $checkoutSession
2629
*/
2730
public function __construct(
2831
CartItems $cartItems,
32+
CartValue $cartValue,
2933
ShippingMethodManagementInterface $shippingMethodManagement,
3034
CheckoutSession $checkoutSession
3135
) {
3236
$this->cartItems = $cartItems;
37+
$this->cartValue = $cartValue;
3338
$this->shippingMethodManagement = $shippingMethodManagement;
3439
$this->checkoutSession = $checkoutSession;
3540
}
@@ -57,6 +62,8 @@ public function get(): array
5762
return [
5863
'event' => 'add_shipping_info',
5964
'ecommerce' => [
65+
'currency' => $quote->getQuoteCurrencyCode(),
66+
'value' => $this->cartValue->get(),
6067
'shipping_tier' => $shippingMethod,
6168
'items' => $this->cartItems->get(),
6269
],

0 commit comments

Comments
 (0)