Merge pull request #14043 from woocommerce/fix/missing-product-type-field

if product type field is not posted, we should maintain existing type, not change to simple
This commit is contained in:
Claudio Sanches 2017-04-06 11:58:55 -03:00 committed by GitHub
commit 3fff61ea4e
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(