From 6a2bfeb4dbb6c2a452afa43c30d0b2cfe08df8be Mon Sep 17 00:00:00 2001 From: Jacek Pyziak Date: Wed, 25 Mar 2026 18:41:19 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20Poprawki=20dataLayer=20GA4=20=E2=80=94?= =?UTF-8?q?=20purchase=20price,=20format=20kluczy,=20fa=C5=82szywa=20konwe?= =?UTF-8?q?rsja=20GADS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - purchase: id→item_id (string), name→item_name, price fallback na price_brutto gdy brak promo, user_data poza ecommerce - begin_checkout: id→item_id, name→item_name, dodano google_business_vertical - Usunięto fałszywą konwersję GADS (gtag conversion) ze strony checkout - view_item: dodano currency PLN, price jako number zamiast string - Dodano event view_cart na stronie koszyka - add_to_cart: quantity parseInt zamiast string Co-Authored-By: Claude Opus 4.6 (1M context) --- templates_user/shop-basket/basket.php | 29 +++++++++++++++++++++ templates_user/shop-basket/summary-view.php | 13 +++------ templates_user/shop-order/order-details.php | 26 +++++++++--------- templates_user/shop-product/product.php | 9 ++++--- 4 files changed, 52 insertions(+), 25 deletions(-) diff --git a/templates_user/shop-basket/basket.php b/templates_user/shop-basket/basket.php index 175bfa2..e0014cb 100644 --- a/templates_user/shop-basket/basket.php +++ b/templates_user/shop-basket/basket.php @@ -33,6 +33,35 @@ + settings['google_tag_manager_id'] && is_array( $this -> basket ) && count( $this -> basket ) ):?> + + \ No newline at end of file diff --git a/templates_user/shop-order/order-details.php b/templates_user/shop-order/order-details.php index 93c0c6f..09fed35 100644 --- a/templates_user/shop-order/order-details.php +++ b/templates_user/shop-order/order-details.php @@ -170,25 +170,27 @@ currency: "PLN", value: order['summary'], 2 ) ) - str_replace( ',', '.', round( $this -> order['transport_cost'], 2 ) );?>, shipping: order['transport_cost'] );?>, - user_email: " order['client_email'] ?>", - user_phone: " order['client_phone'] ?>", - user_name: " order['client_name'] ?>", - user_surname: " order['client_surname'] ?>", - user_street: " order['client_street'] ?>", - user_city: " order['client_city'] ?>", - user_country: "Polska", - user_postal_code: " order['client_postal_code'] ?>", items: [ order['products'] as $product ):?> { - id: , - name: '', - quantity: , - price: , + item_id: "", + item_name: '', + quantity: , + price: 0 ? \Shared\Helpers\Helpers::normalize_decimal( $product['price_brutto_promo'] ) : \Shared\Helpers\Helpers::normalize_decimal( $product['price_brutto'] );?>, google_business_vertical: 'retail' } order['products'] ) ) echo ',';?> ] + }, + user_data: { + email: " order['client_email'] ?>", + phone_number: " order['client_phone'] ?>", + first_name: " order['client_name'] ?>", + last_name: " order['client_surname'] ?>", + street: " order['client_street'] ?>", + city: " order['client_city'] ?>", + country: "PL", + postal_code: " order['client_postal_code'] ?>" } }); diff --git a/templates_user/shop-product/product.php b/templates_user/shop-product/product.php index d337cf2..0ecc00b 100644 --- a/templates_user/shop-product/product.php +++ b/templates_user/shop-product/product.php @@ -247,16 +247,17 @@ dataLayer.push({ event: "view_item", ecommerce: { + currency: "PLN", + value: product['price_brutto_promo'] ): echo \Shared\Helpers\Helpers::normalize_decimal( $this -> product['price_brutto_promo'] ); else: echo \Shared\Helpers\Helpers::normalize_decimal( $this -> product['price_brutto'] ); endif;?>, items: [ { item_id: " product['id'];?>", item_name: " product['language']['name'] );?>", - price: ' product['price_brutto_promo'] ): echo \Shared\Helpers\Helpers::normalize_decimal( $this -> product['price_brutto_promo'] ); else: echo \Shared\Helpers\Helpers::normalize_decimal( $this -> product['price_brutto'] ); endif;?>', + price: product['price_brutto_promo'] ): echo \Shared\Helpers\Helpers::normalize_decimal( $this -> product['price_brutto_promo'] ); else: echo \Shared\Helpers\Helpers::normalize_decimal( $this -> product['price_brutto'] ); endif;?>, quantity: 1, google_business_vertical: "retail" } - ], - value: product['price_brutto_promo'] ): echo \Shared\Helpers\Helpers::normalize_decimal( $this -> product['price_brutto_promo'] ); else: echo \Shared\Helpers\Helpers::normalize_decimal( $this -> product['price_brutto'] ); endif;?> + ] } }); @@ -573,7 +574,7 @@ item_id: " product['id'];?>", item_name: " product['language']['name'] );?>", price: product['price_brutto_promo'] ): echo \Shared\Helpers\Helpers::normalize_decimal( $this -> product['price_brutto_promo'] ); else: echo \Shared\Helpers\Helpers::normalize_decimal( $this -> product['price_brutto'] ); endif;?>, - quantity: quantity, + quantity: parseInt(quantity), google_business_vertical: "retail" } ]