diff --git a/MageWire/Checkout.php b/MageWire/Checkout.php index 84ddc8b7..b5a84d7c 100644 --- a/MageWire/Checkout.php +++ b/MageWire/Checkout.php @@ -10,10 +10,6 @@ class Checkout extends Component { - protected $listeners = [ - 'shipping_method_selected' => 'triggerShippingMethod', - 'payment_method_selected' => 'triggerPaymentMethod', - ]; private CheckoutSession $checkoutSession; private BeginCheckout $beginCheckout; private AddShippingInfo $addShippingInfo; @@ -31,6 +27,17 @@ public function __construct( $this->addPaymentInfo = $addPaymentInfo; } + public function boot(): void + { + $parent = get_parent_class($this); + if ($parent && method_exists($parent, 'boot')) { + parent::boot(); + } + + $this->listeners['shipping_method_selected'] = 'triggerShippingMethod'; + $this->listeners['payment_method_selected'] = 'triggerPaymentMethod'; + } + public function triggerBeginCheckout() { $this->dispatchBrowserEvent('ga:trigger-event', $this->beginCheckout->get()); diff --git a/view/frontend/layout/hyva_checkout_index_index.xml b/view/frontend/layout/hyva_checkout_index_index.xml index 285290cf..c976b8da 100644 --- a/view/frontend/layout/hyva_checkout_index_index.xml +++ b/view/frontend/layout/hyva_checkout_index_index.xml @@ -2,8 +2,10 @@ - + Tagging\GTM\MageWire\Checkout Tagging\GTM\DataLayer\Event\BeginCheckout diff --git a/view/frontend/templates/hyva_checkout/data-layer.phtml b/view/frontend/templates/hyva_checkout/data-layer.phtml index 1bb0826f..fc019642 100644 --- a/view/frontend/templates/hyva_checkout/data-layer.phtml +++ b/view/frontend/templates/hyva_checkout/data-layer.phtml @@ -14,26 +14,18 @@ if (false === $magewire->isHyvaCheckoutEnabled()) { } $beginCheckoutEvent = $block->getData('begin_checkout_event'); +$beginCheckoutPayload = $beginCheckoutEvent->get(); ?> -
+