if product type field is not posted, we should maintain existing type, not change to simple

This commit is contained in:
Mike Jolley 2017-04-06 15:56:55 +01:00
parent ddf188a61e
commit 82cdf65c04
1 changed files with 2 additions and 2 deletions

View File

@ -290,8 +290,8 @@ class WC_Meta_Box_Product_Data {
*/
public static function save( $post_id, $post ) {
// Process product type first so we have the correct class to run setters.
$product_type = empty( $_POST['product-type'] ) ? 'simple' : sanitize_title( stripslashes( $_POST['product-type'] ) );
$classname = WC_Product_Factory::get_product_classname( $post_id, $product_type );
$product_type = empty( $_POST['product-type'] ) ? WC_Product_Factory::get_product_type( $post_id ) : sanitize_title( stripslashes( $_POST['product-type'] ) );
$classname = WC_Product_Factory::get_product_classname( $post_id, $product_type ? $product_type : 'simple' );
$product = new $classname( $post_id );
$attributes = self::prepare_attributes();
$errors = $product->set_props( array(