570, 'single_image_width' => 665, 'product_grid' => array( 'default_rows' => 3, 'min_rows' => 1, 'default_columns' => 4, 'min_columns' => 1, 'max_columns' => 6, ), ) ); if( version_compare( $woocommerce->version, '3.0', ">=" ) ) { add_theme_support( 'wc-product-gallery-zoom' ); add_theme_support( 'wc-product-gallery-lightbox' ); add_theme_support( 'wc-product-gallery-slider' ); } } add_action( 'after_setup_theme', 'blogauthor_woocommerce_setup' ); /** * Woocommerce Sidebar */ function blogauthor_woocoommerce_widgets_init(){ register_sidebar( array( 'name' => esc_html__( 'Shop Sidebar', 'blogauthor' ), 'id' => 'shop-sidebar', 'description' => esc_html__( 'Sidebar displaying only in woocommerce pages.', 'blogauthor' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); } add_action( 'widgets_init', 'blogauthor_woocoommerce_widgets_init' ); /** * WooCommerce specific scripts & stylesheets. * * @return void */ function blogauthor_woocommerce_scripts() { wp_enqueue_style( 'blogauthor-woocommerce-style', get_template_directory_uri() . '/assets/css/woocommerce.css', array(), _S_VERSION ); } add_action( 'wp_enqueue_scripts', 'blogauthor_woocommerce_scripts' ); /** * Add 'woocommerce-active' class to the body tag. * * @param array $classes CSS classes applied to the body tag. * @return array $classes modified to include 'woocommerce-active' class. */ function blogauthor_woocommerce_active_body_class( $classes ) { $classes[] = 'woocommerce-active'; return $classes; } add_filter( 'body_class', 'blogauthor_woocommerce_active_body_class' ); /** * Related Products Args. * * @param array $args related products args. * @return array $args related products args. */ function blogauthor_woocommerce_related_products_args( $args ) { $defaults = array( 'posts_per_page' => 3, 'columns' => 3, ); $args = wp_parse_args( $defaults, $args ); return $args; } add_filter( 'woocommerce_output_related_products_args', 'blogauthor_woocommerce_related_products_args' ); /** * Remove default WooCommerce wrapper. */ remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 ); remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 ); if (!function_exists('blogauthor_woocommerce_wrapper_before')) { /** * Before Content. * * Wraps all WooCommerce content in wrappers which match the theme markup. * * @return void */ function blogauthor_woocommerce_wrapper_before() { ?>
'; dynamic_sidebar( 'shop-sidebar' ); echo ''; } } add_action( 'blogauthor_woocommerce_sidebar', 'blogauthor_woocommerce_sidebar_cb' ); /** * Removes the "shop" title on the main shop page */ add_filter( 'woocommerce_show_page_title' , '__return_false' ); if( ! function_exists( 'blogauthor_woocommerce_cart_count' ) ) : /** * Woocommerce Cart Count * * @link https://isabelcastillo.com/woocommerce-cart-icon-count-theme-header */ function blogauthor_woocommerce_cart_count(){ $cart_page = get_option( 'woocommerce_cart_page_id' ); $count = WC()->cart->cart_contents_count; if( $cart_page ){ ?> cart->cart_contents_count; ?> cart->add_to_cart( $product_id, 1 ); $count = WC()->cart->cart_contents_count; $cart_url = $woocommerce->cart->get_cart_url(); ?>