ayeh botak
ayeh botak

Reputation: 3

woocommerce Client city to be sent on ‘new order’ email

We get constant fake orders from our competition, we need to see the real city behind the IP the client placed the order, so we would like to see some field called ‘real city’ on the email that we received on each order. Until now we managed to get the IP by adding this line on function.php but its time consuming to open browser and manually search the city to see if match the client order city. As you may notice we added the real city line but its only extracting what the client selects so its not good, could I get the city name based on IP ? Thank you !

function send_customer_city( $order, $sent_to_admin, $plain_text, $email ){
if( ‘new_order’ == $email->id ){
echo ‘<br>
<p>‘.__(‘Client IP’).’: ‘. get_post_meta( $order->id, ‘_customer_ip_address’, true ).'</p>

<p>‘.__(‘Real City’).’: ‘. get_post_meta( $order->get_id(), ‘_billing_city’, true ).'</p>’;

 }
 }

Upvotes: 0

Views: 50

Answers (1)

Mannu saraswat
Mannu saraswat

Reputation: 1081

In place of doing this You can do one thing You can place a hidden filed on the checkout form and set the city according to IP/LAT-LONG using any API. using woocommerce hooks woocommerce_after_checkout_billing_form

AT the time of placing an order You can get this filed data as well to check that Is This Real order Or fake?

OR

You can also check this before placing an order to avoid fake orders creations using woocommerce_review_order_before_submit or any other hook

Upvotes: 1

Related Questions