Skip to content

Instantly share code, notes, and snippets.

@akther80
Created June 29, 2020 15:44
Show Gist options
  • Save akther80/ad0f520f4ce8bb54d4819cf5720b3318 to your computer and use it in GitHub Desktop.
Save akther80/ad0f520f4ce8bb54d4819cf5720b3318 to your computer and use it in GitHub Desktop.
Cartzilla- Shop sidebar for single product
add_action( 'init', 'cz_child_enable_single_product_sidebar', 10 );
function cz_child_enable_single_product_sidebar() {
remove_action( 'template_redirect', 'cartzilla_wc_product_remove_sidebar' );
add_action( 'woocommerce_before_single_product', 'cartzilla_wc_before_content', 7 );
add_action( 'woocommerce_before_single_product', 'cartzilla_wc_before_single_product', 10 );
add_action( 'woocommerce_after_single_product', 'cartzilla_wc_after_single_product', 350 );
add_action( 'woocommerce_sidebar', 'cartzilla_wc_after_content', 20 );
add_action( 'cartzilla_handheld_toolbar', 'cartzilla_wc_single_product_handheld_toolbar_toggle_shop_sidebar', 30 );
}
if ( ! function_exists( 'cartzilla_wc_before_content' ) ) {
function cartzilla_wc_before_content() {
if ( is_product() && cartzilla_get_single_product_style() !== 'style-v4' ) : ?>
<div class="single-product-sidebar">
<div class="container">
<div class="row">
<?php endif;
}
}
if ( ! function_exists( 'cartzilla_wc_after_content' ) ) {
function cartzilla_wc_after_content() {
if ( is_product() && cartzilla_get_single_product_style() !== 'style-v4') : ?>
</div>
</div>
</div>
<?php endif;
}
}
if ( ! function_exists( 'cartzilla_wc_before_single_product' ) ) {
function cartzilla_wc_before_single_product() { ?>
<div class="primary"><?php
}
}
if ( ! function_exists( 'cartzilla_wc_after_single_product' ) ) {
function cartzilla_wc_after_single_product() { ?>
</div><?php
}
}
if ( ! function_exists( 'cartzilla_wc_single_product_handheld_toolbar_toggle_shop_sidebar' ) ) {
function cartzilla_wc_single_product_handheld_toolbar_toggle_shop_sidebar() {
if ( is_product() && ( get_theme_mod( 'shop_sidebar', 'no-sidebar' ) != 'no-sidebar' )) : ?>
<a href="#shop-sidebar" data-toggle="sidebar" class="d-table-cell cz-handheld-toolbar-item">
<span class="cz-handheld-toolbar-icon">
<i class="czi-filter-alt"></i>
</span>
<span class="cz-handheld-toolbar-label"><?php echo esc_html_x( 'Filters', 'front-end', 'cartzilla' ); ?></span>
</a>
<?php
endif;
}
}
.single-product-sidebar .primary {
flex: 0 0 100%;
max-width: 100%;
padding: 0 15px;
}
@media (min-width: 1024px) {
.single-product-sidebar .primary {
flex: 0 0 66.66%;
max-width: 66.66%;
order: 2;
}
.single-product-sidebar .cz-sidebar {
max-width: 100%;
}
}
@media (min-width: 992px){
.related-product-carousel .slick-arrow.slick-next {
right: 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment