WC handling of billing address is atrocious
-
Having recently come to use WC for a shop implementation linking to an existing PayPal business account, I am frankly appalled at the lack of integrity and deep flaws that exist within the WC’s handling of billing and shipping addresses.
From my point of view – running a simple checkout, pay and ship – all I need is exactly what PayPal provides:
Billing Name and Email
Complete Shipping Details
– (bonus points if I can specify an additional shipping email here, but probably not necessary)To see how fundamentally broken this is do the following.
Do a PayPal Checkout from the Cart and ship to a different address. In order to track this through the existing WC system, try:
Fred Biller, USA address, fred@email
Jane Shipper, UK addressPayPal on successful checkout returns to “Confirm PayPal order” and provides:
Fred Biller
fred@emailShipping Details:
Jane Shipper, UK address.Then, this code is executed from:
woocommerce-gateway-paypal-express-checkout
Includes
class-wc-gateway-ppec-checkout-handler.phpLine about 211 (shipping/billing details are retrieved). Then this horrible hack:
if ( empty( $billing_details[‘address_1’] ) ) {
// Set flag so that WC copies billing to shipping
$_POST[‘ship_to_different_address’] = 0;$copyable_keys = array( ‘first_name’, ‘last_name’, ‘address_1’, ‘address_2’, ‘city’, ‘state’, ‘postcode’, ‘country’ );
foreach ( $copyable_keys as $copyable_key ) {
if ( array_key_exists( $copyable_key, $shipping_details ) ) {
$billing_details[ $copyable_key ] = $shipping_details[ $copyable_key ];
}`
}
} else {
// Shipping may be different from billing, so set flag to not copy address from billing
$_POST[‘ship_to_different_address’] = 1;
}WTF!?!?!
Until this point, the billing first and last name IS CORRECT. It no longer is and is lost.
ALL consequent activity from WC sees a cascading plethora of mis-addressing, mis-listing. If you want to see how bad this is, just comment out the names:
$copyable_keys = array( /*‘first_name’, ‘last_name’,*/ ‘address_1’,…);
and watch it go through the process of copying billing to shipping address (YES IT EVEN DOES THIS! – admin-new-order email).$_POST[‘ship_to_different_address’] = 1; seems to be ignored.
I can’t describe how appalled I am with that code, clearly written because much of the WC seems to require a billing address. WHY? WC is a platform to interface TO payment gateways, and it is the legal responsibility of these payment gateways to validate payment details NOT WC. WC has no reason – for a basic operation – to validate/retain/acquire billing address (unless it needs to gather that information for the Payment gateway – in the case of using PayPal it does not).
The correct fix here is this:
(1) WC should work without requiring a Billing address.The easiest way I can see to fix this is to make the following change in that appalling code:
You could do this:
if ( empty( $billing_details[‘address_1’] ) ) {
// Shipping may be different from billing, so set flag to not copy address from billing
$_POST[‘ship_to_different_address’] = 1;
}But WC seems to ignore that and in any case, the logic here is so arcane.
Instead, why not simply do this: if you do not have a valid shipping address, then you ship to the billing address… (or something like that – it is after-all what the UI basically presents).
But you ALWAYS look to the shipping address first – that is what it is there for.
So, the fix in this appalling code might be to simply remove that entire if/else statement – do not overwrite billing address, do not set a variable that is anyway ignored, then fix all the bugs that fallout from WC (there are multitudes).
Then you test this by doing a PayPal Checkout from the Cart, where you will have:
Biller Name, Email
Shipping Detailsand look at everything:
Resulting Confirmation Pages
Resulting Order information
Resulting emails to customers (and admins) for processing/holding/refunding/completion of orders.Then if you have more complex features (such as retaining billing information in accounts), then you can go through those extra steps ensuring that you generate AN ERROR because you do not have a Billing Address, and you need to enable that feature with PayPal.
Pretending you have a billing address is disgraceful, overwriting a valid billing name is appalling. Please, fix it. (And telling me I need to go get Billing Address from PayPal when I don’t need that data is NOT A FIX).
William
- The topic ‘WC handling of billing address is atrocious’ is closed to new replies.