Post by HAO » Fri Apr 15, 2016 2:51 am

Original article:
liquidpele wrote:This is actually a pretty big problem - a busy site might have 3 people trying to buy the same thing at the same time! The answer is: Just have the database handle it for you.

Make the table you track the carts/stock with InnoDB instead of myISAM. Then track the cart/stock in that table and use table locks to verify things if you're verifying and then updating the table. The performance doesn't matter if the only thing using the locking table are people with carts because you're not going to have 200 people checking out and refreshing at the same time and having good concurrency is more important.
If I change the oc_cart table to MyISAM engine, This is the reason for the negative result of it?

If the result is negative because of this, that if I changed back to the original InnoDB is not able to solve it?

PS.I can be empty oc_cart the table, let it be recalculated?

MY OpenCart 2.1.0.2
Last edited by HAO on Sat May 07, 2016 11:25 pm, edited 2 times in total.

HAO
Active Member

Posts

Joined
Fri Jun 03, 2011 2:52 pm

Post by oc-extensions » Fri Apr 15, 2016 2:54 am

Hi,

In your store is allowed to buy out of stock products?
Check your settings in tab Options

Image | Extensions and Custom Development


User avatar
Active Member

Posts

Joined
Fri Jan 06, 2012 11:31 pm

Post by HAO » Sat Apr 16, 2016 3:13 am

I do not have open this option, But I is indeed the oc_cart table change to the MyISAM engine, This is the cause it?

I can clear the oc_cart table, Let it reproduces the data?

HAO
Active Member

Posts

Joined
Fri Jun 03, 2011 2:52 pm

Post by HAO » Mon Apr 25, 2016 1:36 pm

After that I will oc_cart table changed the InnoDB engine, The results will still be negative stock the problems.

How do I solve this problem? Continues like this for negative stock, I would really cause problems, please help me!

Can I through the clear oc_cart the table, To solve the problem of negative stock it?

HAO
Active Member

Posts

Joined
Fri Jun 03, 2011 2:52 pm

Post by HAO » Sat May 07, 2016 11:18 pm

After that I have to clear the table oc_cart, But still there will be a negative stockt he problem.

I have modified to InnoDB engine, Why would the same problem?

May I ask I in the end how to solve this problem?

Please help me!
1462627863032.jpg

1462627863032.jpg (129.74 KiB) Viewed 1423 times

PS.System/Setting - Stock Checkout: Allow customers to still checkout, I do not have this option turn on, Negative stock Is coming from?

HAO
Active Member

Posts

Joined
Fri Jun 03, 2011 2:52 pm

Post by straightlight » Sun May 08, 2016 8:44 am

Use the truncate table command for the oc_cart instead of clearing the table. This should reset the indexes from the database reading this table particularly. It looks like you have UTF-8 Unicode translation errors showing from your screenshot.

Also, can you indicate if you're using the database structure collation showing as: utf8_general_ci ?

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com Administrator / Quality Assurance Analyst / Programmer


Legendary Member

Posts

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

Post by HAO » Sun May 08, 2016 7:08 pm

2016-05-08_190209.png

2016-05-08_190209.png (4.96 KiB) Viewed 1403 times

My table has maintained database structure collation showing as: utf8_general_ci

My Quantity of products are set to 30, I do not know why will become negative, This continues there will be real legal issues.

Why is this?

HAO
Active Member

Posts

Joined
Fri Jun 03, 2011 2:52 pm

Post by straightlight » Tue May 10, 2016 10:24 pm

If people are currently ordering on your store and you notice negative values from the product quantity, a quick option would be to go to your: catalog/model/checkout/order.php file.

Then, find:

Code: Select all

