get_user_id(); $orderId = ($this->ivav_version_check(2.7)) ? $orderId = $order->get_id() : $order->id; IvavAgeVerify::verify($userId, $orderId); } public function ivav_wc_order_manual_clear_action($order) { $userId = $order->get_user_id(); $orderId = ($this->ivav_version_check(2.7)) ? $orderId = $order->get_id() : $order->id; IvavAgeVerify::clear($userId, $orderId); } public function ivav_register_bulk_verify($actions) { $actions['ivav-bulk-verify'] = __('AgeVerify: mark user as manually age verified.'); return $actions; } public function ivav_bulk_action_edit_user($redirectTo, $action, $userIds) { if ($action == 'ivav-bulk-verify') { foreach ($userIds as $userId) { IvavAgeVerify::verify($userId); } } return $redirectTo; } public function ivav_register_bulk_verify_order($actions) { $actions['ivav-bulk-verify'] = __('AgeVerify: mark user as manually age verified.'); return $actions; } public function ivav_bulk_action_edit_order($redirectTo, $action, $orderIds) { if ($action == 'ivav-bulk-verify') { foreach ($orderIds as $orderId) { $order = new WC_Order($orderId); $userId = $order->get_user_id(); IvavAgeVerify::verify($userId, $orderId); } } return $redirectTo; } public function ivav_custom_order_option($post) { $orderId = $post->ID; $order = new WC_Order( $orderId ); $userId = $order->get_user_id(); $av = IvavAgeVerify::load($userId, $orderId); if ($av->isManual()) { $class = 'dashicons dashicons-yes'; $color = 'green'; $msg = 'Age manually verified'; } elseif ($av->isVerified()) { $class = 'dashicons dashicons-yes'; $color = 'green'; $description = 'Age Verified'; if (in_array($this->forceName, ['billing', 'both']) && !$av->isNameMatch($order->billing_first_name, $order->billing_last_name)) { $color = 'orange'; $description .= ' - Name Mismatch'; } if (in_array($this->forceName, ['shipping', 'both']) && !$av->isNameMatch($order->shipping_first_name, $order->shipping_last_name)) { $color = 'orange'; $description .= ' - Name Mismatch'; } $msg = '' . $description . ''; if (is_numeric($av->age)) { $msg .= '
Name: ' . $av->firstName . ' ' . $av->lastName; $msg .= '
Birthdate: ' . $av->birthdate; $msg .= '
Age at verification: ' . $av->age; } } elseif ($av->isDenied()) { $class = 'dashicons dashicons-no'; $color = 'red'; $msg = 'Age verification failed'; } else { $class = 'dashicons dashicons-no'; $color = 'black'; $msg = 'Age unverified'; } echo "
$msg
"; } public function ivav_shop_order_columns($columns) { $columns = (is_array($columns)) ? $columns : array(); $ageVerify = array('ageVerify' => 'AgeVerify'); $position = 3; $newColumns = array_slice($columns, 0, $position, true) + $ageVerify + array_slice($columns, $position, count($columns)-$position, true); //stop editing return $newColumns; } public function ivav_shop_order_posts_custom_column($column) { global $post, $woocommerce, $the_order; if ( empty( $the_order ) || $the_order->id != $post->ID ) { $the_order = new WC_Order( $post->ID ); } if ($column == 'ageVerify') { $userId = $the_order->get_user_id(); $orderId = $post->ID; $class = 'dashicons-no'; $color = 'black'; $title = 'Age unverified'; $av = IvavAgeVerify::load($userId, $orderId); if ($av->isVerified()) { $color = 'green'; $title = 'Age Verified'; if ($av->isManual()) { $title .= ' Manually'; } else { if (in_array($this->forceName, ['shipping', 'both']) && !$av->isNameMatch($the_order->shipping_first_name, $the_order->shipping_last_name)) { $color = 'orange'; $title .= ' - Name Mismatch'; } if (in_array($this->forceName, ['billing', 'both']) && !$av->isNameMatch($the_order->billing_first_name, $the_order->billing_last_name)) { $color = 'orange'; $title .= ' - Name Mismatch'; } } $class = 'dashicons-yes'; if ($av->date != '') $title .= "\nDate: $av->date"; } elseif ($av->isDenied()) { $color = 'red'; $title = 'Age verification failed'; if ($av->date != '') $title .= "\nDate: $av->date"; } echo ''; } } public function ivav_wc_order_actions($actions) { global $theorder; if ($theorder == null) { return $actions; } $orderId = ($this->ivav_version_check(2.7)) ? $orderId = $theorder->get_id() : $theorder->id; $order = new WC_Order($orderId); $userId = $order->get_user_id(); $av = IvavAgeVerify::load($userId, $orderId); if (!$av->isManual()) { $actions['ivav_wc_order_manual_verify_action'] = __('AgeVerify: mark order as manually age verified.'); } if ($av->guid != '') { $actions['ivav_wc_order_manual_clear_action'] = __('AgeVerify: clear age verification data.'); } return $actions; } public function ivav_hide_order_status($order_statuses) { global $theorder; if ($theorder == null) { return $order_statuses; } $orderId = ($this->ivav_version_check(2.7)) ? $orderId = $theorder->get_id() : $orderId = $theorder->id; $order = new WC_Order($orderId); $userId = $order->get_user_id(); $av = IvavAgeVerify::load($userId, $orderId); if ($this->forceName == 'billing' || $this->forceName == 'both' && !$av->isManual() && !$av->isNameMatch($order->billing_first_name, $order->billing_last_name)) { unset($order_statuses['wc-processing']); } if ($this->forceName == 'shipping' || $this->forceName == 'both' && !$av->isManual() && !$av->isNameMatch($order->shipping_first_name, $order->shipping_last_name)) { unset($order_statuses['wc-processing']); } return $order_statuses; } public function ivav_show_extra_user_fields($user) { $av = IvavAgeVerify::load($user->ID); if ($av->isManual() == true) { $msg = 'Manually verified'; } elseif ($av->isVerified() == true) { $msg = '' . $guid . ''; if (is_numeric($av->age)) { $extra = "Name$av->firstName $av->lastName"; $extra .= "Birthdate$av->birthdate"; $extra .= "Age at verification$av->age"; } } elseif ($av->isDenied() == true) { $msg = 'Failed'; } else { $msg = 'Unverified'; } echo "

AgeVerify by Inverite

$extra
Age Verification Status$msg
"; } }