Automattic\WooCommerce\Internal\ProductAttributesLookup
LookupDataStore::maybe_schedule_update()
Schedule an update of the product attributes lookup table for a given product. If an update for the same action is already scheduled, nothing is done.
If the 'woocommerce_attribute_lookup_direct_update' option is set to 'yes', the update is done directly, without scheduling.
Method of the class: LookupDataStore{}
No Hooks.
Return
null
. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->maybe_schedule_update( $product_id, $action );
- $product_id(int) (required)
- The product id to schedule the update for.
- $action(int) (required)
- The action to perform, one of the ACTION_ constants.
LookupDataStore::maybe_schedule_update() LookupDataStore::maybe schedule update code WC 9.5.1
private function maybe_schedule_update( int $product_id, int $action ) { if ( get_option( 'woocommerce_attribute_lookup_direct_updates' ) === 'yes' ) { $this->run_update_callback( $product_id, $action ); return; } $args = array( $product_id, $action ); $queue = WC()->get_instance_of( \WC_Queue::class ); $already_scheduled = $queue->search( array( 'hook' => 'woocommerce_run_product_attribute_lookup_update_callback', 'args' => $args, 'status' => \ActionScheduler_Store::STATUS_PENDING, ), 'ids' ); if ( empty( $already_scheduled ) ) { $queue->schedule_single( WC()->call_function( 'time' ) + 1, 'woocommerce_run_product_attribute_lookup_update_callback', $args, 'woocommerce-db-updates' ); } }