Post by moodleboy » Thu Feb 18, 2016 12:35 pm

For some reason, OC will not respect the specials price when an order is edited, which results in all sorts of bizarre workarounds (http://forum.opencart.com/viewtopic.php?f=20&t=151343). Apparently, this not considered a bug (https://github.com/opencart/opencart/issues/3797) and, of course, any attempt to bring this to Daniel's attention predictably invokes a wrath of insults, poor grammar and punctuation, and a prompt closing of the issue.

I am trying to create a mod to correct this for 2.1.0.x but I am having some trouble. Currently, the edit order feature on the admin side uses the cart api. I need to be able to retrieve the order_id from the cart api so that I can retrieve the order date and subsequently find the special price, but I have no idea how to get it. I know that the product data is stored in $this->request->post['product'], but does anyone know how to get the order information?

Thanks in advance.

Newbie

Posts

Joined
Sun Feb 03, 2013 4:01 am

Post by Randem » Thu Feb 18, 2016 2:51 pm

Hi moodleboy,

Could you just add a credit to the order for the difference in price?

NEVER take serious; anyone who gives negative impact statements with no ABSOLUTE proof!
OpenCart Helpful Information * Upgrade 1.5 to 2.1 * Upgrade 2.1 to 2.2
"Why do people NEVER have enough time to do it right but ALWAYS enough time to do it over?"
DO NOT EVER GIVE SOMEONE YOU DON"T KNOW ADMIN ACCESS TO ANYTHING!
I am NOT affiliated with OpenCart


User avatar
Active Member

Posts

Joined
Sat Sep 27, 2014 9:17 am

Post by moodleboy » Thu Feb 18, 2016 10:27 pm

Hi Randem,

Thanks for the reply, but unfortunately that is just another "workaround" and not a real solution. It requires us (the store owners) to make manual calculations every time there is a change to the order and it also changes the order history for the customer, so if they go back and view their order the prices are different from what they paid.

The real solution is that when the items are loaded into the cart via the API, the system checks to see if it is an existing order and uses the date the order was created (oc_order.date_added) against then special_start and special_end dates instead of using NOW(). This is relatively easy, but I need to be able to access the order_id from the api and then I can make the necessary changes in catalog/product.php

Any suggestions would be appreciated!

Thanks,
Paul

Newbie

Posts

Joined
Sun Feb 03, 2013 4:01 am

Post by Randem » Fri Feb 19, 2016 5:09 am

Not a work-around, basic accounting and audit trails. if you changed what actually transpired you leave yourself open to not knowing several months down the road what actually happen but only what you made happen with no evidence on how.

NEVER take serious; anyone who gives negative impact statements with no ABSOLUTE proof!
OpenCart Helpful Information * Upgrade 1.5 to 2.1 * Upgrade 2.1 to 2.2
"Why do people NEVER have enough time to do it right but ALWAYS enough time to do it over?"
DO NOT EVER GIVE SOMEONE YOU DON"T KNOW ADMIN ACCESS TO ANYTHING!
I am NOT affiliated with OpenCart


User avatar
Active Member

Posts

Joined
Sat Sep 27, 2014 9:17 am

Post by moodleboy » Fri Feb 19, 2016 6:38 am

if you changed what actually transpired you leave yourself open to not knowing several months down the road what actually happen but only what you made happen with no evidence on how
This is exactly what I am talking about - which is why the current setup is not correct. Suppose I have to make a change to the order: then under the current setup, if the customer purchased products while on special, then the order becomes completely different if the edit is made after the special expires. How is it better to completely change an order and leave a manually applied credit instead of leaving the order unchanged except for the edit (which could be recorded in the history for accounting/auditing purposes)

I'm not sure why logic would dictate that if you edit an order, the prices originally paid would change if the edit doesn't affect those items. For example, if the customer entered in the wrong email address and needs it corrected, or if one product needs to be substituted for another, why should the prices of the other items in the order change?

It sounds like you are advocating that orders shouldn't be edited at all - which is fine if your store doesn't require it. However, some of us do need to edit orders and therefore the editing process should not re-work the prices.

Please, do not take this as an insult, and I appreciate your suggestion. However, my situation requires me to edit an order while leaving the original prices intact regardless if a special expires or not.

If anyone has any suggestions on how to fix this bug, it would be very much appreciated.

For reference, here is a list of four bug reports on github regarding this that were all closed:
https://github.com/opencart/opencart/issues/3797
https://github.com/opencart/opencart/issues/1373
https://github.com/opencart/opencart/issues/3298
https://github.com/opencart/opencart/issues/3792

Newbie

Posts

Joined
Sun Feb 03, 2013 4:01 am

Post by Burt65 » Fri Feb 19, 2016 8:36 am

I think the main problem here is your approach to find a solution.

As Daniel pointed out, his way of dealing with a wrong order is to void it and make a new one. This is also the standard procedure in 100% of real life business where a purchase has been made. While in my short experience I had the need to void an order only twice, I can see that you may need to do it 100 times on a daily basis. I don't really understand why, but that's not the point...The point is that as far as Daniel concern, this is not a bug but the intended way he wants his software to work!

As I said before, I'm not judging right or wrong here, just stating the facts.

In your example your are mentioning a customer entering the wrong e-mail address, and unless you are selling software for download, that's not really a problem to complete the transaction as the postal service don't use emails for deliveries.
If the customer has enter other wrong details, he/she can edit them in their account. If they have purchase the wrong item or wrong quantities, then you really should void the order and create a new one (mainly for tax purposes)

So here is my suggestion. If you could explain here the why or the main reason you need to edit the orders so often, somebody (maybe under payment) would be able to provide you with an extension or a better approach to the solution of your problem. Like you said in your post "my situation requires me to edit an order"...

Or you can keep banging your head against the bug campaign, and maybe something that is only need by few, will make his way into a new version of OC... Your time...

Over 95% of all computer problems can be traced back to the interface between the keyboard and the chair...


User avatar
Active Member

Posts

Joined
Mon Nov 18, 2013 3:23 pm
Location - Oz

Post by moodleboy » Fri Feb 19, 2016 12:34 pm

Hi Burt,

I appreciate your feedback and advice.

Allow me to ask a different question: I understand that it is not advisable to edit orders (although I doubt that 100% of "real-life" business simply void an invoice and create a new one). However, why should the price change when it is edited? Everyone states, "you shouldn't edit an order," and they may or may not be right. However, the feature exists, and since it exists, it should work properly.

So, please, tell me why that it is normal behavior that when an order is edited, the prices of purchased items are not preserved?

Newbie

Posts

Joined
Sun Feb 03, 2013 4:01 am

Post by Burt65 » Fri Feb 19, 2016 10:27 pm

moodleboy wrote:Hi Burt,

I appreciate your feedback and advice.

Allow me to ask a different question: I understand that it is not advisable to edit orders (although I doubt that 100% of "real-life" business simply void an invoice and create a new one). However, why should the price change when it is edited? Everyone states, "you shouldn't edit an order," and they may or may not be right. However, the feature exists, and since it exists, it should work properly.

So, please, tell me why that it is normal behavior that when an order is edited, the prices of purchased items are not preserved?
Well if you did appreciate it, you would have understood.

Try this: go into a shop buy something then walk out of the shop, then return into the shop and tell them that you bought the wrong item, or the wrong number of items. Watch what they do! Unless, that is, you live in a place where people don't care about the legality of things....

Now that is not a different question, as Daniel did explained in GitHub that he only put the edit button there because it was asked to by some of the developers...Frankly I really don't care as it is a button that has no real need to be there in the first place. But you obviously need that button to work really badly, so why don't you fix it? It is Open source after all... And if you can't fix it, just pay someone to do it for you.

And just for the record, when you select to edit an order, it is not just the price that get screwed up. Your stock also is affected among other things...But I guess you haven't gone that far yet

On a different note OC 2.2.0.0 has reached Beta. :banana: Who knows, maybe the edit button will work then, or maybe it has been removed altogether... :laugh:

Over 95% of all computer problems can be traced back to the interface between the keyboard and the chair...


User avatar
Active Member

Posts

Joined
Mon Nov 18, 2013 3:23 pm
Location - Oz

Post by moodleboy » Sat Feb 20, 2016 12:12 am

Try this: go into a shop buy something then walk out of the shop, then return into the shop and tell them that you bought the wrong item, or the wrong number of items. Watch what they do! Unless, that is, you live in a place where people don't care about the legality of things....
I can tell you what I have not seen: I have never seen a store change the prices of items that were not affected by the return/change. The new receipt simply shows the items that were changed. I mean, where you live, if you purchased 10 items on sale and then returned one, they bill you for the difference in price for the other 9 items?
Your stock also is affected among other things...But I guess you haven't gone that far yet
I'm not sure I appreciate the condescending remark. Stock doesn't get affected. When the item is changed in the order, removed items are added back into stock and newly added items are deducted from the stock.
Frankly I really don't care as it is a button that has no real need to be there in the first place. But you obviously need that button to work really badly, so why don't you fix it? It is Open source after all... And if you can't fix it, just pay someone to do it for you.
Exactly. Which is what my 1st and 2nd posts were about. I never intended for this thread to turn into a philosophical discussion about the ethics of editing orders. However, all the replies to my questions steered it in that direction. So, for the benefit of those just reading the end of this thread, here are my original questions:
Currently, the edit order feature on the admin side uses the cart api. I need to be able to retrieve the order_id from the cart api so that I can retrieve the order date and subsequently find the special price, but I have no idea how to get it. I know that the product data is stored in $this->request->post['product'], but does anyone know how to get the order information?
and
The real solution is that when the items are loaded into the cart via the API, the system checks to see if it is an existing order and uses the date the order was created (oc_order.date_added) against then special_start and special_end dates instead of using NOW(). This is relatively easy, but I need to be able to access the order_id from the api and then I can make the necessary changes in catalog/product.php
Again, the changes are minor. I am just missing something in the flow of the code. I develop primarily in PHP and Java, however admin/view/template/order_form.tpl uses a JSON call to catalog/controller/api/cart.php to load the cart with the order. I am having some trouble nailing down where that takes place and how the order_id is actually passed. Once I do, I can grab the order_id, from which I can grab the date_added date, from which I can override the actual product price with the special price, if it applies.

So, I humbly ask anyone with a response to this purely technical question, please help. And anyone with moral/ethical/legal objections to editing orders in general, with all due respect, please refrain from comment in this thread. This is not the place for that discussion.

Thank you.

Newbie

Posts

Joined
Sun Feb 03, 2013 4:01 am

Post by Burt65 » Sat Feb 20, 2016 10:41 am

The new receipt simply shows the items that were changed.
Bingo!

So you are going from:
I appreciate your feedback and advice.
to
And anyone with moral/ethical/legal objections to editing orders in general, with all due respect, please refrain from comment in this thread
Hmmm... Ok.

Over 95% of all computer problems can be traced back to the interface between the keyboard and the chair...


User avatar
Active Member

Posts

Joined
Mon Nov 18, 2013 3:23 pm
Location - Oz

Post by moodleboy » Mon Feb 22, 2016 1:03 pm

Well, thank you Burt, for your lecture. I hope you accomplished your goal of feeling superior. I find it mildly humorous (sad, really) that in your entire pontification, you still managed to avoid answering one, very specific question: Why is it considered normal behavior for the price to change when you edit an order if the order is edited after the special expires?

For the rest of us who acknowledge that the ability to edit orders is necessary, and that the current system is slightly broken, I am attaching I am linking to an OCMOD to fix it.

Bascially I set a session variable in catalog/controller/api/order.php in the edit() function to hold the order_id. Since this function can only be called by the admin when editing an order, the session variable will only be set during a backend order edit.

Then, in system/library/cart.php, I wrapped the product_special_query in an if() statement that basically checks to see if the session variable is set. if it is, it graps the date_added date from the order and compares the special price to that instead of NOW(), thus preserving the special price of the order. I have to do some more testing to make sure it works will all the order totals as well, but so far it looks like it does.

Now, a couple of directions for anyone using this:
  • Please test thoroughly first on a test store and post back here if you have any issues. Even better, post any suggestions and/or fixes
  • For it to work, you first have to go into your store's settings, under options, and select "Yes" to "Respect Specials When Editing Order"
  • During the editing process, the prices will not show the specials price - I haven't gotten to this yet - however, this is normal
  • After you click "Save" on the last tab of the edit process ("Totals") the prices will update with the specials price if the order was placed during the time the special was valid
  • This works on version 2.1.0.1 and 2.1.0.2. I haven't tested it out on earlier versions.
If anyone finds this useful and/or has any suggestions, please let me know.

Unfortunately, this forum will not allow me to actually upload the file due to security, so you can grab it below:

https://drive.google.com/file/d/0B-eMK_ ... sp=sharing

Newbie

Posts

Joined
Sun Feb 03, 2013 4:01 am

Post by baltextra » Tue May 24, 2016 5:34 pm

Hi!!!

But there is also another bug "Respect outdated prices": respect old outdated prices if order is not changed. Standart (not special) price may change every day, for example oil prices, lol :) So you have to just freeze prices if the order-cart is not modified. For example, you want to edit First name and Address for a very-very old order.

