swift_peformance_get_product_variation_parent

If cache for product variation has been cleared, Swift Performance will clear the cache for the parent product as well. This filter can be used to change the parent product ID

Parameters

$product_id

integer, id of the parent product

$variation_id

integer, id of the product variation

Return

integer


Example

// clear cache only if parent product is in stock
add_filter('swift_peformance_get_product_variation_parent', function($product_id, $variation_id){
$product = wc_get_product($product_id);
if (!$product->is_in_stock()){
return -1;
}
return $product_id;
}, 10, 2);