I have installed Journal 3x theme for Opencart Version 3.0.3.2.
In order to receive order conversions in the Google Ads service, I have to paste a code on the order complete page. This code should only be found on the order completion page that appears after you press the complete shopping button. How can I do that.
I tried this with an external plug-in but they were not compatible with theme files so it didn't work. I would be glad if you help.
I reach the order complete page with catalog / view / theme / journal3 / template / common / success.twig, but this is the body of the order complete page. I need to put this code in <head> </head> tags. (Not for the entire site, only for the order completion page)
When I add something to the header.twig file in the same folder, I cannot view it anywhere on the site. (After adding something, I make the necessary renewal from the developer settings from the admin panel, but it still does not work)
I found the following topics in the forum, but I either did not understand the solution or misunderstood and applied it incorrectly. In short, I could not reach a conclusion with these links.
viewtopic.php?f=202&t=217624&p=786182&h ... ds#p786182
viewtopic.php?f=202&t=217624&hilit=checkout+ads
viewtopic.php?f=202&t=207086&hilit=checkout+ads
viewtopic.php?f=202&t=210287&hilit=checkout+ads
Can you help me about this topic?
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
straightlight wrote: ↑Tue Nov 03, 2020 10:26 pmWith the original theme, this link works perfectly: viewtopic.php?f=202&t=217624&p=786182&h ... ds#p786182 .
As a matter of fact, I studied that text a lot, but I could not understand it. Let me examine it again in the evening with a calm mind. Thank you.
Having said that, don't use Journal3, use a proper standard-compliant web theme. But in this case, above approach could even work for the Journal3 framework, too.
Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig
pprmkr wrote: ↑Sun Sep 23, 2018 2:52 pmFirst edit catalog/controller/checkout/success.php:
After:Paste:Code: Select all
if (isset($this->session->data['order_id'])) {
Then edit catalog/view/theme/default/template/common/success.twig:Code: Select all
$data['transaction_id'] = $this->session->data['order_id']; $data['cart_total'] = $this->cart->getTotal();
Before:Paste:Code: Select all
{{ footer }}
Edit code to fit your needs.Code: Select all
{% if transaction_id is defined %} transaction ID = {{ transaction_id }} cart Total = {{ cart_total }} Use these values if needed as parameter in tag.js for example: <!-- Event snippet for Example conversion page --> <script> gtag('event', 'conversion', {'send_to': 'AW-123456789/AbC-D_efG-h12_34-567', 'value': {{ cart_total }}, 'currency': 'USD', 'transaction_id': '{{ transaction_id }}' }); </script> {% endif %}
Thank you so much.
It works, but I didn't add the code to the head field. I added it on the footer as in the quote but the tag assistant still reads. Is it ok if I don't add it to the head area?

Attachments
adsS.png (158.64 KiB) Viewed 2589 times
Sorry, I could not understand what you mean. It may be because my English is not sufficient. Do you think the above method is correct?JNeuhoff wrote: ↑Tue Nov 03, 2020 11:22 pmThis requires event handlers for the triggers catalog/controller/checkout/success/before (to save the order_id into a session variable), and catalog/controller/checkout/success/after (to modify the <header> section of the output for the given order_id, and then to clear the session variable)
Having said that, don't use Journal3, use a proper standard-compliant web theme. But in this case, above approach could even work for the Journal3 framework, too.
It's not. You're editing core files while event handlers are being suggested.fguzels wrote: ↑Wed Nov 04, 2020 6:13 pmSorry, I could not understand what you mean. It may be because my English is not sufficient. Do you think the above method is correct?JNeuhoff wrote: ↑Tue Nov 03, 2020 11:22 pmThis requires event handlers for the triggers catalog/controller/checkout/success/before (to save the order_id into a session variable), and catalog/controller/checkout/success/after (to modify the <header> section of the output for the given order_id, and then to clear the session variable)
Having said that, don't use Journal3, use a proper standard-compliant web theme. But in this case, above approach could even work for the Journal3 framework, too.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig
straightlight wrote: ↑Wed Nov 04, 2020 8:13 pmIt's not. You're editing core files while event handlers are being suggested.
I don't know how to do this.
Documentation: https://github.com/opencart/opencart/wiki/Events-System .fguzels wrote: ↑Thu Nov 05, 2020 3:45 pmstraightlight wrote: ↑Wed Nov 04, 2020 8:13 pmIt's not. You're editing core files while event handlers are being suggested.I don't know how to do this.
However, if you are unable to follow this documentation, you could always create a new service request in the Commercial Support section of the forum, or contact an Opencart partner by using the resources link at the top of the site, or contact me directly via PM to get this done as a custom job.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Code: Select all
<?php
class ControllerEventAds extends Controller {
// catalog/controller/checkout/success/after
public function index(&$route, &$args, &$output) {
if (isset($this->session->data['order_id'])) {
$this->load->model('checkout/order');
$order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']);
if ($order_info) {
$data = $this->response->getOutput();
if ($data) {
$data['ads'] = $this->load->controller('checkout/ads');
$output .= str_replace('{{ footer }}', '{% if ads %}{{ ads }}{% endif %}' . "\n{{ footer }}", $output);
}
}
}
}
}
Code: Select all
<?php
class ControllerCheckoutAds extends Controller {
public function index() {
if (isset($this->session->data['order_id'])) {
$data['transaction_id'] = $this->session->data['order_id'];
$data['cart_total'] = $this->cart->getTotal();
return $this->load->view('checkout/ads');
}
}
}
Add:
Code: Select all
{% if transaction_id is defined %}
transaction ID = {{ transaction_id }}
cart Total = {{ cart_total }}
Use these values if needed as parameter in tag.js
for example:
<!-- Event snippet for Example conversion page -->
<script>
gtag('event', 'conversion', {'send_to': 'AW-123456789/AbC-D_efG-h12_34-567',
'value': {{ cart_total }},
'currency': 'USD',
'transaction_id': '{{ transaction_id }}'
});
</script>
{% endif %}
Code: Select all
INSERT INTO `oc_event` (`code`, `trigger`, `action`, `status`, `sort_order`) VALUES ('checkout_ads', 'catalog/controller/checkout/success/after', 'event/ads', 1, 0);
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig
The catalog/controller/extension folder are for group extensions which, also, are loaded from the header. I would not advise to create event triggers into that location since this folder is not being used for the same concept as Events especially if it needs to be shown to others on the forum. As for the installable OCMod ZIP files, using the checkout folder is still available since the project files are still being stored in the storage folder. The idea on the above was to show how the Events themselves works. Afterwards, the concept remains the same on how and where the project files should be stored into as opposed to work directly on core files.JNeuhoff wrote: ↑Fri Nov 06, 2020 4:48 pmThe catalog/controller/event and catalog/controller/checkout folders are not among the ones which are allowed to take files from OpenCart extensions. Your class files should go into the catalog/controller/extension folder. Otherwise, the only way to add these new files is via FTP instead of the OpenCart installer. Quote often I bundle all the new files into an upload folder, and create an installable ocmod.zip archive for the OC installer.
As for the event folder, perhaps both triggers could be launched from the checkout folder under two separated methods instead of both using index() and modify their targets from the oc_event. That's another way to do it.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Code: Select all
// A list of allowed directories to be written to
$allowed = array(
'admin/controller/extension/',
'admin/language/',
'admin/model/extension/',
'admin/view/image/',
'admin/view/javascript/',
'admin/view/stylesheet/',
'admin/view/template/extension/',
'catalog/controller/extension/',
'catalog/language/',
'catalog/model/extension/',
'catalog/view/javascript/',
'catalog/view/theme/',
'system/config/',
'system/library/',
'image/catalog/'
);
Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Users browsing this forum: Amazon [Bot] and 4 guests