Forums / PayPal Express Checkout support / Paypal Express SQl Error on Checkout

Paypal Express SQl Error on Checkout

Locked

Started by rasyr on 25 Mar 2009, 2:59 PM · Views: 1,796

Results 1 to 6 of 6
This thread is locked. New replies are disabled.
25 Mar 2009, 2:59 PM
#1
rasyr avatar

rasyr

Zen Follower

Join Date:
Aug 2006
Posts:
233
Plugin Contributions:
0

Paypal Express SQl Error on Checkout

I am using Zen Cart 1.3.8a
I have a couple of modules installed, (i.e. EZ Populate, Reward Points, some custom sideboxes, etc.)

I got a report this morning from a Customer. he tried to purchase an item using the Paypal Express, it gave him a sql error

I discovered that it is giving this error whenever the customer is not logged in and they try to use the Paypal Express button

You can easily reproduce this by going to http://shop.ironcrown.com and putting any item in a shopping cart and hitting the paypal express button on the shopping cart page

My settings for Paypal Express are as follows:

Enable this Payment Module
True

Sort order of display.
2

Payment Zone
--none--

Set Order Status
Paid [2]

Set Unpaid Order Status
Pending [1]

Set Refund Order Status
Canceled [6]

Express Checkout: Require Confirmed Address
No

Express Checkout: Select Cheapest Shipping Automatically
No

Express Checkout: Skip Payment Page
No

Express Checkout: Automatic Account Creation
Yes

Payment Action
Final Sale

Transaction Currency
Only USD

PayPal Page Style
Primary

API Signature -- Username
--removed--

API Signature -- Password


API Signature -- Signature Code
--removed--

PayPal Mode
PayPal

Live or Sandbox
live

Debug Mode
Off

Can somebody please tell me how to fix this so that I don't get these sql errors anymore.

25 Mar 2009, 3:12 PM
#2
pierre avatar

pierre

New Zenner

Join Date:
Oct 2006
Posts:
84
Plugin Contributions:
0

Re: Paypal Express SQl Error on Checkout

It looks like the error is caused by your reward points module.

The problem with the sql is the bit that says

WHERE c.customers_id=

the value for c.customers_id cannot be emtpty. You will need to go find the place where the sql executes (if you have dreamweaver you can easily do a search in the folders) and just wrap single quotes around the customers id variable.

So then the query would look like:

 WHERE c.customers_id=''

when the user is not logged in, and that shouldn't give any errors.

http://www.customscripts.co.za - Custom development for open-source applications

http://www.pcservice.co.za - Website Development, Domain Registration, Hosting

25 Mar 2009, 3:19 PM
#3
pierre avatar

pierre

New Zenner

Join Date:
Oct 2006
Posts:
84
Plugin Contributions:
0

Re: Paypal Express SQl Error on Checkout

Maybe if you can tell me what rewards module you are using and where to get it, I can tell you the exact place where to edit the code and what needs to be changed.

http://www.customscripts.co.za - Custom development for open-source applications

http://www.pcservice.co.za - Website Development, Domain Registration, Hosting

25 Mar 2009, 3:56 PM
#4
rasyr avatar

rasyr

Zen Follower

Join Date:
Aug 2006
Posts:
233
Plugin Contributions:
0

Re: Paypal Express SQl Error on Checkout

The Rewards Point module is the one made by hem -- not sure of exact link to find it off-hand.

26 Mar 2009, 10:48 AM
#5
pierre avatar

pierre

New Zenner

Join Date:
Oct 2006
Posts:
84
Plugin Contributions:
0

Re: Paypal Express SQl Error on Checkout

Open the file includes/function/extra_functions/reward_points_functions.php

Look for the code (around line 141):

function GetRedeemRatio($customers_id)
{
	global $db;
	
	$sql = "SELECT redeem_ratio 
	        FROM ".TABLE_REWARD_MASTER." prp, ".TABLE_CUSTOMERS." as c
			LEFT JOIN(".TABLE_GROUP_PRICING." as gp) ON (gp.group_id=c.customers_group_pricing)
			WHERE c.customers_id=".(int)$customers_id."
			AND ((prp.scope_id=".$customers_id." AND prp.scope=".SCOPE_CUSTOMER.")
			OR (gp.group_id=c.customers_group_pricing AND prp.scope_id=gp.group_id AND scope=".SCOPE_GROUP.")
			OR (prp.scope=".SCOPE_GLOBAL."))
			ORDER BY prp.scope DESC LIMIT 1;"; 

	$result=$db->Execute($sql);

    if($result)
	 return $result->fields['redeem_ratio'];
	else
	 return 0;
}

and replace it with:

function GetRedeemRatio($customers_id)
{
	global $db;
	
	$sql = "SELECT redeem_ratio 
	        FROM ".TABLE_REWARD_MASTER." prp, ".TABLE_CUSTOMERS." as c
			LEFT JOIN(".TABLE_GROUP_PRICING." as gp) ON (gp.group_id=c.customers_group_pricing)
			WHERE c.customers_id='".(int)$customers_id."'
			AND ((prp.scope_id='".$customers_id."' AND prp.scope='".SCOPE_CUSTOMER."')
			OR (gp.group_id=c.customers_group_pricing AND prp.scope_id=gp.group_id AND scope='".SCOPE_GROUP."')
			OR (prp.scope='".SCOPE_GLOBAL."'))
			ORDER BY prp.scope DESC LIMIT 1;"; 

	$result=$db->Execute($sql);

    if($result)
	 return $result->fields['redeem_ratio'];
	else
	 return 0;
}

http://www.customscripts.co.za - Custom development for open-source applications

http://www.pcservice.co.za - Website Development, Domain Registration, Hosting

26 Mar 2009, 11:41 AM
#6
rasyr avatar

rasyr

Zen Follower

Join Date:
Aug 2006
Posts:
233
Plugin Contributions:
0

Re: Paypal Express SQl Error on Checkout

thanks! That seems to have fixed it...