Post by tomeda » Wed Jan 29, 2020 4:03 am

straightlight wrote:
Wed Jan 29, 2020 3:28 am
rhorne wrote:
Tue Jan 28, 2020 10:25 pm
That's strange, I get no such errors or warnings. What about the following:

https://snipboard.io/huejHm.jpg
Yes, this one works better. I would, then, suggest to remove the previous link you posted above for security purposes.

As for the out of stock, the thing is that the products are being pulled from the same location whether it's from the API in the admin sales orders or from the catalog product page in order to maintain the stock levels and the service levels between store owners and the customers. If you're looking for a push order strategy based on a stock level that cannot be guaranteed to the customer, then you'd be affecting the utility of the product value when using the API orders as compared to the catalog product page.

In order to rectify that issue, since each stores also have their own settings defined from the admin systems settings, the stock levels would need to be overwritten individually on the stock levels whenever the API is used but, even there, manufacturers and products being copied categorically could also exclude those remarks as well as store owners feeding their products with their stocks via a service provider where this method can also become quite complex.

Therefore, by creating a product group page (which I believe one or multiple extensions on the Marketplace already exists for this) could create part of the solution where the stock levels could be re-balanced since product groups could also involved using the APIs as an additional group. This way, the product page and the checkout process from the catalog-end side won't be interfered with any customers whether it's for guests or registered customers and affiliates.
I really don't have a clue what are you talking about?!

The issue is simple. Admin user is editing existing order, why is OC pulling stock for an existing order twice? If admin increases quantity for that order OK, but when the actual change is not on quantity it's regarding address, name or something else beside quantity, I don't see any meaningful explanation why OC should reduce the stock of that products in the existing order again?!

OpenCart SEO Services
http://tomeda.bg


User avatar
New member

Posts

Joined
Thu Mar 19, 2015 4:48 am


Post by straightlight » Wed Jan 29, 2020 4:31 am

I don't see any meaningful explanation why OC should reduce the stock of that products in the existing order again?!
That was already explained above. It's because the API calls the same method on the catalog-end to calculate the stock.

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 mupcku » Tue Jul 21, 2020 8:43 pm

straightlight wrote:
Wed Jan 29, 2020 4:31 am
That was already explained above. It's because the API calls the same method on the catalog-end to calculate the stock.
BUT we are searching for a solution, not for an explaination.

https://wedeom.bg
Image


Active Member

Posts

Joined
Tue Jan 24, 2017 8:12 pm

Post by francesco.bragagna » Sun Oct 04, 2020 10:26 pm

Hi,

not sure I can help, I'm using 2.0.2.0
Note: I'm a developer, but I'm not using in general php, so sometimes I have difficulties in understanding when a controlled is used from one or more page, or if a template is used in only one context or more than one.

I know that there is a way to configure when the items are subtracted from stock. In my installation, I decided to subtract them as soon the order is sent by the customer. In this way my online shop shows the item really present, considering the items containend in the order received as sold (also if not payed yet).

The problem editing the orders is that: when an ADMINISTRATOR edit an order, the page using order api prepare a cart with all the item in the order.
But, the item in that order can be not more available of course, beause sold exactly in that order.
Let's me say and example: a customer make order #1200 with only one item in it, a jurassic park t-shirt. My stock has only one of this shirt, so when the order is received the stock it's updated and the shirt it not more available. Than I need to edit order #1200 (to change address, to change payment method, to add items ... not important what), but editing it the shirt it's out of stock and marked ***, beacuse it was the last one.

