Thursday, October 22, 2020

Woocommerce: Single Product Page Customisation

/**

 * SINGLE PRODUCT PAGE CUSTOMISATION

 */



// Remove Categories @ Single Products 

remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );



// Hide "in stock" @ Single Products 

function my_wc_hide_in_stock_message( $html, $text, $product ) {

$availability = $product->get_availability();


if ( isset( $availability['class'] ) && 'in-stock' === $availability['class'] ) {

return '';

}


return $html;

}


add_filter( 'woocommerce_stock_html', 'my_wc_hide_in_stock_message', 10, 3 );



// Hide "Additional Information tab" @ Single Products 


add_filter( 'woocommerce_product_tabs', 'bbloomer_remove_product_tabs', 9999 );

  

function bbloomer_remove_product_tabs( $tabs ) {

    unset( $tabs['additional_information'] ); 

    return $tabs;

}


// Hide  "xx product has been added to your cart" @ Single Product Page

add_filter( 'wc_add_to_cart_message_html', '__return_false' );


// Change location of price to above "Add to Cart" button

remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );

add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 20 );

No comments: