Inventory Sync for WooCommerce: Hook Reference

rudr_invsync_product_data

This hook allows you to add other product data to the stock sync or remove existing product data from the sync (when running the plugin for standalone WooCommerce stores).

$product_data = apply_filters( 'rudr_invsync_product_data', $product_data, $product, $store_url );
$product_data
(array) Product data, currently supports the following parameters: manage_stock, stock_status, stock_quantity, regular_price, sale_price.
$product
(WC_Product) Product (or product variation) object.
$store_url
(string) URL of the specific store we are syncing the product data with.

Example. Sync only stock quantity and nothing else

For example, you can only sync product stock quantity without syncing stock status and stock management parameters:

add_filter( 'rudr_invsync_product_data', function( $product_data, $product ) {

	unset( $product_data[ 'manage_stock' ] );
	unset( $product_data[ 'stock_status' ] );

	return $product_data;

}, 25, 2 );

Read here how to use code snippets.

rudr_wpmu_invsync_product_data

Similar hook to rudr_invsync_product_data but works only for stores which are a part of the same WooCommerce Multisite network.

$product_data = apply_filters( 'rudr_wpmu_invsync_product_data', $product_data, $product, $store_id );
$product_data
(array) Product data, currently supports the following parameters: manage_stock, stock_status, stock_quantity, regular_price, sale_price.
$product
(WC_Product) Product (or product variation) object.
$store_id
(int) ID of the target store within the same WordPress Multisite network, we are syncing the product data with.

Example. Also sync product price to a specific store

Let’s sync the product price, but only to a store with a specific ID.

add_filter( 'rudr_wpmu_invsync_product_data', function( $product_data, $product, $store_id ) {

	if( 5 === $store_id ) {
		$product_data[ 'regular_price' ] = $product->get_regular_price();
	}

	return $product_data;

}, 25, 3 );

Read here how to use code snippets.

rudr_invsync_exclude_product_ids

If you want the plugin to completely ignore some specific products (or variations), you can provide their IDs as an array in this filter hook, for example:

add_filter( 'rudr_invsync_exclude_product_ids', function( $product_ids ) {

	return array( 123, 134, 150 );

} );

Need more help?