// =========================================================================
// REMOVE SIDEBAR FROM SINGLE PRODUCT PAGE IN STOREFRONT
// =========================================================================
add_action( 'get_header', 'wpninja_remove_storefront_sidebar' );
function wpninja_remove_storefront_sidebar() {
if ( is_product() ) {
remove_action( 'storefront_sidebar', 'storefront_get_sidebar', 10 );
add_filter( 'body_class', function( $classes ) {
return array_merge( $classes, array( 'page-template-template-fullwidth page-template-template-fullwidth-php ' ) );
} );
}
}
Storefront
Conditionally add Full-Width Layout for Storefront with ACF and custom body_class
Create a True / False custom field with ACF Pro
Add this to functions.php
// =========================================================================
// FULL WIDTH CHECKBOX
// =========================================================================
function add_full_width_layout(){
if( get_field('full_width') ){
remove_action( 'storefront_sidebar', 'storefront_get_sidebar', 10 );
add_filter( 'body_class', function( $classes ) {
return array_merge( $classes, array( 'page-template-template-fullwidth page-template-template-fullwidth-php ' ) );
} );
}
}
add_action( 'wp', 'add_full_width_layout' );
Remove Storefront built-in homepage sections
function remove_storefront_home_sections( $args ) {
remove_action( 'homepage', 'storefront_product_categories', 20 );
remove_action( 'homepage', 'storefront_recent_products', 30 );
remove_action( 'homepage', 'storefront_featured_products', 40 );
remove_action( 'homepage', 'storefront_popular_products', 50 );
remove_action( 'homepage', 'storefront_on_sale_products', 60 );
remove_action( 'homepage', 'storefront_best_selling_products', 70 );
}
add_action( 'wp', 'remove_storefront_home_sections' );
Hide specific Flat Rates when Free Shipping is available
//Hide specific Flat Rates when Free Shipping is available
add_filter( 'woocommerce_package_rates', 'conditionally_hide_shipping_methods', 100, 2 );
function conditionally_hide_shipping_methods( $rates, $package ) {
// HERE yours 2nd flat rate "Express Shipping" (that you never hide) in the array:
$flat_rates_pickpack = array(
'wc_pont_shipping_method:3',
'local_pickup:9'
);
$free = $flat2 = array();
foreach ( $rates as $rate_key => $rate ) {
// Updated Here To
if ( in_array( $rate->id, $flat_rates_pickpack ) )
$flat2[ $rate_key ] = $rate;
if ( 'free_shipping' === $rate->method_id )
$free[ $rate_key ] = $rate;
}
return ! empty( $free ) ? array_merge( $free, $flat2 ) : $rates;
}
How to fix collapsed checkout fields in Storefront (Bootstrap)
#customer_details .col-1,
#customer_details .col-2 {
width: 100%;
max-width: 100%;
}
.woocommerce-input-wrapper {
display: block !important;
width: 100%;
}
Move Header Cart and Product Search before header in Storefront
// =========================================================================
//CHANGE DEFAULT STOREFRONT HEADER LAYOUT
// =========================================================================
function remove_storefront_actions() {
remove_action( 'storefront_header', 'storefront_product_search', 40 );
remove_action( 'storefront_header', 'storefront_primary_navigation', 50 );
remove_action( 'storefront_header', 'storefront_header_cart', 60 );
}
add_action( 'init', 'remove_storefront_actions' );
function add_top_bar_opening_wrap(){
echo '<div class="top-bar">';
}
function add_top_bar_closing_wrap(){
echo '</div>';
}
add_action( 'storefront_before_header', 'add_top_bar_opening_wrap', 1 );
add_action( 'storefront_before_header', 'storefront_header_cart', 2 );
add_action( 'storefront_before_header', 'storefront_product_search', 40 );
add_action( 'storefront_before_header', 'add_top_bar_closing_wrap', 50 );
How to Remove Homepage Title in Storefront
Storefront Homepage Page Template
//Hide Homepage Title - Storefront Homepage Page Template
add_action( 'wp', 'wpninja_storefront_remove_title_from_home_homepage_template' );
function wpninja_storefront_remove_title_from_home_homepage_template() {
remove_action( 'storefront_homepage', 'storefront_homepage_header', 10 );
}
Storefront Default Page Template
//Hide Homepage Title - Storefront Default Page Template
add_action( 'wp', 'wpninja_storefront_remove_title_from_home_default_template' );
function wpninja_storefront_remove_title_from_home_default_template() {
if ( is_front_page() ) remove_action( 'storefront_page', 'storefront_page_header', 10 );
}
Hook revslider in Storefront
//HOOK REVSLIDER
add_filter( 'storefront_before_content', 'add_revslider' );
function add_revslider( $rev_slider ) {
if ( is_front_page() ) {
echo do_shortcode('[rev_slider alias="revslider"]');
}
return $rev_slider;
}