WooCommerce snippets

Note: All code examples on this site are provided for developer reference/guidance only and we cannot guarantee that they will always work as expected. Our support policy does not include assistance with modifying or debugging code from any code examples, and they may be changed or removed if we find they no longer work due to changes in our plugins.

Please use the Code Snippets plugin, rather than adding the code samples below directly to your theme’s functions.php file. That will help ensure that any code errors won’t crash your site, and the changes will not be overwritten when you update your theme.


Show hidden WooCommerce products when selecting a job package

add_filter( 'wcpl_get_job_packages_args', 'bk_show_hidden_job_packages');

function bk_show_hidden_job_packages( $args ) {
    unset( $args['tax_query'][1] );
    return $args;
}

Change default new role in WooCommerce

function my_new_customer_data( $new_customer_data ){
    $new_customer_data['role'] = 'candidate';
    return $new_customer_data;
}
add_filter( 'woocommerce_new_customer_data', 'my_new_customer_data');
WooCommerce Paid Listings Documentation