Convert states to strings for PayPal Closes #5078
This commit is contained in:
parent
c39c4ca5a3
commit
da970638d5
|
@ -313,7 +313,7 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
|
||||||
'address1' => $order->billing_address_1,
|
'address1' => $order->billing_address_1,
|
||||||
'address2' => $order->billing_address_2,
|
'address2' => $order->billing_address_2,
|
||||||
'city' => $order->billing_city,
|
'city' => $order->billing_city,
|
||||||
'state' => $order->billing_state,
|
'state' => $this->get_paypal_state( $order->billing_country, $order->billing_state ),
|
||||||
'zip' => $order->billing_postcode,
|
'zip' => $order->billing_postcode,
|
||||||
'country' => $order->billing_country,
|
'country' => $order->billing_country,
|
||||||
'email' => $order->billing_email
|
'email' => $order->billing_email
|
||||||
|
@ -334,7 +334,7 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
|
||||||
$paypal_args['address1'] = $order->shipping_address_1;
|
$paypal_args['address1'] = $order->shipping_address_1;
|
||||||
$paypal_args['address2'] = $order->shipping_address_2;
|
$paypal_args['address2'] = $order->shipping_address_2;
|
||||||
$paypal_args['city'] = $order->shipping_city;
|
$paypal_args['city'] = $order->shipping_city;
|
||||||
$paypal_args['state'] = $order->shipping_state;
|
$paypal_args['state'] = $this->get_paypal_state( $order->shipping_country, $order->shipping_state );
|
||||||
$paypal_args['country'] = $order->shipping_country;
|
$paypal_args['country'] = $order->shipping_country;
|
||||||
$paypal_args['zip'] = $order->shipping_postcode;
|
$paypal_args['zip'] = $order->shipping_postcode;
|
||||||
} else {
|
} else {
|
||||||
|
@ -936,4 +936,24 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
|
||||||
|
|
||||||
return $order;
|
return $order;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the state to send to paypal
|
||||||
|
* @param string $cc
|
||||||
|
* @param string $state
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_paypal_state( $cc, $state ) {
|
||||||
|
if ( 'US' === $cc ) {
|
||||||
|
return $state;
|
||||||
|
}
|
||||||
|
|
||||||
|
$states = WC()->countries->get_states( $cc );
|
||||||
|
|
||||||
|
if ( isset( $states[ $state ] ) ) {
|
||||||
|
return $states[ $state ];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $state;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue