• Resolved skaught

    (@skaught)


    The plug in just stopped working one day. It goes to a blank screen when selected. I didn’t install anything new – no new plug ins, themes or WP system. It just worked one day and then didn’t the next.

    Any ideas?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter skaught

    (@skaught)

    Oh – and I deleted the plug in and reinstalled it. Same problem.

    I suspect your issue is the same one I’ve had, though I just installed the plugin today.

    I have ~8000 orders in my store, and the query in wevop_get_orders() uses around 800MB to complete, so hits the PHP limit for memory usage.

    But, there is a solution, to modify the first query, I can reduce the memory usage of the function to 30MB… ??

    The “my_query” result only uses the post->ids, so doesn’t need the whole post data returned, so you need to use the ‘fields’ parameter to WP_Query.

    Here is the new code:

            function wevop_get_orders() {                                                                                                                                                                           
                global $woocommerce, $product;                                                                                                                                                                      
                $args = array(                                                                                                                                                                                      
                    'post_type'     => 'shop_order',                                                                                                                                                                
                    'post_status'   => array_keys( wc_get_order_statuses() ),                                                                                                                                       
                    'posts_per_page'=> '-1',                                                                                                                                                                        
                    'date_query'    => array(                                                                                                                                                                       
                        array(                                                                                                                                                                                      
                            'after'     => $this->product_filter_date_from,                                                                                                                                         
                            'before'    => $this->product_filter_date_to,                                                                                                                                           
                            'inclusive' => true,                                                                                                                                                                    
                        )                                                                                                                                                                                           
                                             ),                                                                                                                                                                     
                    'fields' => 'ids'                                                                                                                                                                               
                );                                                                                                                                                                                                  
                                                                                                                                                                                                                    
                $my_query = new WP_Query( $args );                                                                                                                                                                  
                $order_pro_arr = array();                                                                                                                                                                           
                foreach($my_query->posts as $order_id){                                                                                                                                                             
                    $order      = new WC_Order( $order_id );                                                                                                                                                        
                    $items      = $order->get_items();                                                                                                                                                              
                    foreach ( $items as $ordered_item_id => $item ) {                                                                                                                                               
    

    The main change is the ‘fields’ => ‘ids’, and then the while changes to a foreach because my_query is no longer a set of posts with the have_posts() stuff, but just a plainer query with the posts parameter being a list of order ids.

    I’m not sure if the plugin is going to do what my customer wants, but at least it runs now, and you’ll probably want to use my code to make it work quicker for everyone.

    Same issue in wop_get_variable_product_orders().

            function wope_get_variable_product_orders() {                                                                                                                                                           
                $status = array_keys( wc_get_order_statuses() );                                                                                                                                                    
                if ( !empty( $this->order_filter_by_status ) ) {                                                                                                                                                    
                    $status = $this->order_filter_by_status;                                                                                                                                                        
                }                                                                                                                                                                                                   
                                                                                                                                                                                                                    
                $args = array(                                                                                                                                                                                      
                    'post_type'     => 'shop_order',                                                                                                                                                                
                    'post_status'   => $status,                                                                                                                                                                     
                    'posts_per_page'=> '-1',                                                                                                                                                                        
                    'date_query'    => array(                                                                                                                                                                       
                        array(                                                                                                                                                                                      
                            'after'     => $this->order_filter_date_from,                                                                                                                                           
                            'before'    => $this->order_filter_date_to,                                                                                                                                             
                            'inclusive' => true,                                                                                                                                                                    
                        )                                                                                                                                                                                           
                                             ),                                                                                                                                                                     
                    'fields' => 'ids'                                                                                                                                                                               
                );                                                                                                                                                                                                  
                                                                                                                                                                                                                    
                                                                                                                                                                                                                    
                $query  = new WP_Query(  $args  );                                                                                                                                                                  
                $finalOrders    = array();                                                                                                                                                                          
                foreach ( $query->posts as $orderId ) {                                                                                                                                                             
    

    Though this query was written even worse, with the extra call to get_posts().

    That page still takes a long time to load (I have ~1000 variable orders), really some pagination would be good, rather than loading all results out of the database.

    This page still uses more than 256MB of RAM, and takes 10-15 seconds to load, but I don’t think it can be made more efficient without adding in pagination.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Plug in Stopped Working’ is closed to new replies.