Post by CharmersVine99 » Fri May 08, 2015 10:27 pm

Hello,
I use the order ID as my inventory ID, so the fact that missing orders cause it to jump is causing problems. Currently I believe it is creating the order ID when you select a payment method, agree to terms and conditions, and click continue. I would like a suggestion as to changing the creation of the order ID until their payment succeeds (right before they are redirected to the success page).

I would hope this is something as easy as finding the code that creates the order ID in the 'checkout' file, and moving it to lower down in the file?

Any help greatly appreciated!


Posts

Joined
Sat Apr 04, 2015 1:50 am

Post by CharmersVine99 » Sat May 09, 2015 5:27 am

FYI: Using Opencart 2.0.1.1


Posts

Joined
Sat Apr 04, 2015 1:50 am

Post by G47F » Sat May 09, 2015 5:40 am

This has been a pet peeve of mine with Opencart for a while now. As far as I'm aware there is no way around this, unfortunately. You'll probably just have to learn to live with it (as I have).

New member

Posts

Joined
Sat Feb 08, 2014 6:51 am

Post by CharmersVine99 » Tue May 12, 2015 9:22 pm

Very unfortunate.

The other thing is that when I go into the database and manually change my order_id (from say 100) back down to the number I want (say 50) and change it in tables: *_orders, *_order_history, *_order_option, *_order_product, *_order_total), it will work for that order, but then the next order will show up as 101, not 51. So it is counting the order numbers somewhere else, and I cannot find out where. When I download the db as a spreadsheet, and search all tables for '50' or '100', it only comes up in those tables I listed above (also searched 'order_id' everywhere, nothing). So how is it knowing that my last order_id was 100, and not 50?


Posts

Joined
Sat Apr 04, 2015 1:50 am

Post by artcore » Tue May 12, 2015 9:48 pm

Auto increment on xxxxxxx_id columns in the database keeps track of this.
This can be viewed and changed in a database editor like phpmyadmin.
Be very careful changing this! Always backup!

It should be possible to renumber these id columns on an hourly basis, automatically, but I'm not sure if such script can keep all the involved tables to point to the same item. The totals table comes to mind :drunk: ???

Attn: I no longer provide OpenCart extensions, nor future support - this includes forum posts.
Reason: OpenCart version 3+ ;D

Thanks!


User avatar
Active Member

Posts

Joined
Tue Jul 09, 2013 4:13 am
Location - The Netherlands

Post by Dhaupin » Wed May 13, 2015 2:06 am

The order is actually created after the payment method step...it just seems like its that step that is doing it. As soon as you hit the payment confirm step, things are validated, and if you are not redirected, the controller/checkout/confirm.php fires this:

Code: Select all

$this->session->data['order_id'] = $this->model_checkout_order->addOrder($order_data);
Then in model/checkout/order.php there is a big insert, which doesn't have to do with payment method per-say. You could perhaps edit that function to look for and successfully validate *something* from the payment details, such as a card number put through a Luhn function, or perhaps callback from payment processor. The hard part about this is figuring out how and what since all the payment processors are different :)

https://creadev.org | support@creadev.org - Opencart Extensions, Integrations, & Development. Made in the USA.


User avatar
Active Member

Posts

Joined
Tue May 13, 2014 3:45 am
Location - PA

Post by sculptex » Wed May 13, 2015 3:19 am

For many, it is a big positive that unpaid orders are stored because they can be recalled and turned into orders (FILTER: order status > missing orders)

Why not generate invoices for all your successful orders and use the invoice number as the basis of your inventory ID?

ImageImage


User avatar
Active Member

Posts

Joined
Tue Sep 13, 2011 3:07 am
Location - UK

Post by artcore » Wed May 13, 2015 4:25 am

I haven't looked at it but the new order_id is still the auto_incremented from the db, not? So rearranging the ids omitting the failed/deleted orders would be like I said. Correct me if I'm wrong ;)

Attn: I no longer provide OpenCart extensions, nor future support - this includes forum posts.
Reason: OpenCart version 3+ ;D

Thanks!


User avatar
Active Member

Posts

Joined
Tue Jul 09, 2013 4:13 am
Location - The Netherlands

Post by CharmersVine99 » Thu May 14, 2015 1:42 am

Ok, so I have decided to just use the invoice # instead of the order ID.

I replaced 'order_id' with 'invoice_no' in my invoices, and that works.

Now what I want to do is on the dashboard and on order history, I want to display invoice number instead of order id (also in the search on the order history).

In the admin/view/template/sale/order_list.tpl I found the following code that fills the table.

Code: Select all

              <tbody>
                <?php if ($orders) { ?>
                <?php foreach ($orders as $order) { ?>
                <tr>
                  <td class="text-center"><?php if (in_array($order['order_id'], $selected)) { ?>
                    <input type="checkbox" name="selected[]" value="<?php echo $order['order_id']; ?>" checked="checked" />
                    <?php } else { ?>
                    <input type="checkbox" name="selected[]" value="<?php echo $order['order_id']; ?>" />
                    <?php } ?>
                    <input type="hidden" name="shipping_code[]" value="<?php echo $order['shipping_code']; ?>" /></td>
<td class="text-right"><?php echo $order['order_id']; ?></td>
<td class="text-left"><?php echo $order['customer']; ?></td>
<td class="text-left"><?php echo $order['status']; ?></td>
<td class="text-right"><?php echo $order['total']; ?></td>
<td class="text-left"><?php echo $order['date_added']; ?></td>
<td class="text-left"><?php echo $order['date_modified']; ?></td>
I tried replacing "<?php echo $order['order_id']; ?>" with:
<?php echo $order['invoice_no']; ?>
<?php echo $invoice_no; ?>

but I get undefined variable invoice_no. I supposed I need to define the invoice_no for this page?

Can someone point me in the right direction?
Thanks.


Posts

Joined
Sat Apr 04, 2015 1:50 am
Who is online

Users browsing this forum: No registered users and 45 guests