woo_subcategories_thumb( $category ); } /** * Add categories on sidebar */ function alanah_get_wc_categories_menu( $title = 'Categories' ){ global $al_core; $al_core->alanah_wc_categories_menu( $title ); } /** * Product Labels (Sale/New) on upsells and cross sells products */ function alanah_wc_product_labels() { global $al_core; $al_core->alanah_wc_product_label(); } /** * Create product slider getting query */ function alanah_wc_carousel( $args, $slider_cols, $direction, $scroll, $autoplay, $title, $timer, $expirydate, $ID = '', $class = '' ) { global $al_core; $al_core->alanah_wc_product_carousel( $args, $slider_cols, $direction, $scroll, $autoplay, $title, $timer, $expirydate, $ID, $class ); } /** * Create product Grid getting query */ function alanah_products_grid( $args, $title, $column, $timer, $expirydate, $ID = '', $class = '' ) { global $al_core; $al_core->alanah_wc_product_grid( $args, $title, $column, $timer, $expirydate, $ID, $class ); } /** * Get product categories array */ function alanah_woo_categories() { global $al_core; return $al_core->alanah_wc_categories(); } /** * Hide categories & products from shop */ add_action( 'woocommerce_product_query', 'alanah_shop_products_query' ); function alanah_shop_products_query( $query ) { if( alanah_get_option( 'hide_product_category' ) ) : $tax_query = (array) $query->get( 'tax_query' ); $tax_query[] = array( 'taxonomy' => 'product_cat', 'field' => 'slug', 'terms' => array( alanah_get_option( 'hide_product_category' ) ), 'operator' => 'NOT IN' ); $query->set( 'tax_query', $tax_query ); endif; } /** * Change woocommerce checkout fields */ add_filter( 'woocommerce_default_address_fields', 'alanah_checkout_address_label', 9999 ); function alanah_checkout_address_label( $fields ) { $fields['address_2']['label'] = __( 'Apartment', 'alanah-free' ); return $fields; } /** * Change number of related products */ function woo_related_products_limit() { global $product; $args['posts_per_page'] = 20; return $args; } add_filter( 'woocommerce_output_related_products_args', 'alanah_related_products_args', 20 ); function alanah_related_products_args( $args ) { $args['posts_per_page'] = 20; // 20 related products return $args; } /** * Ajax Add to Cart handler */ add_action( 'wc_ajax_alanah_add_to_cart', 'alanah_ajax_add_to_cart_handler' ); add_action( 'wc_ajax_nopriv_alanah_add_to_cart', 'alanah_ajax_add_to_cart_handler' ); function alanah_ajax_add_to_cart_handler() { WC_Form_Handler::add_to_cart_action(); WC_AJAX::get_refreshed_fragments(); } // Remove WC Core add to cart handler to prevent double-add if( alanah_get_option( 'ajax_addtocart' ) ) remove_action( 'wp_loaded', array( 'WC_Form_Handler', 'add_to_cart_action' ), 20 ); /** * Add fragments for notices. */ add_filter( 'woocommerce_add_to_cart_fragments', 'alanah_ajax_add_to_cart_add_fragments' ); function alanah_ajax_add_to_cart_add_fragments( $fragments ) { $all_notices = WC()->session->get( 'wc_notices', array() ); $notice_types = apply_filters( 'woocommerce_notice_types', array( 'error', 'success', 'notice' ) ); ob_start(); foreach ( $notice_types as $notice_type ) { if ( wc_notice_count( $notice_type ) > 0 ) { wc_get_template( "notices/{$notice_type}.php", array( 'notices' => array_filter( $all_notices[ $notice_type ] ), ) ); } } $fragments['notices_html'] = ob_get_clean(); wc_clear_notices(); return $fragments; } /** * Woocommerce Override Product per page. */ add_filter( 'loop_shop_per_page', 'alanah_loop_shop_per_page', 30 ); function alanah_loop_shop_per_page( $products ) { return alanah_get_option( 'products_per_page' ); } /** * Print Start Ratings on Shop loop */ add_action( 'woocommerce_before_shop_images', 'alanah_print_stars', 10);/** Print ratings on loop items **/ function alanah_print_stars() { //global $al_core; ALANAH_CORE_FUNCTIONS::alanah_print_stars(); } //alanah_print_stars /** * Redirect to after login */ add_filter( 'woocommerce_login_redirect', 'alanah_woo_login_redirect' ); function alanah_woo_login_redirect( $redirect_to ) { return get_permalink( wc_get_page_id( 'myaccount' ) ); }