Community Forums

[MOD/vQmod] - Only Generate Single Temp Order Id

Free manual modifications can be contributed here. Modifications are manual snippets of code that are pasted into the forums for others to use.

[MOD/vQmod] - Only Generate Single Temp Order Id

Postby Qphoria » Mon Jan 04, 2010 8:33 pm

UPDATE: NOW SUPPORTS 1.4.7 through 1.5.5.1 VQMOD VERSION (Attached)

Many people have commented about their distaste for the way OpenCart generates a new order id each time the checkout/confirm page is reloaded.

This is a very simple modification to force the cart to reuse the same order id once it has been set at the session level. This means, that if a customer gets to the confirm page and his order id is 101, if he goes back and buys more and returns to the confirm page, it will still be order id 101.

This will cut down on the thousands of "no status" orders that get generated for a single person who can't make up his mind.

INCLUDES FIX FOR ORDER STATUS CHECK TO RESOLVE POTENTIAL FOR CUSTOMER CLICKING BACK ALL THE WAY AFTER PAYMENT

Supports 1.4.7 through 1.5.5.1
You must install vQmod to use it
Attachments
single_temp_order_id.xml
(43.62 KiB) Downloaded 758 times
Image Image
Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
User avatar
Qphoria
Administrator
 
Posts: 18207
Joined: Mon Jul 21, 2008 7:02 pm
Donate to Qphoria

Re: [MOD] - Only Generate Single Temp Order Id

Postby richard211986 » Thu Mar 25, 2010 9:41 pm

Q, this mod if a customer places an item in the basket registers and clicks confirm order this obviously creates a missing order if they then go off site or press the back button another order is created.........does this mod stop that and only use 1 order number for the repeat same order session as such? ive got alot of invoices which ive just had to move to cancelled =/
richard211986
 
Posts: 146
Joined: Sat Sep 19, 2009 9:34 pm

Re: [MOD] - Only Generate Single Temp Order Id

Postby Qphoria » Thu Mar 25, 2010 9:42 pm

Yes.. if a customer goes to your site. When they get to the confirm page an order id is generated. If they hit refresh, another order id is generated, and so on.

With my mod, it stops this. It keeps the same order_id that was generated on the first load and prevents the constant regeneration of a new number while that customer session is logged in.
Image Image
Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
User avatar
Qphoria
Administrator
 
Posts: 18207
Joined: Mon Jul 21, 2008 7:02 pm
Donate to Qphoria

Re: [MOD] - Only Generate Single Temp Order Id

Postby Daniel » Thu Mar 25, 2010 10:01 pm

I'm sure the problem with this is that if paypal callback cannot get through and a customer click back instead of returning to the store the order with be overwritten.
OpenCart®
Project Owner & Developer.
OpenCart commercial support now available!
User avatar
Daniel
Administrator
 
Posts: 5173
Joined: Fri Nov 03, 2006 10:57 am

Re: [MOD] - Only Generate Single Temp Order Id

Postby Qphoria » Sun Mar 28, 2010 7:32 pm

No, A session doesn't change just because they click back vs click "Return". It would still be the same session id. If you are describing the rare situation where the callback didn't go through AND the customer clicked back 4 times, then it would be no different if a new temp order was created. You'd still end up with an uncleared cart and no finalized order state. Doesn't matter if the number is the same or different. I've been using this mod on my store since 1.3.0 and have never had a problem.
Image Image
Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
User avatar
Qphoria
Administrator
 
Posts: 18207
Joined: Mon Jul 21, 2008 7:02 pm
Donate to Qphoria

Re: [MOD] - Only Generate Single Temp Order Id

Postby Qphoria » Wed Mar 31, 2010 12:11 am

The Alchemist wrote:The goal is to get them to come back and complete the order

If installing this mod would still keep their orders accurate in their accounts.


Yes, that is still the goal. This does not change that. It just cuts down on the multiple temp orders per customer. orders ids are not reused across different people. Once it is used, its used.. and the order id that is first generated for that customer session will remain his for that session. If he ends up leaving then you only have 1 dead order instead of multiple. If he comes back 3 hours later and has to re-login, then that session is over and he will get a new number, but only one number.

