Post by schiggi » Fri Aug 05, 2016 1:57 am

Hi there,

I need a bit Support in understand the order statuses. I set the standard statuses for Processing and Completed ("Processing" and "Completed").

Now, I understand, once a checkout is done, the status is set to "Processing", which subtracts the stock and applies any coupons etc. - When I set the status to complete, then download products can be downloaded. For physical products it doesn't have any implications.

Now, I do have many statuses in between (shipped, packing, packed, waiting for payment, checking for product etc.) - As far as I understand in the code, any status other than the processing and complete status will restock the products, i.e. cancel the order and make the product (quantities) available for sale. That is obviously not, what I want.

Do I have to check all statuses, which belong to my order fulfillment process in the settings tab to prevent OC from restocking the products?

Another question is, how OC handles returns. If a return arrives in the system, how does OC connects it to the orders and the products in terms of restocking and sales reports?

Thanks,
schiggi

New member

Posts

Joined
Tue May 13, 2014 4:23 am

Post by straightlight » Fri Aug 05, 2016 3:05 am

Do I have to check all statuses, which belong to my order fulfillment process in the settings tab to prevent OC from restocking the products?
Not only under the admin settings but also under the payment modules to where the payment transactions are activated for your customers during checkout.
Another question is, how OC handles returns. If a return arrives in the system, how does OC connects it to the orders and the products in terms of restocking and sales reports?
This feature might exist as an extension. If there are no extension that can be relatively found, this idea can always be posted under the feature requests section of the forum. :)

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by schiggi » Fri Aug 05, 2016 4:00 am

Thank you for the very quick reply. That makes the whole process a bit clearer.

One thing, that bugs me or I don't understand the behaviour, is the order edit. Atm, after every edit of the order (correcting wrong customer data like name or address), the admins and the customer gets a new confirmation email. Since I can edit an order up to 10x times, the customer and me are getting 10 emails, which is obviously annoying.

How to change the behaviour? Is that intended or a bug/misusage from my side?

New member

Posts

Joined
Tue May 13, 2014 4:23 am

Post by straightlight » Fri Aug 05, 2016 4:15 am

schiggi wrote:Thank you for the very quick reply. That makes the whole process a bit clearer.

One thing, that bugs me or I don't understand the behaviour, is the order edit. Atm, after every edit of the order (correcting wrong customer data like name or address), the admins and the customer gets a new confirmation email. Since I can edit an order up to 10x times, the customer and me are getting 10 emails, which is obviously annoying.

How to change the behaviour? Is that intended or a bug/misusage from my side?
This seems to be a persistent bug which was also not fixed into the latest version of Opencart either. Thanks for tracking this.

In order to resolved this issue, in your catalog/model/checkout/order.php file,

find:

Code: Select all

$mail->send();
	
				// Admin Alert Mail
replace with:

Code: Select all

if ((!empty($this->session->data['order_id'])) || (empty($this->session->data['order_id']) && $notify)) {
    $mail->send();
}
	
				// Admin Alert Mail
Optional step to avoid receiving an email to yourself and to other administration members of your store;

find:

Code: Select all

$mail->send();
	
					// Send to additional alert emails
					$emails = explode(',', $this->config->get('config_alert_email'));
	
					foreach ($emails as $email) {
						if ($email && filter_var($email, FILTER_VALIDATE_EMAIL)) {
							$mail->setTo($email);
							$mail->send();
						}
					}
replace with:

Code: Select all

if ((!empty($this->session->data['order_id'])) || (empty($this->session->data['order_id']) && $notify)) {
    $mail->send();
}

// Send to additional alert emails
					$emails = explode(',', $this->config->get('config_alert_email'));
	
					foreach ($emails as $email) {
						if ($email && filter_var($email, FILTER_VALIDATE_EMAIL)) {
							$mail->setTo($email);
                                                        if ((!empty($this->session->data['order_id'])) || (empty($this->session->data['order_id']) && $notify)) {
							$mail->send();
                                                        }
						}
					}
