I think I finally may have found a viable solution but I need some help getting the data into the PayPal tables properly. This solution is independent of the one I posted earlier and seems much cleaner and less risky.
In my travels around the PayPal developer’s handbooks I found a new API function which I had not seen before. This function is "NOSHIPPING". When I came across it I new it was the answer
. Basically this API call removes the customer’s option to change their shipping address on the PayPal screen. The code I wrote only runs if their selected shipping address is not the same as their default one and their account is not a temporary one.
Find this code:
Code:
/**
* Ask PayPal for the token with which to initiate communications
*/
$response = $doPayPal->SetExpressCheckout(number_format($order_amount, 2), $return_url, $cancel_url, $options);
(line 1668 or so of my includes/modules/payment/paypalwpp.php)
Just ABOVE it add:
Code:
if(isset($_SESSION['sendto']) && isset($_SESSION['customer_default_address_id'])
&& $_SESSION['sendto'] != $_SESSION['customer_default_address_id'] && isset($_SESSION['customer_id'])){
//This user has selected a shipping address other than their default address book entry
$sql = "SELECT customers_paypal_ec
FROM " . TABLE_CUSTOMERS . "
WHERE customers_id = '".$_SESSION['customer_id']."' ";
$check_customer = $db->Execute($sql);
if (!$check_customer->EOF) {
if ($check_customer->fields['customers_paypal_ec'] != '1') {
//this is not a temporary account so hide the shipping detail on the PayPal screen
$options['NOSHIPPING'] = 1;
}
}
}
This seems to work really well as far as I can see except that in our scenario (customer choosing different shipping address) it does not enter all address details correctly into the PayPal table as there is no address response from PayPal. The shipping address is entered into the Zen orders tables correctly and shows the correct shipping address.
DrByte I would appreciate if you could take a look at the code above and let me know if it is a viable workaround/patch as there seems to be many threads dealing with the same issue as we are here. Most of the other threads don't have any real answers and some contain custom hacks that don't look too sound to me.
Bookmarks