This
Code: Select all
<script>
gtag('event', 'add_to_cart', {
'send_to': 'AW-xxxxxxxxxx',
'value': '{{price}}',
'items': [{
'id': '{{ product.product_id }}',
'google_business_vertical': 'retail'
}]
});
</script>
This
Code: Select all
<script>
gtag('event', 'add_to_cart', {
'send_to': 'AW-xxxxxxxxxx',
'value': '{{price}}',
'items': [{
'id': '{{ product.product_id }}',
'google_business_vertical': 'retail'
}]
});
</script>
straightlight wrote: ↑Fri Jul 09, 2021 11:25 pmThen, to use: {{ product.quantity }} and {{ product.product_id }} in cart.twig file.
Majnoon wrote: ↑Sun Jul 11, 2021 7:39 pmCode: Select all
<script> gtag('event', 'add_to_cart', { 'send_to': 'AW-xxxxxxxxxx', 'value': '{{price}}', 'items': [{ 'id': '{{ product.product_id }}', 'google_business_vertical': 'retail' }] }); </script>
doesstraightlight wrote: ↑Sat Jul 10, 2021 1:26 amInstructions unfollowed with TWIG file. Read the above again.
Code: Select all
{{price}}
Code: Select all
{{product.product_id}}
DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.
https://www.youtube.com/watch?v=zXIxDoCRc84
I don't think so it can be the same asby mona wrote: ↑Sun Jul 11, 2021 9:00 pmdoeslook the same asCode: Select all
{{price}}
Code: Select all
{{product.product_id}}
Code: Select all
{{product.product_id}}
Code: Select all
'product_id'=> $product['product_id'],
Code: Select all
{{product.product_id}}
Code: Select all
'price' => $price,
Code: Select all
{{product.product_id}}
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Including the changes in category.php controller file, yes.Majnoon wrote: ↑Mon Jul 12, 2021 7:52 pmThanks @straightlight.straightlight wrote: ↑Mon Jul 12, 2021 5:31 pmThe array is product. It's no different than product ID and quantity. {{ product.price }}.
Will the same code work on category.twig
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
I have made the changes as suggested.straightlight wrote: ↑Mon Jul 12, 2021 7:56 pmIncluding the changes in category.php controller file, yes.
Which is why, it is best to keep things simple by creating an extension for this rather than playing with core files.Majnoon wrote: ↑Mon Jul 12, 2021 9:05 pmI have made the changes as suggested.straightlight wrote: ↑Mon Jul 12, 2021 7:56 pmIncluding the changes in category.php controller file, yes.
will there be files (cart.php & cart.twig) in the storage/modification?
As i am seeing only modification file for cart.php but not for theme.
I have refresh the cache and modifications though.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
straightlight wrote: ↑Mon Jul 12, 2021 9:07 pmWhich is why, it is best to keep things simple by creating an extension for this rather than playing with core files.
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<modification>
<name>Google ads event</name>
<version>1.0.0</version>
<author>straightlight</author>
<link>https://forum.opencart.com/</link>
<code>GAE</code>
<file path="catalog/controller/common/cart.php">
<operation>
<search><![CDATA['cart_id' => $product['cart_id'],]]></search>
<add position="after"><![CDATA['product_id'=> $product['product_id'],]]></add>
</operation>
</file>
<file path="catalog/view/theme/default/template/common/cart.twig">
<operation>
<search><![CDATA[<div id="cart" class="btn-group btn-block">]]></search>
<add position="before"><![CDATA[<script>
gtag('event', 'add_to_cart', {
'send_to': 'AW-xxxxxxxxx,
'value': '{{product.price}}',
'items': [{
'id': '{{ product.product_id }}',
'google_business_vertical': 'retail'
}]
});
</script>
]]></add>
</operation>
</file>
</modification>
Not supported on the forum@straightlight just a question will this code works for journal user as well?
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Users browsing this forum: Bing [Bot], shanghua and 463 guests