This should entirely rectify the problem. By sending an edit order status, if you do not click the notify customer checkmark, the email should not be sent to the customer automatically.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by schiggi » Fri Aug 05, 2016 4:56 am

Thanks, that indeed is a another problem. Thanks for the fix. Will implement that as an ocmod.

What I actually meant with my previous post was the real order edit. So not order status edit, but order edit.

From the function edit_order in catalog/model/checkout/order.php, I can see, that the order is voided first and the order status set to 0:

Code: Select all

// Void the order first
$this->addOrderHistory($order_id, 0);
I am not sure, why that has to be done. Could you explain me, why we need to void it first in order to edit it?

As the order_status_id is set to 0, later through the API (catalog/controller/api/order.php) the order_status is set to the status defined during the order edit form in the backend admin:

Code: Select all

//Line 676
$this->model_checkout_order->addOrderHistory($order_id, $order_status_id);
As the order_status has been set to 0 in the previous order_edit function, the following lines are triggered in addOrderHistory (Line 383)

Code: Select all

// If order status is 0 then becomes greater than 0 send main html email
if (!$order_info['order_status_id'] && $order_status_id) {...}
...and the customer/admin gets the order confirmation.

That might make sense, if the ordered products have been changed or anything regarding the total sum. But for simple editing of spelling mistakes or assigning customers to customer groups or anything, then it would be great to have the choice, if to send a confirmation email or not.

Through an event, I could add back the original order status in order_edit, but I am not sure, why voiding of order has been added in the first place. Can you please explain that to me?

EDIT: Through your modifications, obviously the same result would be achieved as order edits don't have a $notify var as far as I can see. Still curious about the voiding of order.
Last edited by schiggi on Fri Aug 05, 2016 4:58 am, edited 1 time in total.

New member

Posts

Joined
Tue May 13, 2014 4:23 am

Post by straightlight » Fri Aug 05, 2016 4:58 am

schiggi wrote:Thanks, that indeed is a another problem. Thanks for the fix. Will implement that as an ocmod.

What I actually meant with my previous post was the real order edit. So not order status edit, but order edit.

From the function edit_order in catalog/model/checkout/order.php, I can see, that the order is voided first and the order status set to 0:

Code: Select all

// Void the order first
$this->addOrderHistory($order_id, 0);
I am not sure, why that has to be done. Could you explain me, why we need to void it first in order to edit it?

As the order_status_id is set to 0, later through the API (catalog/controller/api/order.php) the order_status is set to the status defined during the order edit form in the backend admin:

Code: Select all

//Line 676
$this->model_checkout_order->addOrderHistory($order_id, $order_status_id);
As the order_status has been set to 0 in the previous order_edit function, the following lines are triggered in addOrderHistory (Line 383)

Code: Select all

// If order status is 0 then becomes greater than 0 send main html email
if (!$order_info['order_status_id'] && $order_status_id) {...}
...and the customer/admin gets the order confirmation.

That might make sense, if the ordered products have been changed or anything regarding the total sum. But for simple editing of spelling mistakes or assigning customers to customer groups or anything, then it would be great to have the choice, if to send a confirmation email or not.

Through an event, I could add back the original order status in order_edit, but I am not sure, why voiding of order has been added in the first place. Can you please explain that to me?
Either you decide to edit the order status of the main order or the order statuses related to the order will still be heading to the addOrderHistory method from the mentioned path and file above. Implementing the fix above will definitely fix the issue which was already addressed before for prior versions of Opencart.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by schiggi » Fri Aug 05, 2016 4:59 am

Got it, thanks!

New member

Posts

Joined
Tue May 13, 2014 4:23 am

Post by Faalsa » Sun Jun 25, 2017 3:39 pm

Hi,
Di i have to fix these codes even if i am using opencart v2.3.0.2

Newbie

Posts

Joined
Wed May 20, 2015 12:10 am
Who is online

Users browsing this forum: No registered users and 144 guests