cart->get_cart_contents_count(), 'xshop' ), WC()->cart->get_cart_contents_count() ); ?>
esc_html__( 'Shop Sidebar', 'xshop' ), 'id' => 'shop-sidebar', 'description' => esc_html__( 'Add shop widgets here.', 'xshop' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); } add_action( 'widgets_init', 'xshop_shop_widgets_init' ); function xshop_before_single_product_div(){ echo '
'; } add_action('woocommerce_before_single_product_summary','xshop_before_single_product_div',5); function xshop_after_single_product_div(){ echo '
'; } add_action('woocommerce_after_single_product_summary','xshop_after_single_product_div',5); function xshop_woo_body_classes( $classes ) { if ( ! is_active_sidebar( 'shop-sidebar' ) && is_shop() ) { $classes[] = 'no-shop-widget'; } if ( is_front_page() && is_shop() ) { $classes[] = 'xfront-shop'; } return $classes; } add_filter( 'body_class', 'xshop_woo_body_classes' ); /** * Change number or products per row */ add_filter('loop_shop_columns', 'xshop_loop_columns', 999); if (!function_exists('xshop_loop_columns')) { function xshop_loop_columns() { if( is_active_sidebar( 'shop-sidebar' ) ){ return 3; // 3 products per row }else{ return 4; // 3 products per row } } } add_filter( 'woocommerce_output_related_products_args', 'xshop_related_products_args', 20 ); function xshop_related_products_args( $args ) { if( is_active_sidebar( 'shop-sidebar' ) ){ $args['posts_per_page'] = 3; // 4 related products $args['columns'] = 3; // arranged in 2 columns }else{ $args['posts_per_page'] = 4; // 4 related products } return $args; }