$this->db->query("UPDATE " . DB_PREFIX . "product SET quantity = (quantity - " . (int)$order_product['quantity'] . ")
add above:

Code: Select all

if ((int)$order_product['quantity'] <= 0) {
    $order_product['quantity'] = 0;
}
In admin/model/catalog/product.php file,

find:

Code: Select all

public function addProduct($data) {
add below:

Code: Select all

if ((int)$data['quantity'] <= 0) {
    $data['quantity'] = 0;
}
Then, find:

Code: Select all

public function editProduct($product_id, $data) {
add below:

Code: Select all

if ((int)$data['quantity'] <= 0) {
    $data['quantity'] = 0;
}
This should resolved the problem.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com Administrator / Quality Assurance Analyst / Programmer


Legendary Member

Posts

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

Post by HAO » Fri Jul 22, 2016 1:59 pm

Thank you for your reply!

I reply to you in the moment, I have modified the code, But the same problem still occurs.

This time problem occurred the product, It belongs to a limited product, The same product three options, Each option has two Quantity.

Exceed the number of checkout problems did not expect to actually appear, How do I solve this problem it?

I really do not want such a problem because the burden of liability, Because this issue is illegal in Taiwan.

The problem is that I do not stock, I can not sell it?

Really I hope that authorities were able to solve this problem, Please help! :'(

HAO
Active Member

Posts

Joined
Fri Jun 03, 2011 2:52 pm

Post by straightlight » Fri Jul 22, 2016 7:19 pm

HAO wrote:Thank you for your reply!

I reply to you in the moment, I have modified the code, But the same problem still occurs.

This time problem occurred the product, It belongs to a limited product, The same product three options, Each option has two Quantity.

Exceed the number of checkout problems did not expect to actually appear, How do I solve this problem it?

I really do not want such a problem because the burden of liability, Because this issue is illegal in Taiwan.

The problem is that I do not stock, I can not sell it?

Really I hope that authorities were able to solve this problem, Please help! :'(
Which OC version are you using?

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com Administrator / Quality Assurance Analyst / Programmer


Legendary Member

Posts

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

Post by HAO » Fri Jul 22, 2016 8:24 pm

OpenCart 2.1.0.2

HAO
Active Member

Posts

Joined
Fri Jun 03, 2011 2:52 pm

Post by straightlight » Fri Jul 22, 2016 8:42 pm

HAO wrote:OpenCart 2.1.0.2
This time problem occurred the product, It belongs to a limited product,
When indicating: 'belongs to a limited product', is it related to a specific extension installed?

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com Administrator / Quality Assurance Analyst / Programmer


Legendary Member

Posts

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

Post by HAO » Fri Jul 22, 2016 9:01 pm

Because we are accustomed to the same products, different specifications are used to value the Quantity of options as the Quantity of products.

So after we found a problem, we want to try to buy the relevant extensions to solve this problem, but it seems to be invalid.

Option Combination Stock Management

Extensions settings, it is too complicated for us to give up.

Quantity based on options quantity

For those non-selling products seem to be useful, But those limited quantity of products, because it is limited also find many people at the same time added to the shopping cart, I think it would not follow that about?

Because the total quantity of only 6, there are more than 20 orders for records, This is incredible.

Definitely a problem in the framework program, Repeat submit the form actually has the case, Really dangerous.

Please help to solve! :'(

HAO
Active Member

Posts

Joined
Fri Jun 03, 2011 2:52 pm

Post by straightlight » Fri Jul 22, 2016 10:30 pm

HAO wrote:Because we are accustomed to the same products, different specifications are used to value the Quantity of options as the Quantity of products.

So after we found a problem, we want to try to buy the relevant extensions to solve this problem, but it seems to be invalid.

Option Combination Stock Management

Extensions settings, it is too complicated for us to give up.

Quantity based on options quantity

For those non-selling products seem to be useful, But those limited quantity of products, because it is limited also find many people at the same time added to the shopping cart, I think it would not follow that about?

Because the total quantity of only 6, there are more than 20 orders for records, This is incredible.

Definitely a problem in the framework program, Repeat submit the form actually has the case, Really dangerous.

Please help to solve! :'(
Based on the above, you seem to be using two different extensions which I would rather suggest to contact each developers to assist you with these issues.

However, as for this analogy:
Repeat submit the form actually has the case, Really dangerous.
Could you reproduce the facts that repeated submission would actually be the case of resulting negative stock values without extensions installed if the problem is definitely related to the framework program?

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com Administrator / Quality Assurance Analyst / Programmer


Legendary Member

Posts

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

Post by HAO » Sat Jul 23, 2016 3:33 am

I just want to say, The same problem occurs more than one person I have, Many people have encountered.

I am currently in accordance with what you said, I installed my first extension removed, I will observe a period of time to see.

But I also want to be able to from the official quantity of options, calculated as the quantity of products in stock for standard.

Because in the past recall OpenCart 1.5 are no such problems, we are also able to calculate the quantity of stock and options.

HAO
Active Member

Posts

Joined
Fri Jun 03, 2011 2:52 pm
Who is online

Users browsing this forum: No registered users and 28 guests