Post by stenci » Fri Feb 23, 2018 1:26 am

I am working on a shipping cost calculator that manages the inventory on different locations and splits the items of the same order on several shipments. I think the logic is too complex for OpenCart, so I decided to create a new server to do the job. I may be wrong because I don't know OpenCart, but I don't want to risk to embark on a long project only to find out that I am asking too much from OpenCart.

So I created a new shipping cost extension for OpenCart that sends the info about the cart and the shipping address to another server. The second server crunches the numbers, and returns the shipping options to OpenCart. The user picks one of the options and continues with the checkout to the order confirmation page.

Everything works well until now.

Now I need to tell the second server that the order has been confirmed, so the inventory can be updated.

Is it possible, when the user clicks on Confirm Order, to:
1) send a request to the second server saying that the order has been confirmed
2) wait for the second server to respond, to make sure that everything went well
3) cancel the order if something went wrong

The second server will:
- when the shipping cost is calculated: put the material on hold and keep it on hold for the next 20 minutes
- when the order is confirmed: decrease the quantity on the inventory
- when the 20 minute expire without order confirmation: remove the hold on the material

Newbie

Posts

Joined
Tue Dec 05, 2017 4:50 am

Post by eft0 » Fri Feb 23, 2018 5:43 am

I do that in /catalog/controller/mail/order.php after the "// Send to additional alert emails" line 465

if ($data['order_status'] == 'Complete') // then do you stuff

Newbie

Posts

Joined
Thu Apr 22, 2010 5:24 am

Post by stenci » Fri Apr 13, 2018 12:42 am

I cannot find the file you mention. Perhaps because your version is different from mine.
I am working with OpenCart 2.3 and I think I found the file you mention in catalog/model/checkout/order.php.

I don't want just to do something when the order is confirmed (I think I could do that with the events as explained here).

I also want to be able to cancel the process of confirmation and tell the user that something went wrong.

If for example the user waited too long and there is no more material in the inventory, I want to be able to prevent the user from confirming the order. (My shipping cost extension manages the inventory because OpenCart cannot (or I don't know how to teach OpenCart to do it) manage inventory in several facilities, and I want to offer different shipping options, something like the fastest and more expensive because it will come from a farther facility that has it in stock or the cheaper that comes from the closest facility but there is a longer lead time).

Newbie

Posts

Joined
Tue Dec 05, 2017 4:50 am
Who is online

Users browsing this forum: Bing [Bot] and 258 guests