add_filter('woocommerce_shortcode_order_tracking_form', 'customize_order_tracking_form');function customize_order_tracking_form($output) { // Check if the order ID is submitted by the user if (isset($_POST['order_id']) && !empty($_POST['order_id'])) { // Sanitize and retrieve the order ID entered by the customer $order_id = absint($_POST['order_id']);global $wpdb;// Retrieve the tracking URL from the wp_woocommerce_order_itemmeta table $tracking_url = $wpdb->get_var($wpdb->prepare( "SELECT meta_value FROM {$wpdb->prefix}woocommerce_order_itemmeta WHERE meta_key = 'tracking_url' AND order_item_id IN (SELECT order_item_id FROM {$wpdb->prefix}woocommerce_order_items WHERE order_id = %d)", $order_id ));if ($tracking_url) { // Modify the output to display the tracking URL $output .= '

Tracking URL: ' . esc_url($tracking_url) . '

'; } } else { // Display the order tracking form with an input field for the order ID $output .= '
'; $output .= ''; $output .= ''; $output .= ''; $output .= '
'; }return $output; }
Shopping Cart