Support » Plugin: WooCommerce » Custom Product Type won’t save in Woocommerce 3

  • Resolved Chupsi

    (@chupsi)


    Hi,

    I have a problem with my shop since woocommerce 3. I have a custom product type and I can’t save products with this type in the admin product edit. It’ll always jump back to Simple Product after saving and even old products with the custom product type change their type to Simple when I update anything. 🙁

    I already tried some things but nothing worked. This is my current code for creating the custom product type:

    function create_custom_product_type() {
    	
    	class WC_Product_Books extends WC_Product {
    	 	
    		public $product_type = 'books_product';
    		
    	   public function __construct( $product ) { 
    	
    	        parent::__construct( $product );
    	   }
    
    	   public function get_type( ) {
    
    		return $product_type;
    	   }
    	 }
    }
    add_action( 'init', 'create_custom_product_type' );
    
    function add_custom_product_type( $types ) {
        $types[ 'books_product' ] = __( 'Book' );
        return $types;
    }
    add_filter( 'product_type_selector', 'add_custom_product_type' );

    Did I miss anything?

    Thanks,
    Chupsi

    • This topic was modified 2 years, 6 months ago by Chupsi.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom Product Type won’t save in Woocommerce 3’ is closed to new replies.