If this is your first visit, check our documentation. To post, register or login.
Forums / Code Matters / Bug Reports / Unable to checkout with coupons discount enable

Unable to checkout with coupons discount enable

Started by nicksab on 12 Aug 2024, 11:38 PM · Views: 2,343

Results 1 to 12 of 12
12 Aug 2024, 11:38 PM
#1
nicksab avatar

nicksab

Totally Zenned

Join Date:
Apr 2011
Posts:
592
Plugin Contributions:
0

Unable to checkout with coupons discount enable

ZC 2.0.1
Php 8.3
Bootstrap template
OPC. 2.5.3

I am getting the following error while trying to checkout:

[12-Aug-2024 00:54:08 UTC] PHP Fatal error: Uncaught TypeError: CouponValidation::is_product_valid(): Argument #1 ($product_id) must be of type int, string given, called in /includes/functions/functions_gvcoupons.php on line 90 and defined in /includes/classes/CouponValidation.php:14
Stack trace:
#0 /includes/functions/functions_gvcoupons.php(90): CouponValidation::is_product_valid()
#1 /includes/modules/order_total/ot_coupon.php(635): is_product_valid()
#2 /includes/modules/order_total/ot_coupon.php(138): ot_coupon->get_order_total()
#3 /includes/classes/order_total.php(72): ot_coupon->process()
#4 /includes/modules/pages/checkout_one/header_php.php(347): order_total->process()
#5 /index.php(35): require('/home/zch1akhw6...')
#6 {main}
thrown in /includes/classes/CouponValidation.php on line 14

Any help please

Thank you in advance

13 Aug 2024, 2:07 AM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Re: Unable to checkout with coupons discount enable

This should bandage it until non-core code is updated to pass only integers:

CouponValidation.php, line 14: add |string like this:


public static function is_product_valid(int|string $product_id, int $coupon_id): bool

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

13 Aug 2024, 11:41 AM
#3
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,142
Plugin Contributions:
56

Re: Unable to checkout with coupons discount enable

DrByte:

This should bandage it until non-core code is updated to pass only integers:

CouponValidation.php, line 14: add |string like this:


public static function is_product_valid(int
|string $product_id, int $coupon_id): bool

What non-core code would that be?  I'll note that it's ot_coupon that appears to be the culprit.
14 Aug 2024, 2:18 AM
#4
nicksab avatar

nicksab

Totally Zenned

Join Date:
Apr 2011
Posts:
592
Plugin Contributions:
0

Re: Unable to checkout with coupons discount enable

Thanks DrByte,

I will give it a try and report back.

I rarely use coupons but I do want it working if it becomes needed

14 Aug 2024, 2:25 AM
#5
nicksab avatar

nicksab

Totally Zenned

Join Date:
Apr 2011
Posts:
592
Plugin Contributions:
0

Re: Unable to checkout with coupons discount enable

No expert at all here but I agree that's it ot_coupon related.

In my case, I tried:

bootstrap or responsive template.
OPC on or off

The coupon issue remains in all scenario

20 Aug 2024, 4:21 PM
#6
gothstone avatar

gothstone

Zen Follower

Join Date:
Jun 2005
Posts:
330
Plugin Contributions:
0

Re: Unable to checkout with coupons discount enable

Bumping this to make sure it's not forgotten. I don't see an issue or PR for this on github, but don't understand it well enough to create one.

2 + 2 = 5 for extremely large values of 2

Pez Collectors Store •••••••• My Plugins List

21 Aug 2024, 1:43 AM
#7
nicksab avatar

nicksab

Totally Zenned

Join Date:
Apr 2011
Posts:
592
Plugin Contributions:
0

Re: Unable to checkout with coupons discount enable

Thanks . I haven't find any permanent fix for it yet. DrByte suggestions seems to work but to early to tell. The updated site is not fully live yet

21 Aug 2024, 2:18 AM
#8
nicksab avatar

nicksab

Totally Zenned

Join Date:
Apr 2011
Posts:
592
Plugin Contributions:
0

Re: Unable to checkout with coupons discount enable

DrByte:

This should bandage it until non-core code is updated to pass only integers:

CouponValidation.php, line 14: add |string like this:


public static function is_product_valid(int
|string $product_id, int $coupon_id): bool


Made the changes but getting the error as follow:

> [21-Aug-2024 02:16:03 UTC] Request URI: /upgrade/index.php?main_page=checkout_one, IP address: 24.4.88.128
> --> PHP Fatal error: Uncaught TypeError: CouponValidation::is_product_valid(): Argument #2 ($coupon_id) must be of type int, string given, called in /includes/functions/functions_gvcoupons.php on line 90 and defined in /includes/classes/CouponValidation.php:14
> Stack trace:
> #0 /includes/functions/functions_gvcoupons.php(90): CouponValidation::is_product_valid()
> #1 /includes/modules/order_total/ot_coupon.php(635): is_product_valid()
> #2 /includes/modules/order_total/ot_coupon.php(138): ot_coupon->get_order_total()
> #3 /includes/classes/order_total.php(72): ot_coupon->process()
> #4 /includes/modules/pages/checkout_one/header_php.php(347): order_total->process()
> #5 /index.php(35): require('/home/zch1akhw6...')
> #6 {main}
> thrown in /includes/classes/CouponValidation.php on line 14.
21 Aug 2024, 1:02 PM
#9
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,142
Plugin Contributions:
56

Re: Unable to checkout with coupons discount enable

The error being logged, specifically

PHP Fatal error: Uncaught TypeError: CouponValidation::is_product_valid(): Argument #2 ($coupon_id) must be of type int, string given

belies your statement that you made the requested changes.

24 Aug 2024, 11:53 PM
#10
nicksab avatar

nicksab

Totally Zenned

Join Date:
Apr 2011
Posts:
592
Plugin Contributions:
0

Re: Unable to checkout with coupons discount enable

I just double checked my CouponValidation.php to make sure the edit was there.

I thought it fixed it at first but my discount coupon were still off. Once i turned it back on, error was logged and unable to checkout ( with or without the edit)

With the "edit" , i can't even make it to the login page.

25 Aug 2024, 12:56 AM
#11
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,974
Plugin Contributions:
8

Re: Unable to checkout with coupons discount enable

lat9:

The error being logged, specifically

PHP Fatal error: Uncaught TypeError: CouponValidation::is_product_valid(): Argument #2 ($coupon_id) must be of type int, string given

belies your statement that you made the requested changes.

the requested change dealt with argument #1.

this new error is complaining about argument #2.

author of square Webpay, now with Apple Pay and Google Pay.
mXworks
donations: venmo or paypal accepted.
premium consistent excellent support. available for hire.

25 Aug 2024, 8:05 PM
#12
nicksab avatar

nicksab

Totally Zenned

Join Date:
Apr 2011
Posts:
592
Plugin Contributions:
0

Re: Unable to checkout with coupons discount enable

carlwhat:

the requested change dealt with argument #1.

this new error is complaining about argument #2.

Oh wow. I literally missed that. Thank you once again Carl

Should i try something like:

public static function is_product_valid(int|string $product_id, int|string $coupon_id): bool