wp-background-processing icon indicating copy to clipboard operation
wp-background-processing copied to clipboard

Class 'WP_Background_Process' not found

Open CNSam opened this issue 8 years ago • 4 comments

Hi there,

I am currently using the Wordpress Plugin Boilerplate (https://github.com/DevinVinson/WordPress-Plugin-Boilerplate) to build a plugin as I have many times before however now have a requirement for background processing.

I am also using woocommerce and what im wanting to do is upon payment complete is push the order to our warehouse management system but do this as a background task as opposed to taking up the time on the user-facing side.

Unfortunately when I am running through a test transaction I am constantly receiving

Class 'WP_Background_Process' not found in WCKhaos/includes/tasks/SendOrderTask.php on line 3

Have you any experience with WooCommerce, WPPB and your plugin or any advice so I can look further?

Thanks in advance

CNSam avatar Sep 12 '16 12:09 CNSam

WP_Background_Process is actually included in WooCommerce, see:

https://github.com/woothemes/woocommerce/blob/master/includes/libraries/wp-background-process.php

What does your code look like?

A5hleyRich avatar Sep 12 '16 14:09 A5hleyRich

Hi Ashley,

Thanks for your response - I think i've fathomed the inclusion of the file out, however I cannot for the life of me work out why the tasks aren't being ran:

I have this within my plugin:

        $this->loader->add_action( 'woocommerce_order_status_changed', $khaos_order, 'process_order_for_queue');

The `process_order_for_queue' function looks like:

public function process_order_for_queue( $order_id )
    {

        $order_id = '114';
        $queue = new SendOrderTask();
        $queue->push_to_queue($order_id);
            $queue->save();
            $queue->dispatch();
    }

What am I missing here, there seems to be a number of "wp_khaos_orders_batch_fed9ebb241fa503030fd6debd282d73a" within the options table but nothing is actually firing?

CNSam avatar Sep 12 '16 14:09 CNSam

Are you able to manually hit wp-admin/admin-ajax.php? Is the site behind basic auth?

A5hleyRich avatar Sep 12 '16 14:09 A5hleyRich

Yep, can hit that absolutely fine, I've managed to dump out the url that is generated: /wp-admin/admin-ajax.php?action=wp_khaos_orders&nonce=5d91a7bdaa

Also, If I var_dump the $queue->dispatch() call im getting the following:

array (size=5)
  'headers' => 
    array (size=0)
      empty
  'body' => string '' (length=0)
  'response' => 
    array (size=2)
      'code' => boolean false
      'message' => boolean false
  'cookies' => 
    array (size=0)
      empty
  'http_response' => null

Anything to go on here?

* UPDATE* I've installed the example plugin and that all seems to work absolutely fine - seriously at a loss, im just wondering if it has something to do with the ordering of the initialisation of the Wordpress Plugin Boilerplate

CNSam avatar Sep 12 '16 14:09 CNSam

Closing this rather old support issue, if by some miracle this is an outstanding issue, please comment.

ianmjones avatar Apr 11 '23 15:04 ianmjones