diff --git a/acf-json/group_5f9f3d11c5367.json b/acf-json/group_5f9f3d11c5367.json index 15e5e2a..baccc11 100644 --- a/acf-json/group_5f9f3d11c5367.json +++ b/acf-json/group_5f9f3d11c5367.json @@ -191,6 +191,63 @@ "prepend": "", "append": "", "maxlength": "" + }, + { + "key": "field_60a3fed902bc5", + "label": "Authentications", + "name": "authentications", + "type": "repeater", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "collapsed": "", + "min": 0, + "max": 0, + "layout": "table", + "button_label": "", + "sub_fields": [ + { + "key": "field_60a3ff0002bc6", + "label": "Date", + "name": "date", + "type": "date_picker", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "display_format": "d\/m\/Y", + "return_format": "d\/m\/Y", + "first_day": 1 + }, + { + "key": "field_60a3ff0d02bc7", + "label": "IP Address", + "name": "ip_address", + "type": "text", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "default_value": "", + "placeholder": "", + "prepend": "", + "append": "", + "maxlength": "" + } + ] } ], "location": [ @@ -210,5 +267,5 @@ "hide_on_screen": "", "active": true, "description": "", - "modified": 1606765859 + "modified": 1621362064 } \ No newline at end of file diff --git a/woocommerce-coupon-gateway.php b/woocommerce-coupon-gateway.php index 9ca7b6e..95b9b27 100644 --- a/woocommerce-coupon-gateway.php +++ b/woocommerce-coupon-gateway.php @@ -137,6 +137,27 @@ function wcg_process_coupon_code_url() // set coupon cookie? if (!isset($_COOKIE[$coupon_cookie]) || $_COOKIE[$coupon_cookie] != $coupon_code) { setcookie($coupon_cookie, $coupon_code, $expire); + + // track the coupon has been used to login - timestamp and IP address + $date = date('d/m/Y'); + $ip = ''; + + if (!empty($_SERVER['HTTP_CLIENT_IP'])) { + //ip from share internet + $ip = $_SERVER['HTTP_CLIENT_IP']; + } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { + //ip pass from proxy + $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; + } else { + $ip = $_SERVER['REMOTE_ADDR']; + } + + $row = array( + 'date' => $date, + 'ip_address' => $ip + ); + add_row('authentications', $row, $coupon->id); + } // set redirect cookie? if (!isset($_COOKIE[$redirect_cookie]) || $_COOKIE[$redirect_cookie] != $redirect_slug) {