One solution is manage the answer on client side: when it's called api to load the cart with items in the order, checking the response I consider really out of stock only when the item present in the page are more than originally ordered. That's need a development on javascript of order_form.tpl (it's used only by administrator?)

The problem becomes more complicated when (for example) I have 3 instance of one item. The original order order two of them. Editing the order I want to increase the quantity of that product, but the page must shown an error if I choose 4 or more, and not if I set 3.

Note: I dont' know if the problem is mitigated or solved in newest version of opencart (e.g. 3.x or 2.1.x because I use an old one) but I can't change deployed version in my installation, and I prefere to solve the issue with custom code (if I can). I very surprised that this issue is still unsolved anyway, editing an order should be something that everyone using oc in production make daily.


Posts

Joined
Sat May 05, 2018 7:10 am

Post by ad-min » Thu Oct 14, 2021 4:28 am

straightlight wrote:
Wed Jan 29, 2020 4:31 am
That was already explained above. It's because the API calls the same method on the catalog-end to calculate the stock.
Then as a workaround how about switching off the stock errors for Admin users?
We could easy modify system/library/cart/cart.php at line 213

Code: Select all

// Stock
if (!$product_query->row['quantity'] || ($product_query->row['quantity'] < $cart['quantity'])) {
	$stock = false;
}
to

Code: Select all

// Stock
if (!$product_query->row['quantity'] || ($product_query->row['quantity'] < $cart['quantity'])) {
	if (isset($this->session->data['api_id'])) {
		//Now as ADMIN you may edit order even with zero stock
	}else{
		$stock = false;
	}
}
Hope that helps to all those who need to edit order details like addresses, prices, coupons and so one.
Please keep in mind, that after changing the above code for Admin Order Edit no more stock errors will be thrown, even if stock would become negative.

Ad-min

New member

Posts

Joined
Tue Aug 18, 2020 10:31 pm
Location - Germany

Post by straightlight » Thu Oct 14, 2021 5:30 am

ad-min wrote:
Thu Oct 14, 2021 4:28 am
straightlight wrote:
Wed Jan 29, 2020 4:31 am
That was already explained above. It's because the API calls the same method on the catalog-end to calculate the stock.
Then as a workaround how about switching off the stock errors for Admin users?
We could easy modify system/library/cart/cart.php at line 213

Code: Select all

// Stock
if (!$product_query->row['quantity'] || ($product_query->row['quantity'] < $cart['quantity'])) {
	$stock = false;
}
to

Code: Select all

// Stock
if (!$product_query->row['quantity'] || ($product_query->row['quantity'] < $cart['quantity'])) {
	if (isset($this->session->data['api_id'])) {
		//Now as ADMIN you may edit order even with zero stock
	}else{
		$stock = false;
	}
}
Hope that helps to all those who need to edit order details like addresses, prices, coupons and so one.
Please keep in mind, that after changing the above code for Admin Order Edit no more stock errors will be thrown, even if stock would become negative.

Ad-min
That won't really solve the issue since when the API ID would not be used, in this scenario, the stock would then be set to false during checkout.

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 ad-min » Tue Oct 26, 2021 5:00 pm

It works for me anyway.
When I am logged in as Administrator in backend, then I can edit orders even if stock of one of the items is 0.
And customers can't place orders with items, which are out of stock.
Also tested in a fresh 3.0.3.2 installation.

Did anybody already try it?

Ad-min

New member

Posts

Joined
Tue Aug 18, 2020 10:31 pm
Location - Germany

Post by ad-min » Thu Oct 28, 2021 7:22 pm

A better solution would be as follows:

in admin/controller/sale/order.php before line 708

Code: Select all

$this->response->setOutput($this->load->view('sale/order_form', $data));
add this line

Code: Select all

$session->data['no_stock'] = 1;
and in system/library/cart/cart.php find line 215

Code: Select all

$stock = false;
and replace it with

Code: Select all

if (isset($this->session->data['no_stock'])) {
         // no stock error will be returned, 
         // when the session was created from backend's SALE=>ORDER=>EDIT         
}else{
	$stock = false;
}
Now Edit order is possible if product is out of stock :)

ad-min

New member

Posts

Joined
Tue Aug 18, 2020 10:31 pm
Location - Germany

Post by straightlight » Thu Oct 28, 2021 7:42 pm

ad-min wrote:
Thu Oct 28, 2021 7:22 pm
A better solution would be as follows:

in admin/controller/sale/order.php before line 708

Code: Select all

$this->response->setOutput($this->load->view('sale/order_form', $data));
add this line

Code: Select all

$session->data['no_stock'] = 1;
and in system/library/cart/cart.php find line 215

Code: Select all

$stock = false;
and replace it with

Code: Select all

if (isset($this->session->data['no_stock'])) {
         // no stock error will be returned, 
         // when the session was created from backend's SALE=>ORDER=>EDIT         
}else{
	$stock = false;
}
Now Edit order is possible if product is out of stock :)

ad-min
That is correct. That is only useful for the admins. During the header, cart and checkout, these lookups will still be forced to false regardless if the order has been edited or not but only once the products will be added to the cart.

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
Who is online

Users browsing this forum: No registered users and 161 guests