This commit is contained in:
2026-03-28 11:29:41 +01:00
parent d366a58d28
commit bf82685e8f
9 changed files with 131 additions and 46 deletions

View File

@@ -35,6 +35,7 @@
</div>
<? if ( $this -> settings['google_tag_manager_id'] && is_array( $this -> basket ) && count( $this -> basket ) ):?>
<script>
dataLayer.push({ ecommerce: null });
dataLayer.push({
event: "view_cart",
ecommerce: {
@@ -49,7 +50,7 @@
if ( $view_cart_items ) $view_cart_items .= ',';
$view_cart_items .= '{';
$view_cart_items .= '"item_id": "' . $product['id'] . '",';
$view_cart_items .= '"item_name": "' . $product['language']['name'] . '",';
$view_cart_items .= '"item_name": "' . str_replace( '"', '', $product['language']['name'] ) . '",';
$view_cart_items .= '"price": ' . \Shared\Helpers\Helpers::normalize_decimal( $price_product['price_new'] ) . ',';
$view_cart_items .= '"quantity": ' . (int)$position['quantity'] . ',';
$view_cart_items .= '"google_business_vertical": "retail"';

View File

@@ -74,7 +74,7 @@
$begin_checkout_items .= '{';
$begin_checkout_items .= '"item_id": "' . $product['id'] . '",';
$begin_checkout_items .= '"item_name": "' . $product['language']['name'] . '",';
$begin_checkout_items .= '"item_name": "' . str_replace( '"', '', $product['language']['name'] ) . '",';
$begin_checkout_items .= '"price": ' . \Shared\Helpers\Helpers::normalize_decimal( $price_product['price_new'] ) . ',';
$begin_checkout_items .= '"quantity": ' . (int)$position['quantity'] . ',';
$begin_checkout_items .= '"google_business_vertical": "retail"';
@@ -186,4 +186,4 @@
}
});
<? endif;?>
</script>
</script>

View File

@@ -163,6 +163,7 @@
<? if ( \Shared\Helpers\Helpers::get_session('google-analytics-purchase') ):?>
<? if ( $this -> settings['google_tag_manager_id'] ):?>
dataLayer.push({ ecommerce: null });
dataLayer.push({
event: "purchase",
ecommerce: {
@@ -174,9 +175,9 @@
<? foreach ( $this -> order['products'] as $product ):?>
{
item_id: "<?= $product['product_id'];?>",
item_name: '<?= $product['name'];?>',
item_name: "<?= str_replace( '"', '', $product['name'] );?>",
quantity: <?= (int)$product['quantity'];?>,
price: <?= (float)$product['price_brutto_promo'] > 0 ? \Shared\Helpers\Helpers::normalize_decimal( $product['price_brutto_promo'] ) : \Shared\Helpers\Helpers::normalize_decimal( $product['price_brutto'] );?>,
price: <?= ((float)$product['price_brutto_promo'] > 0 && (float)$product['price_brutto_promo'] < (float)$product['price_brutto']) ? \Shared\Helpers\Helpers::normalize_decimal( $product['price_brutto_promo'] ) : \Shared\Helpers\Helpers::normalize_decimal( $product['price_brutto'] );?>,
google_business_vertical: 'retail'
}<? if ( $product != end( $this -> order['products'] ) ) echo ',';?>
<? endforeach;?>
@@ -194,7 +195,7 @@
}
});
<? endif;?>
<? unset( $_SESSION['google-adwords-purchase'] );?>
<? unset( $_SESSION['google-analytics-purchase'] );?>
<? endif;?>
});
</script>
</script>

View File

@@ -244,6 +244,7 @@
<script type="text/javascript">
$( function() {
<? if ( $this -> settings['google_tag_manager_id'] ):?>
dataLayer.push({ ecommerce: null });
dataLayer.push({
event: "view_item",
ecommerce: {
@@ -564,6 +565,7 @@
<? if ( $this -> settings['google_tag_manager_id'] ):?>
var add_to_cart_value = <? if ( $this -> 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;
dataLayer.push({ ecommerce: null });
dataLayer.push({
event: "add_to_cart",
ecommerce: {
@@ -665,4 +667,4 @@
});
return false;
}
</script>
</script>