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', 'avenews_woocommerce_setup');
/**
* Woocommerce Sidebar
*/
function avenews_woocoommerce_widgets_init()
{
register_sidebar(array(
'name' => esc_html__('Shop Sidebar', 'avenews'),
'id' => 'shop-sidebar',
'description' => esc_html__('Sidebar displaying only in woocommerce pages.', 'avenews'),
'before_widget' => '',
'before_title' => '
',
));
}
add_action('widgets_init', 'avenews_woocoommerce_widgets_init');
/**
* WooCommerce specific scripts & stylesheets.
*
* @return void
*/
function avenews_woocommerce_scripts()
{
wp_enqueue_style('avenews-woocommerce-style', get_template_directory_uri() . '/assets/css/woocommerce.css', array(), AVENEWS_S_VERSION);
}
add_action('wp_enqueue_scripts', 'avenews_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 avenews_woocommerce_active_body_class($classes)
{
$classes[] = 'woocommerce-active';
return $classes;
}
add_filter('body_class', 'avenews_woocommerce_active_body_class');
/**
* Related Products Args.
*
* @param array $args related products args.
* @return array $args related products args.
*/
function avenews_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', 'avenews_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('avenews_woocommerce_wrapper_before')) {
/**
* Before Content.
*
* Wraps all WooCommerce content in wrappers which match the theme markup.
*
* @return void
*/
function avenews_woocommerce_wrapper_before()
{
?>
';
dynamic_sidebar('shop-sidebar');
echo '';
}
}
add_action('avenews_woocommerce_sidebar', 'avenews_woocommerce_sidebar_cb');
/**
* Removes the "shop" title on the main shop page
*/
add_filter('woocommerce_show_page_title', '__return_false');
if (!function_exists('avenews_woocommerce_cart_count')) :
/**
* Woocommerce Cart Count
*
* @link https://isabelcastillo.com/woocommerce-cart-icon-count-theme-header
*/
function avenews_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();
?>