If this is your first visit, check our documentation. To post, register or login.
Forums / Code Matters / Bug Reports / Product quantity with 0 as the last digit not being accepted

Product quantity with 0 as the last digit not being accepted

Started by vasilt on 5 Jun 2024, 10:40 AM · Views: 768

Results 1 to 6 of 6
5 Jun 2024, 10:40 AM
#1
vasilt avatar

vasilt

New Zenner

Join Date:
Jan 2006
Posts:
44
Plugin Contributions:
0

Product quantity with 0 as the last digit not being accepted

ZC 2.0
PHP 8.3
Has anyone tried to enter product quantity with 0 as the last digit, e.g. 10? I could not. The quantity field resets to the number without the last zeros, e.g. 10 goes to 1. Other quantities are fine. The old 1.5.8a version dos not have this issue.

5 Jun 2024, 11:40 AM
#2
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,760
Plugin Contributions:
56

Re: Product quantity with 0 as the last digit not being accepted

Can not reproduce.

I'm assuming this is product type 1 (the default type).

Please compare files in admin/includes/modules with a fresh download of Zen Cart 2.0.1, and ensure you don't have any php files in admin/includes/modules/product.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

5 Jun 2024, 12:20 PM
#3
vasilt avatar

vasilt

New Zenner

Join Date:
Jan 2006
Posts:
44
Plugin Contributions:
0

Re: Product quantity with 0 as the last digit not being accepted

Product type 1. All files in admin/includes/modules are identical to the originals. No *.php files in admin/includes/modules/product. I was able to enter values ending in 0 though after removing the preg_replace function on lines 1370 and 2395 in includes/classes/shopping_cart.php.
Line 1370:$new_qty = $data['qty']; and line 2395:```
return $check_qty;

The if statements on the lines check if precision is not 0 and if this is the case all zeros at the back are trimmed. But if the value entered is integer with zeros in the back, e.g. 180 without decimals and the precision is not zero then the number gets trimmed to 18.
5 Jun 2024, 1:14 PM
#4
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,760
Plugin Contributions:
56

Re: Product quantity with 0 as the last digit not being accepted

OK so you are using decimal quantities, correct? Your quantities have fractions?

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

5 Jun 2024, 1:28 PM
#5
vasilt avatar

vasilt

New Zenner

Join Date:
Jan 2006
Posts:
44
Plugin Contributions:
0

Re: Product quantity with 0 as the last digit not being accepted

Correct. QUANTITY_DECIMALS constant is set to 2. Not all products can have fractional quantities though.

5 Jun 2024, 1:32 PM
#6
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,760
Plugin Contributions:
56

Re: Product quantity with 0 as the last digit not being accepted

OK thank you. This is a bug, would you please create an issue here:

https://github.com/zencart/zencart/issues

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.