mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 10:55:00 +08:00
Handle shipping address/methods update
This commit is contained in:
parent
f396870610
commit
efb86acb1f
6 changed files with 204 additions and 5 deletions
|
@ -19,7 +19,7 @@ export const splitFullName = (fullName) => {
|
|||
* @returns {Object}
|
||||
*/
|
||||
export const paypalAddressToWc = (address) => {
|
||||
const map = {
|
||||
let map = {
|
||||
country_code: 'country',
|
||||
address_line_1: 'address_1',
|
||||
address_line_2: 'address_2',
|
||||
|
@ -27,6 +27,14 @@ export const paypalAddressToWc = (address) => {
|
|||
admin_area_2: 'city',
|
||||
postal_code: 'postcode',
|
||||
};
|
||||
if (address.city) { // address not from API, such as onShippingChange
|
||||
map = {
|
||||
country_code: 'country',
|
||||
state: 'state',
|
||||
city: 'city',
|
||||
postal_code: 'postcode',
|
||||
};
|
||||
}
|
||||
const result = {};
|
||||
Object.entries(map).forEach(([paypalKey, wcKey]) => {
|
||||
if (address[paypalKey]) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue