Pass ID, not the product object

This commit is contained in:
Mike Jolley 2017-04-05 20:21:33 +01:00
parent f250cac8d1
commit a6080aa4a9
1 changed files with 2 additions and 2 deletions

View File

@ -126,10 +126,10 @@ class WC_Post_Data {
* @param string $to
*/
public static function product_type_changed( $product, $from, $to ) {
if ( 'variable' === $from ) {
if ( 'variable' === $from && 'variable' !== $to ) {
// If the product is no longer variable, we should ensure all variations are removed.
$data_store = WC_Data_Store::load( 'product-variable' );
$data_store->delete_variations( $product );
$data_store->delete_variations( $product->get_id() );
}
}