WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
Make products virtual by default (4 posts)

  1. orionrush
    Member
    Posted 8 months ago #

    Is there a hook or other means where I can set new products to virtual by default?

    https://wordpress.org/plugins/woocommerce/

  2. nicmare
    Member
    Posted 3 months ago #

    very good question! i was also wondering if there is any hook to have new products become virtual by default? now i have to tick the checkbox for every new product and/Or its variantions which is very time-consuming!

  3. nicmare
    Member
    Posted 3 months ago #

    only dirty solution if found:
    open ~/wp-content/plugins/woocommerce/includes/admin/meta-boxes/views/html-variation-admin.php

    and change line 239 from:
    <label><input type="checkbox" class="checkbox variable_is_virtual" name="variable_is_virtual[<?php echo $loop; ?>]" <?php checked( isset( $_virtual ) ? $_virtual : '', 'yes' ); ?> /> <?php _e( 'Virtual', 'woocommerce' ); ?> <a class="tips" data-tip="<?php _e( 'Enable this option if a product is not shipped or there is no shipping cost', 'woocommerce' ); ?>" href="#">[?]</a></label>
    to
    <label><input type="checkbox" class="checkbox variable_is_virtual" name="variable_is_virtual[<?php echo $loop; ?>]" <?php checked( isset( $_virtual ) ? $_virtual : 'yes', 'yes' ); ?> /> <?php _e( 'Virtual', 'woocommerce' ); ?> <a class="tips" data-tip="<?php _e( 'Enable this option if a product is not shipped or there is no shipping cost', 'woocommerce' ); ?>" href="#">[?]</a></label>

    this is the only change:
    <?php checked( isset( $_virtual ) ? $_virtual : 'yes', 'yes' ); ?> />

  4. nicmare
    Member
    Posted 3 months ago #

    my quick fix is for variable products. if you have a simple product, then you can use this filter in your functions.php

    function cs_wc_product_type_options( $product_type_options ) {
        $product_type_options['virtual']['default'] = 'yes';
        $product_type_options['downloadable']['default'] = 'yes';
        return $product_type_options;
    }
    add_filter( 'product_type_options', 'cs_wc_product_type_options' );

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.