R
R
Roman Shamin2013-11-13 19:27:58
PHP
Roman Shamin, 2013-11-13 19:27:58

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

3 answer(s)
R
Roman Shamin, 2013-11-14
@romanshamin

Here is this Stack Overflow answer that helped me: http://stackoverflow.com/a/19973271/2952652

P
Par Mactep, 2013-11-13
@parmactep

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.

L
lynnikvadim, 2014-11-16
@lynnikvadim

How else can I display the selected delivery method?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question