ATUM slows down order editing with custom endpoint
-
Hi, i have to post it here because i cant log in to the atum support on your site. It does not recognize my account anymore and recovering password funciton on your site does not send me an email.
Im using the follwong code to change the status of orders, ATUM activate it takes 1500 ms on an live server with no other plugins, fresch installation and sotrefront theme – but ATUM deactivate it drops to 600 – 700 ms which is ok for me. Pls fix if possible. Here my code – im using HPOS. My Server is optimized and has no errors in server log. No other plugin as mentioned – Running multiple WP sites on this server with 0 issues except this one.// Register the custom endpoint add_action('init', 'end_point_0007'); function end_point_0007() { add_rewrite_rule('^eoed/?', 'index.php?eoed=1', 'top'); } // Add the custom query variable add_filter('query_vars', 'end_point_0007_query_vars'); function end_point_0007_query_vars($vars) { $vars[] = 'eoed'; return $vars; } // Custom handler for editing orders add_action('template_redirect', 'end_point_0007_handler'); function end_point_0007_handler() { global $wp_query; if (isset($wp_query->query_vars['eoed'])) { // Nonce verification $nonce_action = 'edit_nonce'; if (!isset($_GET['nonce']) || !wp_verify_nonce($_GET['nonce'], $nonce_action)) { wp_send_json_error(array('status' => 'error', 'message' => 'Invalid nonce.')); } // Set content type header('Content-Type: application/json'); // Get order ID and new status from the request $order_id = isset($_GET['order_id']) ? intval($_GET['order_id']) : 0; $new_status = isset($_GET['new_status']) ? sanitize_text_field($_GET['new_status']) : ''; if ($order_id <= 0 || empty($new_status)) { wp_send_json_error(array('status' => 'error', 'message' => 'Invalid order ID or status.')); } // Load the order using HPOS $order = wc_get_order($order_id); if (!$order) { wp_send_json_error(array('status' => 'error', 'message' => 'Order not found.')); } // Update the order status $order->set_status($new_status, 'Order status updated by custom endpoint.'); $order->save(); // Save the changes to the database wp_send_json_success(array('status' => 'success', 'message' => 'Order status updated.')); } }
- You must be logged in to reply to this topic.