(Added version for v1.3.2)
1. EDIT: catalog/model/checkout/order.php
2. FIND (around line 21 & 23):
Code: Select all
$this->db->query("INSERT INTO `" . DB_PREFIX . "order` SET customer_id = '" . (int)$data['customer_id'] . "', firstname = '" . $this->db->escape($data['firstname']) . "', lastname = '" . $this->db->escape($data['lastname']) . "', email = '" . $this->db->escape($data['email']) . "', telephone = '" . $this->db->escape($data['telephone']) . "', fax = '" . $this->db->escape($data['fax']) . "', total = '" . (float)$data['total'] . "', language_id = '" . (int)$data['language_id'] . "', currency = '" . $this->db->escape($data['currency']) . "', currency_id = '" . (int)$data['currency_id'] . "', value = '" . (float)$data['value'] . "', coupon_id = '" . (int)$data['coupon_id'] . "', ip = '" . $this->db->escape($data['ip']) . "', shipping_firstname = '" . $this->db->escape($data['shipping_firstname']) . "', shipping_lastname = '" . $this->db->escape($data['shipping_lastname']) . "', shipping_company = '" . $this->db->escape($data['shipping_company']) . "', shipping_address_1 = '" . $this->db->escape($data['shipping_address_1']) . "', shipping_address_2 = '" . $this->db->escape($data['shipping_address_2']) . "', shipping_city = '" . $this->db->escape($data['shipping_city']) . "', shipping_postcode = '" . $this->db->escape($data['shipping_postcode']) . "', shipping_zone = '" . $this->db->escape($data['shipping_zone']) . "', shipping_country = '" . $this->db->escape($data['shipping_country']) . "', shipping_address_format = '" . $this->db->escape($data['shipping_address_format']) . "', shipping_method = '" . $this->db->escape($data['shipping_method']) . "', payment_firstname = '" . $this->db->escape($data['payment_firstname']) . "', payment_lastname = '" . $this->db->escape($data['payment_lastname']) . "', payment_company = '" . $this->db->escape($data['payment_company']) . "', payment_address_1 = '" . $this->db->escape($data['payment_address_1']) . "', payment_address_2 = '" . $this->db->escape($data['payment_address_2']) . "', payment_city = '" . $this->db->escape($data['payment_city']) . "', payment_postcode = '" . $this->db->escape($data['payment_postcode']) . "', payment_zone = '" . $this->db->escape($data['payment_zone']) . "', payment_country = '" . $this->db->escape($data['payment_country']) . "', payment_address_format = '" . $this->db->escape($data['payment_address_format']) . "', payment_method = '" . $this->db->escape($data['payment_method']) . "', comment = '" . $this->db->escape($data['comment']) . "', date_modified = NOW(), date_added = NOW()");

      $order_id = $this->db->getLastId();


