__('Order status is', 'advance-notification-for-woocommerce'), 'not_in' => __('Order status is not', 'advance-notification-for-woocommerce'), ); } /** * Get HTML for value field * * @param string $html Current HTML. * @param string $condition_id Condition ID. * @param string $unused_param Unused parameter. * @param mixed $current_value Current value. * @return string */ public function get_value_field($html, $condition_id, $unused_param, $current_value) { $statuses = $this->get_order_statuses(); $current_statuses = array(); if (!empty($current_value)) { $current_statuses = is_array($current_value) ? $current_value : array($current_value); } ob_start(); ?>
is_match_for_new_order($return, $data, $trigger_type, $operator, $value); } return false; } public function is_match_for_new_order($return, $data, $trigger_type, $operator, $value) { $order = isset($data['order']) ? $data['order'] : null; if (!$order || !is_a($order, 'WC_Order') || empty($value)) { return false; } $statuses_to_check = is_array($value) ? $value : array($value); $order_status = $order->get_status(); if (empty($order_status)) { return false; } $is_in_list = in_array($order_status, $statuses_to_check, true); if ($operator === 'in') { return $is_in_list; } else { // 'not_in' return !$is_in_list; } } /** * Get all available order statuses * * @return array */ private function get_order_statuses() { if (!function_exists('wc_get_order_statuses')) { return array(); } $raw_statuses = wc_get_order_statuses(); $statuses = array(); foreach ($raw_statuses as $status_key => $status_label) { $trimmed_key = str_replace('wc-', '', $status_key); $statuses[$trimmed_key] = $status_label; } return $statuses; } }