Simple Inventory Sync: Hook Reference


This hooks allows to either add other product data to sync or to remove some existing product data from the sync (when running the plugin on a regular WordPress install).

Let’s add product (and product variation) prices to the sync:

add_filter( 'rudr_sps_request_body', function( $body, $product ) {

	$regular_price = $product->get_regular_price();
	$sale_price = $product->get_sale_price();

	$body[ 'regular_price' ] = $regular_price;
	$body[ 'sale_price' ] = $sale_price;

	return $body;

}, 10, 2 );

How to use code snippets.

Or for example you can only sync product stock quantity without syncing stock status and stock managament parameters:

add_filter( 'rudr_sps_request_body', function( $body, $product ) {

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

	return $body;

}, 10, 2 );
(array) Body of the request.
(WC_Product) Product (or product variation) object.
(string) URL of the specific website we are syncing the product data with.

All the product properties for REST API requests can be found in official docs.


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

add_filter( 'rudr_sps_exclude_ids', function( $product_ids ) {
	return array( 123, 134, 150 );
} );

Need more help?