The shipping address coming into AmazonSeller is different from the shipping add
-
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.
- The topic ‘The shipping address coming into AmazonSeller is different from the shipping add’ is closed to new replies.