Hello all,
While enabling gift certificates today I ran into a strange issue while trying to pay for them with PayPal Website Payments Pro. For orders with a pure virtual cart (only gift certificates in my case -- we sell physical products) I was redirected back to checkout_payment after clicking "confirm order" on step 3.
Steps to reproduce:
- Start with a fresh session. Add a gift certificate (any amount) to your order.
- Proceed to checkout (log in, etc). checkout_shipping should be skipped for this cart as it contains no physical products.
- Select PayPal on checkout_payment.
- Click "confirm order" on checkout_confirmation.
- Log into PayPal. Verify the amount and click "continue."
At this point you will be redirected to checkout_shipping. Zen Cart will then realize you have a virtual cart and redirect you to checkout_payment. - At this point you are in a "special payment" so you can only enter comments, etc., not re-select your payment type. Proceed to checkout_confirmation.
- Click "confirm order."
- Run through the PayPal screens and your transaction will be successful.
This looks to be an issue with Zen's handling of virtual carts. In paypalwpp.php line 1660 Zen checks for a virtual cart skips calling the paypalwpp->getOverrideAddress() function. Unfortunately, getOverrideAddress() is where the "markflow" GET variable is committed to a session variable. So, when we get to line 1732, $reviewOrder is left true and PayPal is told to display a "continue" button, rather than "confirm."
I added the following fix to my paypalwpp.php file starting at line 1659. I added the one line above "} else {":
Code:
if ($_SESSION['cart']->get_content_type() == 'virtual' && isset($_SESSION['customer_id']) && $_SESSION['customer_id'] > 0) {
$this->zcLog('ec-step1-addr_check', "cart contents is virtual and customer is logged in ... therefore options['NOSHIPPING']=1");
$options['NOSHIPPING'] = 1;
$_SESSION['paypal_ec_markflow']=(int)$_GET['markflow'];
} else {
For obvious reasons, I'm hesitant to tinker with the PayPal files. Can someone knowledgeable about Zen's PayPal system please take a look at this and verify that it's a valid fix?
Thanks!
Bookmarks