From 84e008337c6b8fdaeebfb71ab4e41b8011cba0eb Mon Sep 17 00:00:00 2001 From: Peter Fabian Date: Mon, 13 Aug 2018 14:37:21 +0200 Subject: [PATCH 1/2] Update customer's ip address on successful payment. --- includes/shortcodes/class-wc-shortcode-checkout.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/includes/shortcodes/class-wc-shortcode-checkout.php b/includes/shortcodes/class-wc-shortcode-checkout.php index afc71182a6b..ff44fae833c 100644 --- a/includes/shortcodes/class-wc-shortcode-checkout.php +++ b/includes/shortcodes/class-wc-shortcode-checkout.php @@ -229,6 +229,12 @@ class WC_Shortcode_Checkout { // Empty awaiting payment session. unset( WC()->session->order_awaiting_payment ); + // In case order is created from admin, but paid by the actual customer, store the ip address of the payer. + if ( false !== $order ) { + $order->set_customer_ip_address( WC_Geolocation::get_ip_address() ); + $order->save(); + } + // Empty current cart. wc_empty_cart(); From ca08beaa42d396681cfa69c5222807702a77abf1 Mon Sep 17 00:00:00 2001 From: Peter Fabian Date: Mon, 13 Aug 2018 19:44:33 +0200 Subject: [PATCH 2/2] Changed explicit check to implicit. --- includes/shortcodes/class-wc-shortcode-checkout.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/shortcodes/class-wc-shortcode-checkout.php b/includes/shortcodes/class-wc-shortcode-checkout.php index ff44fae833c..7305eb6f1dd 100644 --- a/includes/shortcodes/class-wc-shortcode-checkout.php +++ b/includes/shortcodes/class-wc-shortcode-checkout.php @@ -230,7 +230,7 @@ class WC_Shortcode_Checkout { unset( WC()->session->order_awaiting_payment ); // In case order is created from admin, but paid by the actual customer, store the ip address of the payer. - if ( false !== $order ) { + if ( $order ) { $order->set_customer_ip_address( WC_Geolocation::get_ip_address() ); $order->save(); }