• Resolved evalast

    (@evalast)


    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.'));
        }
    
        }
    • This topic was modified 5 months, 1 week ago by evalast.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Jose Andres Piera

    (@japiera)

    Hi @evalast ,

    Apologies for any inconvenience caused.

    Are you using any premium ATUM add-on?
    Did you try to use the official WooCommerce REST API? Does using it introduce the same delay?

    Please note that we don’t provide custom coding support, so please tell us if you get the same delay using the standard API and we’ll investigate it if so.

    Best Regards,
    José Andrés

    Thread Starter evalast

    (@evalast)

    Hi, i did. It is the same – getting the id and updating the status works in the default WP way, Rest Api, Custom endpoint, in WP actions fine without ATUM activated, but with, it is slow.
    Just try the following – it is the default way of doing it – exactley what im using.

           $order = wc_get_order($order_id);
    // Update the order status
    $order->set_status('cancelled', 'Order status updated by custom endpoint.');
    $order->save(); // Save the changes to the database


    I also tried the older Version to do it - the same. Just slow with ATUM activated:

    $order = wc_get_order($order_id);
    $order->update_status('cancelled', 'Order status updated by custom endpoint.');
    Thread Starter evalast

    (@evalast)

    NO addon

    Plugin Author Jose Andres Piera

    (@japiera)

    Hi @evalast,

    We’ve been checking what ATUM is doing during your call causing the 0,6s – 0,7s additional delay.

    Unfortunately, we can’t reduce it. ATUM uses it to read the ATUM products’ additional properties and make calculations used in Stock Central. Most of ATUM wouldn’t make sense without these properties and calculations.

    Best Regards,
    José Andrés

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.