• the1first

    (@the1first)


    How do I set the default product to be virtual and downloadable?

Viewing 1 replies (of 1 total)
  • cybertron1

    (@cybertron1)

    Hi

    This is the code I use, it hides the other checkboxes and checks virtual/downloadable. Put it in your themes Function.php

    
    add_filter( 'wcfm_product_fields_downloadable', function( $downloadable_fields, $product_id, $product_type ) {
    	//$downloadable_fields = wcfm_hide_field( 'download_limit', $downloadable_fields );
    	$downloadable_fields = wcfm_hide_field( 'download_expiry', $downloadable_fields );
    	return $downloadable_fields;
    }, 50, 3 );
    
    function wcfm_custom_product_manage_fields_general( $general_fileds, $product_id, $product_type ) {
    	global $WCFM;
    	if( isset( $general_fileds['is_virtual'] ) ) {
    		$general_fileds['is_virtual']['class'] = 'wcfm_custom_hide';
    		$general_fileds['is_virtual']['desc_class'] = 'wcfm_custom_hide';
    	}
    	//if( isset( $general_fileds['is_downloadable'] ) ) {
    	//	$general_fileds['is_downloadable']['class'] = 'wcfm_custom_hide';
    	//	$general_fileds['is_downloadable']['desc_class'] = 'wcfm_custom_hide';
    //	}
    	
    	return $general_fileds;
    }
    add_filter( 'wcfm_product_manage_fields_general', 'wcfm_custom_product_manage_fields_general', 150, 3 );
    
    add_filter( 'wcfm_product_manage_fields_general', function( $general_fields, $product_id, $product_type ) {
    	//if( isset( $general_fields['is_virtual'] ) ) {
    	//	$general_fields['is_virtual']['dfvalue'] = 'enable';
    	//}
    	if( isset( $general_fields['is_downloadable'] ) ) {
    		$general_fields['is_downloadable']['dfvalue'] = 'enable';
    	}
    	return $general_fields;
    }, 50, 3 );
Viewing 1 replies (of 1 total)

The topic ‘Set a virtual product default’ is closed to new replies.