• Resolved atsukisakai

    (@atsukisakai)


    The shipping address coming into AmazonSeller is different from the shipping address coming into Woocommerce.

    AmazonPay lists it as 3976-1 Higashi-Wakamatsu-cho, Tsuchiura, Ibaraki, but when it comes into Woocommerce, it is 3976-1 Higashi-Wakamatsu-cho, Tsuchiura, Ibaraki, Shimoyamate Central Heights-505 Rabbit Acupuncture Clinic. I don’t know where the “Shimoyamate Central Heights-505 Usagi Acupuncture Clinic” part is given from. Originally, such an address does not exist, so it is unclear why it behaves this way. Can anyone lend me some wisdom?

    function replaceAmazonPayShippingAndBillingFields($order_id) {
    
    $order = wc_get_order($order_id);
    
    $shipping_address = $order->get_address();
    
    if($shipping_address['city'] === ""){
    
    if($shipping_address['last_name'] === '.'){
    
    $full_name = str_replace(' ', '', $shipping_address['first_name']);
    
    // 文字列を分割して姓と名前にセット
    
    $last_name = mb_substr($full_name, 0, 2);
    
    $first_name = mb_substr($full_name, 2);
    
    $new_billing_address = array(
    
    'first_name' => $first_name, // 姓をセット
    
    'last_name' => $last_name,
    
    'address_1' => $shipping_address["address_2"],
    
    'address_2' => $shipping_address['company'],
    
    'city' => $shipping_address['address_1'],
    
    'state' => $shipping_address['state'],
    
    'postcode' => $shipping_address['postcode'],
    
    'country' => $shipping_address['country'],
    
    );
    
    $new_shipping_address = array(
    
    'first_name' => $first_name, // 姓をセット
    
    'last_name' => $last_name,
    
    'address_1' => $shipping_address["address_2"],
    
    'address_2' => $shipping_address['company'],
    
    'city' => $shipping_address['address_1'],
    
    'state' => $shipping_address['state'],
    
    'postcode' => $shipping_address['postcode'],
    
    'country' => $shipping_address['country'],
    
    );
    
    }
    
    $order->set_shipping_address($new_shipping_address);
    
    $order->set_billing_address($new_billing_address);
    
    $order->save();
    
    }
    
    }
    
    // woocommerce_new_order アクションフックに関数を追加
    
    add_action('woocommerce_new_order', 'replaceAmazonPayShippingAndBillingFields');

    The above code is for Japanese when ordering with AmazonPay, where city is an empty character and firstname is “.”. when the order is in Japanese. It works when there is a new order and the city is an empty character, and corrects the order address discrepancy.
    Is there a problem with this code? Most orders work fine.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Christian

    (@christian1983)

    Hey @atsukisakai ,

    We’ll check more in depth with the development team, and get back to you.

    We’ll be in touch soon.

    Best,
    Christian

    Plugin Support Christian

    (@christian1983)

    Hey @atsukisakai

    Hope you are doing well!

    Testing your code snippet, the only thing I notice is that the company field is duplicated: https://ibb.co/X2kfNgK

    Also depends on what address is comming from Amazon wallet.

    Best,
    Christian

    Thread Starter atsukisakai

    (@atsukisakai)

    Thanks for the answer!
    So you are saying that there is a problem with this code snippet! However, if I don’t use this code, the city will be empty. The fundamental problem is that the lastname is “.” and city is empty, so we are using this code snippet to fix that.

    What do you think is the best way to fix this?

    This code is executed when a new order is saved in woocommerce.

    Plugin Support Christian

    (@christian1983)

    Hey @atsukisakai

    Let me check with the development team, for the Last Name with “.” could be an issue on the plugin. And for the city, we need to check more on how the full address is filled on Amazon Pay.

    Can you give us some real address examples in Japanese?

    Using the Amazon Pay Testing account the city is always “”, but if I manually add the address the city it’s ok. https://ibb.co/p1C8bM9

    Best,
    Christian

    Plugin Support Christian

    (@christian1983)

    Hey @atsukisakai

    here is the issue opened on the plugin repository. Please add all the information that we will need to fix this issue, so Japanese address are loaded as they should.

    Best,
    Christian

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘The shipping address coming into AmazonSeller is different from the shipping add’ is closed to new replies.