Answer the question
In order to leave comments, you need to log in
How to get order amount and ID from JavaScript in Opencart?
To integrate the store with another service, I need to run JS on the successful order page and get the order ID and the total amount in it.
JS looks something like this:
<script type="text/javascript">
// some code here
arr.push([
"create_order",
{order_id: "*order_id*", sum: *sum*}
]);
</script>
Questions
1. Where to insert JS? It looks like it's in success.tpl . If in it, then in what place? If in header.tpl , then how can I make it work only at the time of a successful order?
2. What variables contain the ID and the amount?
Tried like this, didn't work:
{order_id: "<?php echo $order_id; ?>", sum: <?php echo $product_total; ?>}
Answer the question
In order to leave comments, you need to log in
Here is this Stack Overflow answer that helped me: http://stackoverflow.com/a/19973271/2952652
The user may not wait for the confirmation page to load for various reasons. If you need to integrate, then it is better to do it from the server side. And yes, it will be safer.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question