/** * Enqueue script and styles for child theme */ function woodmart_child_enqueue_styles() { wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array( 'woodmart-style' ), wp_get_theme()->get( 'Version' ) ); } add_action( 'wp_enqueue_scripts', 'woodmart_child_enqueue_styles', 10010 ); add_filter( 'woocommerce_checkout_fields', 'bbloomer_rename_woo_checkout_fields' ); function bbloomer_rename_woo_checkout_fields( $fields ) { $fields['billing']['billing_first_name']['label'] = 'Full Name'; return $fields; } add_action('woocommerce_order_get_billing_email', function ( $email ) { if ( ! $email || ! is_email( $email ) ) { return get_option('admin_email'); } return $email; }); function check_duplicate_orders_by_phone_number($order_id) { // Get the order $order = wc_get_order($order_id); if (!$order) { return; } // Get the customer phone number $customer_phone = $order->get_billing_phone(); // Define the time period (72 hours) $time_period = 72 * 60 * 60; // 72 hours in seconds // Get orders with the same phone number within the last 72 hours $args = array( 'meta_query' => array( array( 'key' => '_billing_phone', 'value' => $customer_phone, 'compare' => '=', ), ), 'status' => array('wc-completed', 'wc-processing', 'wc-on-hold'), 'date_query' => array( 'after' => date('Y-m-d H:i:s', strtotime('-72 hours')), 'before' => current_time('mysql'), 'inclusive' => true, ), 'exclude' => array($order_id), // This line will not work directly with wc_get_orders ); $orders = wc_get_orders($args); // Filter out the current order $orders = array_filter($orders, function($existing_order) use ($order_id) { return $existing_order->get_id() !== $order_id; }); // Check if there are duplicate orders if (count($orders) > 0) { update_post_meta($order_id, '_duplicate_order_by_phone', true); } else { update_post_meta($order_id, '_duplicate_order_by_phone', false); } } add_action('woocommerce_thankyou', 'check_duplicate_orders_by_phone_number', 10, 1); add_action('woocommerce_order_status_changed', 'check_duplicate_orders_by_phone_number', 10, 1); // Add a new column to the Orders table function add_duplicate_order_by_phone_column($columns) { $columns['duplicate_order_by_phone'] = __('Duplicate', 'woocommerce'); return $columns; } add_filter('manage_edit-shop_order_columns', 'add_duplicate_order_by_phone_column'); // Populate the custom column function custom_orders_list_column_content($column, $post_id) { if ('duplicate_order_by_phone' === $column) { $duplicate_order = get_post_meta($post_id, '_duplicate_order_by_phone', true); if ($duplicate_order) { echo 'Yes'; } else { echo 'No'; } } } add_action('manage_shop_order_posts_custom_column', 'custom_orders_list_column_content', 10, 2); // Make the column sortable function custom_orders_list_sortable_columns($columns) { $columns['duplicate_order_by_phone'] = '_duplicate_order_by_phone'; return $columns; } add_filter('manage_edit-shop_order_sortable_columns', 'custom_orders_list_sortable_columns'); // Handle the sorting of the custom column function custom_orders_list_column_orderby($vars) { if (isset($vars['orderby']) && '_duplicate_order_by_phone' === $vars['orderby']) { $vars = array_merge($vars, array( 'meta_key' => '_duplicate_order_by_phone', 'orderby' => 'meta_value' )); } return $vars; } add_filter('request', 'custom_orders_list_column_orderby'); // Change logo function custom_login_logo() { echo ' '; } add_action('login_enqueue_scripts', 'custom_login_logo'); function custom_login_logo_url() { return 'https://www.ogerio.com/'; } add_filter('login_headerurl', 'custom_login_logo_url'); function custom_login_logo_url_title() { return 'Go to Ogerio Homepage'; } add_filter('login_headertext', 'custom_login_logo_url_title');