remove_control('woocommerce_catalog_columns'); } add_action('customize_register', 'keydesign_remove_customizer', 20, 1); // Add product template style to post class add_filter( 'wc_product_class', 'keydesign_woo_catalog_style' ); function keydesign_woo_catalog_style( $classes ) { if (!is_admin()) { $redux_ThemeTek = get_option( 'redux_ThemeTek' ); global $product; $product_id = wc_get_product(); if( $product_id && !isset($redux_ThemeTek['tek-woo-catalog-style']) ) { $classes[] = 'woo-detailed-style'; } elseif ( $product_id ) { $classes[] = $redux_ThemeTek['tek-woo-catalog-style']; } return $classes; } } // Add wrappers for product listing function keydesign_woo_start_image_wrapper() { echo '
'; }; add_action( 'woocommerce_before_shop_loop_item_title', 'keydesign_woo_start_image_wrapper', 5, 2 ); function keydesign_woo_end_image_wrapper() { echo '
'; }; add_action( 'woocommerce_before_shop_loop_item_title', 'keydesign_woo_end_image_wrapper', 12, 2 ); function keydesign_woo_end_entry_wrapper() { echo '
'; }; add_action( 'woocommerce_after_shop_loop_item', 'keydesign_woo_end_entry_wrapper', 12, 2 ); // Return 3 related products add_filter( 'woocommerce_output_related_products_args', 'keydesign_woo_related_products' ); function keydesign_woo_related_products( $args ) { $args['posts_per_page'] = 3; $args['columns'] = 3; return $args; } // Return number of products in shop page add_filter( 'loop_shop_per_page', 'keydesign_loop_shop_per_page' ); function keydesign_loop_shop_per_page( $product_number ) { $redux_ThemeTek = get_option( 'redux_ThemeTek' ); $product_number = $redux_ThemeTek['tek-woo-products-number']; return $product_number; } function kd_get_gallery_image_html( $attachment_id, $main_image = false ) { $flexslider = (bool) apply_filters( 'woocommerce_single_product_flexslider_enabled', get_theme_support( 'wc-product-gallery-slider' ) ); $gallery_thumbnail = wc_get_image_size( 'gallery_thumbnail' ); $thumbnail_size = apply_filters( 'woocommerce_gallery_thumbnail_size', array( $gallery_thumbnail['width'], $gallery_thumbnail['height'] ) ); $image_size = apply_filters( 'woocommerce_gallery_image_size', $flexslider || $main_image ? 'woocommerce_single' : $thumbnail_size ); $full_size = apply_filters( 'woocommerce_gallery_full_size', apply_filters( 'woocommerce_product_thumbnails_large_size', 'full' ) ); $thumbnail_src = wp_get_attachment_image_src( $attachment_id, $thumbnail_size ); $full_src = wp_get_attachment_image_src( $attachment_id, $full_size ); $image = wp_get_attachment_image( $attachment_id, $image_size, false, array( 'title' => get_post_field( 'post_title', $attachment_id ), 'data-caption' => get_post_field( 'post_excerpt', $attachment_id ), 'data-src' => $full_src[0], 'data-large_image' => $full_src[0], 'data-large_image_width' => $full_src[1], 'data-large_image_height' => $full_src[2], 'class' => $main_image ? 'wp-post-image' : '', ) ); return ''; } // Move position of related and upsells products remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 ); remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15 ); add_action ( 'woocommerce_after_main_content', 'woocommerce_output_related_products', 2); add_action ( 'woocommerce_after_main_content', 'woocommerce_upsell_display', 5); function keydesign_enqueue_woocommerce() { wp_enqueue_style( 'keydesign-woocommerce', get_template_directory_uri() . '/core/assets/css/woocommerce.css', array(), null, 'all' ); wp_register_script( 'keydesign-ajaxcart', get_template_directory_uri() . '/core/assets/js/woocommerce-keydesign.js', array() , null ); wp_localize_script( 'keydesign-ajaxcart', 'keydesign_menucart_ajax',array('nonce' => wp_create_nonce('keydesign-ajaxcart')) ); wp_enqueue_script( 'keydesign-ajaxcart' ); } add_action('wp_enqueue_scripts', 'keydesign_enqueue_woocommerce', 98 ); function keydesign_get_cart_items() { global $woocommerce; $articles = sizeof( $woocommerce->cart->get_cart() ); $cart = $items_total = ''; if ( $articles > 0 ) { $items_total = $woocommerce->cart->cart_contents_count; foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $cart_item ) { $_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key ); $product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key ); if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_widget_cart_item_visible', true, $cart_item, $cart_item_key ) ) { $product_name = apply_filters( 'woocommerce_cart_item_name', $_product->get_title(), $cart_item, $cart_item_key ); $thumbnail = apply_filters( 'woocommerce_cart_item_thumbnail', $_product->get_image(), $cart_item, $cart_item_key ); $product_price = apply_filters( 'woocommerce_cart_item_price', $woocommerce->cart->get_product_price( $_product ), $cart_item, $cart_item_key ); $cart .= '
  • '; if ( ! $_product->is_visible() ) { $cart .= str_replace( array( 'http:', 'https:' ), '', $thumbnail ); } else { $cart .= ' '.str_replace( array( 'http:', 'https:' ), '', $thumbnail ) . ' '; } $cart .= '
    ' . $product_name . ''; $cart .= ''. apply_filters( 'woocommerce_widget_cart_item_quantity', '' . sprintf( '%s × %s',$cart_item['quantity'] , '' . $product_price ) , $cart_item, $cart_item_key ) . ''; $cart .= '
    '; $cart .= '
  • '; } } $cart .= '
  • ' . esc_html__('Subtotal:', 'ekko') . ' ' . $woocommerce->cart->get_cart_total() . '
  • '; $cart .= '
  • '.esc_html__( 'View Cart', 'ekko' ).' '.esc_html__( 'Checkout', 'ekko' ).'
  • '; } return array('cart' => $cart, 'articles' => $items_total); } function keydesign_woomenucart_ajax() { if ( !wp_verify_nonce( $_REQUEST['nonce'], "keydesign-ajaxcart")) { exit(); } $cart = keydesign_get_cart_items(); echo json_encode($cart); die(); } add_action( 'wp_ajax_woomenucart_ajax', 'keydesign_woomenucart_ajax'); add_action( 'wp_ajax_nopriv_woomenucart_ajax', 'keydesign_woomenucart_ajax' ); function keydesign_add_cart_in_menu() { global $woocommerce; $redux_ThemeTek = get_option( 'redux_ThemeTek' ); $items_total = $woocommerce->cart->cart_contents_count; $get_cart_items = keydesign_get_cart_items(); $cart_container =''; if ((isset($get_cart_items['cart'])) && ($get_cart_items['cart'] !=='')) { $cart_container = ''; } $kd_cart_items = ''; return $kd_cart_items; } ?>