150,
'single_image_width' => 300,
'product_grid' => array(
'default_rows' => 3,
'min_rows' => 1,
'default_columns' => 4,
'min_columns' => 1,
'max_columns' => 6,
),
)
);
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', 'appzend_woocommerce_setup' );
/**
* WooCommerce specific scripts & stylesheets.
*
* @return void
*/
function appzend_woocommerce_scripts() {
wp_enqueue_style( 'appzend-woocommerce-style', get_template_directory_uri() . '/woocommerce.css', array(), _S_VERSION );
$font_path = WC()->plugin_url() . '/assets/fonts/';
$inline_font = '@font-face {
font-family: "star";
src: url("' . $font_path . 'star.eot");
src: url("' . $font_path . 'star.eot?#iefix") format("embedded-opentype"),
url("' . $font_path . 'star.woff") format("woff"),
url("' . $font_path . 'star.ttf") format("truetype"),
url("' . $font_path . 'star.svg#star") format("svg");
font-weight: normal;
font-style: normal;
}';
wp_add_inline_style( 'appzend-woocommerce-style', $inline_font );
}
add_action( 'wp_enqueue_scripts', 'appzend_woocommerce_scripts' );
/**
* Disable the default WooCommerce stylesheet.
*
* Removing the default WooCommerce stylesheet and enqueing your own will
* protect you during WooCommerce core updates.
*
* @link https://docs.woocommerce.com/document/disable-the-default-stylesheet/
*/
// add_filter( 'woocommerce_enqueue_styles', '__return_empty_array' );
remove_action( 'woocommerce_before_main_content','woocommerce_breadcrumb', 20 );
add_filter( 'woocommerce_show_page_title', '__return_false' );
/**
* 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 appzend_woocommerce_active_body_class( $classes ) {
$classes[] = 'woocommerce-active';
return $classes;
}
add_filter( 'body_class', 'appzend_woocommerce_active_body_class' );
/**
* Related Products Args.
*
* @param array $args related products args.
* @return array $args related products args.
*/
function appzend_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', 'appzend_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( 'appzend_woocommerce_wrapper_before' ) ) {
/**
* Before Content.
*
* Wraps all WooCommerce content in wrappers which match the theme markup.
*
* @return void
*/
function appzend_woocommerce_wrapper_before() {
?>
*/
if ( ! function_exists( 'appzend_woocommerce_cart_link_fragment' ) ) {
/**
* Cart Fragments.
*
* Ensure cart contents update when products are added to the cart via AJAX.
*
* @param array $fragments Fragments to refresh via AJAX.
* @return array Fragments to refresh via AJAX.
*/
function appzend_woocommerce_cart_link_fragment( $fragments ) {
ob_start();
appzend_woocommerce_cart_link();
$fragments['a.cart-contents'] = ob_get_clean();
return $fragments;
}
}
add_filter( 'woocommerce_add_to_cart_fragments', 'appzend_woocommerce_cart_link_fragment' );
if ( ! function_exists( 'appzend_woocommerce_cart_link' ) ) {
/**
* Cart Link.
*
* Displayed a link to the cart including the number of items present and the cart total.
*
* @return void
*/
function appzend_woocommerce_cart_link() {
?>
cart->get_cart_contents_count(), 'appzend' ),
WC()->cart->get_cart_contents_count()
);
?>
cart->get_cart_subtotal() ); ?>
'product',
'tax_query' => array(
array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => $cat_slug
)),
'posts_per_page' => $product_number
);
$query = new WP_Query($product_args);
if ($query->have_posts()) {
while ($query->have_posts()) { $query->the_post();
wc_get_template_part('content', 'product');
}
}
wp_reset_postdata();
?>
is_on_sale() == 1 ){
$sale_class = 'new_sale';
}
?>
get_date_created() );
if ( ( time() - ( 60 * 60 * 24 * $newness_days ) ) < $created ) {
appzend_flash_sale_new_tag();
}
endif;
if ( $product->is_on_sale() && get_theme_mod('appzend_catelog_enable_sales_tag', true) ) :
echo apply_filters( 'woocommerce_sale_flash', appzend_flash_sale_tag(), $post, $product );
endif;
?>
is_on_sale() ) {
if ( ! $product->is_type( 'variable' ) and $product->get_regular_price() and $product->get_sale_price() ) {
$max_percentage = ( ( $product->get_regular_price() - $product->get_sale_price() ) / $product->get_regular_price() ) * 100;
} else {
$max_percentage = 0;
foreach ( $product->get_children() as $child_id ) {
$variation = wc_get_product( $child_id );
if( !$variation ) continue;
$price = $variation->get_regular_price();
$sale = $variation->get_sale_price();
$percentage = '';
if ( $price != 0 && ! empty( $sale ) ) $percentage = ( $price - $sale ) / $price * 100;
if ( $percentage > $max_percentage ) {
$max_percentage = $percentage;
}
}
}
$color = get_theme_mod('appzend_catelog_discount_tag_text_color', '#ffffff');
$bg_color = get_theme_mod('appzend_catelog_discount_tag_bg_color', '#ffc60a');
$style = "style='color: $color; background-color: $bg_color;'";
echo "
" . esc_html( round( - $max_percentage ) ) . esc_html__("%", 'appzend')."";
}
}
}
/**
* Add the link to quickview function area
*/
if (defined('YITH_WCQV')) {
function appzend_quickview() {
global $product;
$quick_view = YITH_WCQV_Frontend();
remove_action('woocommerce_after_shop_loop_item', array($quick_view, 'yith_add_quick_view_button'), 15);
$label = esc_html(get_option('yith-wcqv-button-label'));
echo '
'.esc_html__('Quick view', 'appzend').'
';
}
}
/**
* Add the link to compare function area
*/
if (defined('YITH_WOOCOMPARE')) {
function appzend_add_compare_link($product_id = false, $args = array()) {
extract($args);
if (!$product_id) {
global $product;
$productid = $product->get_id();
$product_id = isset( $productid ) ? $productid : 0;
}
$is_button = !isset($button_or_link) || !$button_or_link ? get_option('yith_woocompare_is_button') : $button_or_link;
if (!isset($button_text) || $button_text == 'default') {
$button_text = get_option('yith_woocompare_button_text', esc_html__('Compare', 'appzend'));
yit_wpml_register_string('Plugins', 'plugin_yit_compare_button_text', $button_text);
$button_text = yit_wpml_string_translate('Plugins', 'plugin_yit_compare_button_text', $button_text);
}
printf('
%s', '#', 'compare link-compare', intval( $product_id ), '
'.esc_html( $button_text ).'' );
}
remove_action('woocommerce_after_shop_loop_item', array('YITH_Woocompare_Frontend', 'add_compare_link'), 20);
}
if(!function_exists('appzend_flash_sale_tag')){
function appzend_flash_sale_tag(){
$new_tag_text = get_theme_mod('appzend_catelog_enable_sales_tag_text', esc_html__( 'Sale!', 'appzend' ));
$color = get_theme_mod('appzend_catelog_enable_sales_tag_text_color', '#ffffff');
$bg_color = get_theme_mod('appzend_catelog_enable_sales_tag_text_bg_color', '#f33c3c');
$style = "style='color: $color; background-color: $bg_color;'";
return '
' . $new_tag_text . '';
}
}
if(!function_exists('appzend_flash_sale_new_tag')){
function appzend_flash_sale_new_tag(){
$new_tag_text = get_theme_mod('appzend_catelog_enable_new_tag_text', esc_html__( 'New!', 'appzend' ));
$color = get_theme_mod('appzend_catelog_enable_new_tag_text_color', '#ffffff');
$bg_color = get_theme_mod('appzend_catelog_enable_new_tag_text_bg_color', '#009966');
$style = "style='color: $color; background-color: $bg_color;'";
echo '
' . $new_tag_text . '';
}
}
/**
* Product wishlist button function area
*/
if ( function_exists( 'YITH_WCWL' ) ) {
function appzend_wishlist_products() {
echo do_shortcode( '[yith_wcwl_add_to_wishlist]' );
}
}
/**
* define the yith-wcwl-browse-wishlist-label callback
*/
function filter_yith_wcwl_browse_wishlist_label( $var ) {
return '
'.$var.'';
};
add_filter( 'yith-wcwl-browse-wishlist-label', 'filter_yith_wcwl_browse_wishlist_label', 10, 1 );