When admin edits any order a new price shows up. It's wrong behaviour. Some shops change prices very often. For example, admin cannot just change the Last name or Adress without editing price.

Can you share what you did to fix this bug? Thanks.

Newbie

Posts

Joined
Tue May 24, 2016 5:30 pm

Post by hypemedia » Wed Nov 30, 2016 8:49 pm

Yes I am having the same problem, I need to edit an order after a promotion period so the products in the order have a discounted price, while right now the price of the product in the store is back to the initial amount. When editing the order all the product prices get replaced by the new ones. Also for countries that use multicurrencies the price changes everyday so the actual "normal " way opencart works makes the accounting impossible.

Is there anybody that has an vqmod that fixes this problem. I have one but is for 1.5.6 and now with the API from 2.0 is not working anymore and needs a complete re-write.

Active Member

Posts

Joined
Fri Aug 17, 2012 5:39 pm

Post by schiggi » Thu Jun 29, 2017 11:08 pm

Is there an updated version for OC 2.3?

Edit: Ok, tried it myself. :) - Apart of the path change for the cart lib, everything works.

New member

Posts

Joined
Tue May 13, 2014 4:23 am

Post by bruiseviolet » Wed May 08, 2019 8:15 am

Pretty ridiculous this isn't built in. We have customer service reps who manually enter in orders when customers call in and this is just a mess to have to find a workaround. It's sad some of those who responded earlier seem so narrow minded in their scope of how other businesses utilize OpenCart.

Newbie

Posts

Joined
Tue Feb 16, 2016 1:10 am
Who is online

Users browsing this forum: No registered users and 6 guests