REPLACE WITH:
Code: Select all
//Q: Prevent generating new temp order each time confirmation page loads.
      if (!isset($this->session->data['order_id'])) {
         $this->db->query("INSERT INTO `" . DB_PREFIX . "order` SET customer_id = '" . (int)$data['customer_id'] . "', firstname = '" . $this->db->escape($data['firstname']) . "', lastname = '" . $this->db->escape($data['lastname']) . "', email = '" . $this->db->escape($data['email']) . "', telephone = '" . $this->db->escape($data['telephone']) . "', fax = '" . $this->db->escape($data['fax']) . "', total = '" . (float)$data['total'] . "', language_id = '" . (int)$data['language_id'] . "', currency = '" . $this->db->escape($data['currency']) . "', currency_id = '" . (int)$data['currency_id'] . "', value = '" . (float)$data['value'] . "', coupon_id = '" . (int)$data['coupon_id'] . "', ip = '" . $this->db->escape($data['ip']) . "', shipping_firstname = '" . $this->db->escape($data['shipping_firstname']) . "', shipping_lastname = '" . $this->db->escape($data['shipping_lastname']) . "', shipping_company = '" . $this->db->escape($data['shipping_company']) . "', shipping_address_1 = '" . $this->db->escape($data['shipping_address_1']) . "', shipping_address_2 = '" . $this->db->escape($data['shipping_address_2']) . "', shipping_city = '" . $this->db->escape($data['shipping_city']) . "', shipping_postcode = '" . $this->db->escape($data['shipping_postcode']) . "', shipping_zone = '" . $this->db->escape($data['shipping_zone']) . "', shipping_country = '" . $this->db->escape($data['shipping_country']) . "', shipping_address_format = '" . $this->db->escape($data['shipping_address_format']) . "', shipping_method = '" . $this->db->escape($data['shipping_method']) . "', payment_firstname = '" . $this->db->escape($data['payment_firstname']) . "', payment_lastname = '" . $this->db->escape($data['payment_lastname']) . "', payment_company = '" . $this->db->escape($data['payment_company']) . "', payment_address_1 = '" . $this->db->escape($data['payment_address_1']) . "', payment_address_2 = '" . $this->db->escape($data['payment_address_2']) . "', payment_city = '" . $this->db->escape($data['payment_city']) . "', payment_postcode = '" . $this->db->escape($data['payment_postcode']) . "', payment_zone = '" . $this->db->escape($data['payment_zone']) . "', payment_country = '" . $this->db->escape($data['payment_country']) . "', payment_address_format = '" . $this->db->escape($data['payment_address_format']) . "', payment_method = '" . $this->db->escape($data['payment_method']) . "', comment = '" . $this->db->escape($data['comment']) . "', date_modified = NOW(), date_added = NOW()");
         $order_id = $this->db->getLastId();
      } else {
         $order_id = $this->session->data['order_id'];
         $this->db->query("UPDATE `" . DB_PREFIX . "order` SET customer_id = '" . (int)$data['customer_id'] . "', firstname = '" . $this->db->escape($data['firstname']) . "', lastname = '" . $this->db->escape($data['lastname']) . "', email = '" . $this->db->escape($data['email']) . "', telephone = '" . $this->db->escape($data['telephone']) . "', fax = '" . $this->db->escape($data['fax']) . "', total = '" . (float)$data['total'] . "', language_id = '" . (int)$data['language_id'] . "', currency = '" . $this->db->escape($data['currency']) . "', currency_id = '" . (int)$data['currency_id'] . "', value = '" . (float)$data['value'] . "', coupon_id = '" . (int)$data['coupon_id'] . "', ip = '" . $this->db->escape($data['ip']) . "', shipping_firstname = '" . $this->db->escape($data['shipping_firstname']) . "', shipping_lastname = '" . $this->db->escape($data['shipping_lastname']) . "', shipping_company = '" . $this->db->escape($data['shipping_company']) . "', shipping_address_1 = '" . $this->db->escape($data['shipping_address_1']) . "', shipping_address_2 = '" . $this->db->escape($data['shipping_address_2']) . "', shipping_city = '" . $this->db->escape($data['shipping_city']) . "', shipping_postcode = '" . $this->db->escape($data['shipping_postcode']) . "', shipping_zone = '" . $this->db->escape($data['shipping_zone']) . "', shipping_country = '" . $this->db->escape($data['shipping_country']) . "', shipping_address_format = '" . $this->db->escape($data['shipping_address_format']) . "', shipping_method = '" . $this->db->escape($data['shipping_method']) . "', payment_firstname = '" . $this->db->escape($data['payment_firstname']) . "', payment_lastname = '" . $this->db->escape($data['payment_lastname']) . "', payment_company = '" . $this->db->escape($data['payment_company']) . "', payment_address_1 = '" . $this->db->escape($data['payment_address_1']) . "', payment_address_2 = '" . $this->db->escape($data['payment_address_2']) . "', payment_city = '" . $this->db->escape($data['payment_city']) . "', payment_postcode = '" . $this->db->escape($data['payment_postcode']) . "', payment_zone = '" . $this->db->escape($data['payment_zone']) . "', payment_country = '" . $this->db->escape($data['payment_country']) . "', payment_address_format = '" . $this->db->escape($data['payment_address_format']) . "', payment_method = '" . $this->db->escape($data['payment_method']) . "', comment = '" . $this->db->escape($data['comment']) . "', date_modified = NOW(), date_added = NOW() WHERE order_id = '" . (int)$order_id . "'");
         $this->db->query("DELETE FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int)$order_id . "'");
         $this->db->query("DELETE FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int)$order_id . "'");
         $this->db->query("DELETE FROM " . DB_PREFIX . "order_download WHERE order_id = '" . (int)$order_id . "'");
         $this->db->query("DELETE FROM " . DB_PREFIX . "order_total WHERE order_id = '" . (int)$order_id . "'");
      }//->db->query("DELETE FROM " . DB_PREFIX . "order_total WHERE order_id = '" . (int)$order_id . "'");
         }//
Image Image
Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
User avatar
Qphoria
Administrator
 
Posts: 18207
Joined: Mon Jul 21, 2008 7:02 pm
Donate to Qphoria

Re: [MOD] - Only Generate Single Temp Order Id

Postby richard211986 » Wed Mar 31, 2010 8:40 am

Hi Q,

Ive tried the above code and still get an error when i click on payment type then continue here is the error

Parse error: syntax error, unexpected T_FOREACH, expecting T_FUNCTION in /home/www/thegadgetshack.co.uk/catalog/model/checkout/order.php on line 36

do you think its because i have renamed to payment modules as such without changing the name in all files?

regards
Richard
richard211986
 
Posts: 146
Joined: Sat Sep 19, 2009 9:34 pm

Re: [MOD] - Only Generate Single Temp Order Id

Postby jefrey1983 » Sun Apr 25, 2010 12:09 pm

question it create a session then it will create an order ID for a customer what if i didn't order i decided not to but will it still create the order id
User avatar
jefrey1983
 
Posts: 386
Joined: Sat Jan 30, 2010 10:58 am

Re: [MOD] - Only Generate Single Temp Order Id

Postby Qphoria » Sun Apr 25, 2010 8:35 pm

Yes. The temp order will still be created once.. even if they don't check out, they will still have the single order. It just won't create it 10 times if the same customer reloads the confirm page 10 times
Image Image
Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
User avatar
Qphoria
Administrator
 
Posts: 18207
Joined: Mon Jul 21, 2008 7:02 pm
Donate to Qphoria

Re: [MOD] - Only Generate Single Temp Order Id

Postby dbstr » Tue Apr 27, 2010 9:11 am

Any reason this wasn't added in 1.4.7? And will it be added in 1.4.8? :)
dbstr
 
Posts: 368
Joined: Sat Aug 29, 2009 4:20 pm

Re: [MOD] - Only Generate Single Temp Order Id

Postby American » Sun May 23, 2010 7:08 pm

dbstr wrote:Any reason this wasn't added in 1.4.7? And will it be added in 1.4.8? :)


I second that motion! I just had my first two orders using OC and the first was 4, then the next was 16. This could make things interesting if I need to research past orders for some reason. At the very least it makes things a bit messy.

It would be good to see this in 1.4.8.
Brad G
Fort Worth, Texas
OC 1.5.5.1
User avatar
American
 
Posts: 67
Joined: Thu May 20, 2010 11:39 pm
Location: Fort Worth, Texas

Re: [MOD/vQmod] - Only Generate Single Temp Order Id

Postby Qphoria » Thu Sep 22, 2011 2:45 pm

UPDATED first post.
- Added 1.5.x support
- Added order status id check as noted by CarpeNoctumDC above

This should actually resolve the concerns daniel had about adding it to the core now.
Image Image
Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
User avatar
Qphoria
Administrator
 
Posts: 18207
Joined: Mon Jul 21, 2008 7:02 pm
Donate to Qphoria

Re: [MOD/vQmod] - Only Generate Single Temp Order Id

Postby terrier » Fri Sep 23, 2011 3:28 am

Just wondering, let say if a customer go all the way up to confirm page and generates a new order id.

At the point of time, he decided to make the payment later and therefore close the browser. When he return and start to check out again, will he get a new order ID or reuse order iD?
terrier
 
Posts: 27
Joined: Wed Aug 31, 2011 11:05 am

Re: [MOD/vQmod] - Only Generate Single Temp Order Id

Postby Xsecrets » Fri Sep 23, 2011 3:55 am

terrier wrote:Just wondering, let say if a customer go all the way up to confirm page and generates a new order id.

At the point of time, he decided to make the payment later and therefore close the browser. When he return and start to check out again, will he get a new order ID or reuse order iD?

if you close the browser it kills the session, so they would get a new order_id the next time they came back.
Xsecrets
 
Posts: 5042
Joined: Sat Oct 24, 2009 7:51 pm
Location: FL US

Re: [MOD/vQmod] - Only Generate Single Temp Order Id

Postby terrier » Fri Sep 23, 2011 5:56 am

Hmm...

why is it not possible that order ID is generated only after clicking the confirm order?

Just like inv no. only generated after confirm order
terrier
 
Posts: 27
Joined: Wed Aug 31, 2011 11:05 am

Re: [MOD/vQmod] - Only Generate Single Temp Order Id

Postby Qphoria » Fri Sep 23, 2011 12:35 pm

terrier wrote:Hmm...

why is it not possible that order ID is generated only after clicking the confirm order?

Just like inv no. only generated after confirm order


The last step of the process is actually the payment form. Clicking Confirm goes directly to the external payment gateway url and doesn't go through opencart. So opencart creates a temp order one step earlier.

Yes, it could be possible to change this behavior and have it first send back to opencart, and then load the payment step with a jscript form submit onload like osc does it... or even with the ajax confirm step it could be done.. but it just isn't done like this at this time. Initially it was simpler to do it the way it is. This mod helps to retain the balance of the way you want it and the way it is.
Image Image
Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
User avatar
Qphoria
Administrator
 
Posts: 18207
Joined: Mon Jul 21, 2008 7:02 pm
Donate to Qphoria

Re: [MOD/vQmod] - Only Generate Single Temp Order Id

Postby scanreg » Fri Sep 23, 2011 4:10 pm

Thanks for this :)

