-- HikaShop version -- : 4.4.0
Hello,
I try to create marker in Analytics in the following file show_block_cart.php
Here is the code:
gtag('event', 'begin_checkout', {
"items": [
<?php $count = count($cart->products); ?>
<?php foreach($cart->products as $i => $product){ ?>
{
"id": "<?php echo $product->product_id; ?>",
"name": "<?php echo strip_tags($product->product_name); ?>",
"quantity": <?php echo $product->cart_product_quantity; ?>,
"price": '<?php echo $product->prices[0]->price_value; ?>'
}<?php if ($i > $count - 1) echo ","; ?>
<?php $k = 1-$k; } ?>
],
"coupon": "<?php echo $cart->coupon->discount_value;?>"
});
For products without Characteristics, everything works fine.
For products with Characteristics: in the script, there is the selected variant from the shopping cart + the main product with 0 quantity (which is not in the shopping cart).
gtag('event', 'begin_checkout', {
"items": [
{
"id": "81",
"name": "Dress color: black: S",
"quantity": 1,
"price": '29'
}, {
"id": "13",
"name": "Bag",
"quantity": 1,
"price": '28'
}, {
"id": "80",
"name": "Dress color: black",
"quantity": 0,
"price": '29.00000'
} ],
"coupon": "5.7"
});
Can you help me with this issue?
Best regards!