Permalink
Browse files

Tweak save logic to set _price for variables/groups via sync function…

…s only

Closes #9892
  • Loading branch information...
mikejolley committed Dec 23, 2015
1 parent 9db40dc commit 0b678ab2af7b9ef42679786ad2491811e9f95eb5
@@ -984,7 +984,6 @@ function attributes_cmp( $a, $b ) {
update_post_meta( $post_id, '_sale_price', '' );
update_post_meta( $post_id, '_sale_price_dates_from', '' );
update_post_meta( $post_id, '_sale_price_dates_to', '' );
update_post_meta( $post_id, '_price', '' );
} else {
$date_from = isset( $_POST['_sale_price_dates_from'] ) ? wc_clean( $_POST['_sale_price_dates_from'] ) : '';
@@ -720,8 +720,11 @@ public static function sync( $product_id ) {
) );
// No published variations - product won't be purchasable.
if ( ! $children && 'publish' === get_post_status( $product_id ) ) {
if ( is_admin() ) {
if ( ! $children ) {
update_post_meta( $product_id, '_price', '' );
delete_transient( 'wc_products_onsale' );
if ( is_admin() && 'publish' === get_post_status( $product_id ) ) {
WC_Admin_Meta_Boxes::add_error( __( 'This variable product has no active variations. Add or enable variations to allow this product to be purchased.', 'woocommerce' ) );
}

0 comments on commit 0b678ab

Please sign in to comment.