Are there any plans to change the native method of order-id generation?
scanreg
 
Posts: 603
Joined: Wed May 05, 2010 4:15 pm

Re: [MOD/vQmod] - Only Generate Single Temp Order Id

Postby Qphoria » Fri Sep 23, 2011 4:13 pm

scanreg wrote:Thanks for this :)

Are there any plans to change the native method of order-id generation?


Not at this time
Image Image
Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
User avatar
Qphoria
Administrator
 
Posts: 18207
Joined: Mon Jul 21, 2008 7:02 pm
Donate to Qphoria

Re: [MOD/vQmod] - Only Generate Single Temp Order Id

Postby cpuricelli » Thu May 10, 2012 4:16 pm

Hi Qphoria, I installed the xml but seems that is not working, opencart is still generating new orders ID for missing orders. I have no logs in the vqmod log file, but I have another xml which changes the catalog/model/checkout/order.php ... can this be an issue?
cpuricelli
 
Posts: 9
Joined: Tue Aug 09, 2011 12:56 pm

Re: [MOD/vQmod] - Only Generate Single Temp Order Id

Postby Qphoria » Thu May 10, 2012 7:04 pm

dunno.. check your vqmod/vqmod.log file for errors
Also be aware that you will still get temp orders, just not a new one everytime you reload step 6 of checkout for the same person.

To test.

Goto step 6 of checkout
in another tab, check the Abandoned order filter in the admin order area
Then on the first time, click Modify for step 5 again
Then continue to step 6 again
In the other tab, check the abandoned order filter again
You should not see a new temp order for yourself

I am actively using in 1.5.1.3 store.. haven't had a chanced to test on 1.5.2.x yet
Image Image
Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
User avatar
Qphoria
Administrator
 
Posts: 18207
Joined: Mon Jul 21, 2008 7:02 pm
Donate to Qphoria

Next

Return to Modifications

Who is online

Users browsing this forum: yowchuan and 10 guests

Hosted by Arvixe Web Hosting