Frank Miles

WordPress & Web Developer

  • Home
  • Services
  • Projects

Woocommerce snippets

Remove default CSS

Remove default CSS
1
2
// Disable Woocommerce CSS
add_filter( 'woocommerce_enqueue_styles', '__return_empty_array' );

Remove tabs

Remove tabs
PHP
1
2
3
4
5
6
7
8
9
10
11
12
// Remove tabs
add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );
 
function woo_remove_product_tabs( $tabs ) {
 
    //unset( $tabs['description'] );        // Remove the description tab
    unset( $tabs['reviews'] );      // Remove the reviews tab
    unset( $tabs['additional_information'] );   // Remove the additional information tab
 
    return $tabs;
 
}

Remove related products

Remove related products
PHP
1
2
3
4
5
// Remove related products
function woocommerce_remove_related_products(){
    remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20);
}
add_action('woocommerce_after_single_product_summary', 'woocommerce_remove_related_products');

Remove upsells

1
2
3
4
5
// Remove upsells
function woocommerce_remove_upsells(){
    remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15);
}
add_action('woocommerce_after_single_product_summary', 'woocommerce_remove_upsells');

Move price on single product page

Move price on single product page
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/**********************************
*
* Move WooCommerce Price on Single Product Page
*
* @author AlphaBlossom / Tony Eppright
* @link http://www.alphablossom.com
*
* Reference hook locations using woocommerce_single_product_summary hook
*
* @hooked woocommerce_template_single_title – 5
* @hooked woocommerce_template_single_price – 10
* @hooked woocommerce_template_single_excerpt – 20
* @hooked woocommerce_template_single_add_to_cart – 30
* @hooked woocommerce_template_single_meta – 40
* @hooked woocommerce_template_single_sharing – 50
*
************************************/
 
// Move WooCommerce price
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 25 );

Example function to add content via hooks and priority

Example: add content via hooks
1
2
3
4
5
6
7
8
9
function content_after_add_to_cart() {
if(is_single() )
    echo '<div class="before-posts">Add Text or HTML Here</div>';
};
/**
* @author Brad Dalton
* @link http://wp.me/p1lTu0-9Mr
*/
add_action('woocommerce_single_product_summary', 'content_after_add_to_cart', 35 );

Move title to before thumbnail

PHP
1
2
3
/*---Move Product Title*/
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
add_action( 'woocommerce_before_single_product_summary', 'woocommerce_template_single_title', 5 );

Move price

Move title
PHP
1
2
3
// Move WooCommerce price
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 25 );

Remove SKUs on product pages

Remove SKUs on product pages
PHP
1
2
3
4
5
6
7
8
9
// Remove SKUs on product pages
function sv_remove_product_page_skus( $enabled ) {
    if ( ! is_admin() && is_product() ) {
        return false;
    }
 
    return $enabled;
}
add_filter( 'wc_product_sku_enabled', 'sv_remove_product_page_skus' );

Remove product metadata from footer

Remove product metadata from footer
PHP
1
2
// Remove product metadata from footer
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );

Contact me

Thanks for taking the time to check out my work, and for contacting me. Please fill out the form information and tell me a little about your project, and I'll reply to you within 24 hours.

I look forward to speaking with you.

© 2015. All Rights Reserved