'; } } /** * Product loop figure close * * @since 1.0 */ if ( ! function_exists( 'alpus_product_loop_figure_close' ) ) { function alpus_product_loop_figure_close() { echo ''; } } /** * Product loop hover thumbnail * * @since 1.0 */ if ( ! function_exists( 'alpus_product_loop_hover_thumbnail' ) ) { function alpus_product_loop_hover_thumbnail() { if ( alpus_get_option( 'hover_change' ) ) { $gallery = get_post_meta( get_the_ID(), '_product_image_gallery', true ); if ( ! empty( $gallery ) ) { $gallery = explode( ',', $gallery ); if ( ! empty( $gallery[0] ) ) { $attachment_image = wp_get_attachment_image( $gallery[0], alpus_wc_get_loop_prop( 'hover_thumbnail_size' ), false ); /** * Filters the html of product hover image. * * @since 1.0 */ echo apply_filters( 'alpus_product_hover_image_html', $attachment_image ); } } } } } /** * The single product archive thumbnail size. * * @since 1.0 */ if ( ! function_exists( 'alpus_single_product_archive_thumbnail_size' ) ) { function alpus_single_product_archive_thumbnail_size( $size ) { $new_size = $size; if ( isset( $GLOBALS['alpus_current_product_img_size'] ) ) { $new_size = $GLOBALS['alpus_current_product_img_size']; unset( $GLOBALS['alpus_current_product_img_size'] ); } else { $new_size = alpus_wc_get_loop_prop( 'thumbnail_size', $size ); } if ( 'custom' != $new_size ) { $size = $new_size; } wc_set_loop_prop( 'hover_thumbnail_size', $size ); return $size; } } /** * The product loop vertical action * * @since 1.0 */ if ( ! function_exists( 'alpus_product_loop_vertical_action' ) ) { function alpus_product_loop_vertical_action() { // if product type is not default, do not print vertical action buttons. global $product; $product_type = alpus_wc_get_loop_prop( 'product_type' ); /** * Filters the vertical actions of product. * * @since 1.0 */ $exclude_type = apply_filters( 'alpus_product_loop_vertical_action', array( 'widget' ) ); if ( ! in_array( $product_type, $exclude_type ) ) { $html = ''; if ( '' == alpus_wc_get_loop_prop( 'addtocart_pos' ) ) { ob_start(); woocommerce_template_loop_add_to_cart( array( 'class' => implode( ' ', array_filter( array( 'btn-product-icon', 'product_type_' . $product->get_type(), $product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '', $product->supports( 'ajax_add_to_cart' ) && $product->is_purchasable() && $product->is_in_stock() ? 'ajax_add_to_cart' : '', ) ) ), ) ); $html .= ob_get_clean(); } if ( '' == alpus_wc_get_loop_prop( 'wishlist_pos' ) && defined( 'YITH_WCWL' ) ) { $html .= do_shortcode( '[yith_wcwl_add_to_wishlist container_classes="btn-product-icon"]' ); } if ( alpus_get_option( 'compare_available' ) ) { ob_start(); alpus_product_compare( ' btn-product-icon' ); $html .= ob_get_clean(); } if ( '' == alpus_wc_get_loop_prop( 'quickview_pos' ) ) { global $product; $html .= ''; } if ( $html ) { echo '
' . alpus_escaped( $html ) . '
'; } } } } /** * The product loop media action * * @since 1.0 */ if ( ! function_exists( 'alpus_product_loop_media_action' ) ) { function alpus_product_loop_media_action() { global $product; if ( 'bottom' == alpus_wc_get_loop_prop( 'addtocart_pos' ) ) { if ( 'bottom' == alpus_wc_get_loop_prop( 'quickview_pos' ) ) { echo '
'; woocommerce_template_loop_add_to_cart( array( 'class' => implode( ' ', array_filter( array( 'btn-product-icon', 'product_type_' . $product->get_type(), $product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '', $product->supports( 'ajax_add_to_cart' ) && $product->is_purchasable() && $product->is_in_stock() ? 'ajax_add_to_cart' : '', ) ) ), ) ); if ( defined( 'YITH_WCWL' ) ) { echo do_shortcode( '[yith_wcwl_add_to_wishlist container_classes="btn-product-icon"]' ); } if ( alpus_get_option( 'compare_available' ) ) { echo alpus_product_compare( ' btn-product-icon' ); } global $product; echo ''; } else { echo '
'; woocommerce_template_loop_add_to_cart( array( 'class' => implode( ' ', array_filter( array( 'btn-product', 'product_type_' . $product->get_type(), $product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '', $product->supports( 'ajax_add_to_cart' ) && $product->is_purchasable() && $product->is_in_stock() ? 'ajax_add_to_cart' : '', ) ) ), ) ); } echo '
'; } elseif ( 'bottom' == alpus_wc_get_loop_prop( 'quickview_pos' ) ) { global $product; echo '
'; } } } /** * The product loop count deal * * @since 1.0 */ if ( ! function_exists( 'alpus_product_loop_count_deal' ) ) { function alpus_product_loop_count_deal() { global $product; if ( $product->is_on_sale() ) { if ( $product->is_type( 'variable' ) ) { $variations = $product->get_available_variations( 'object' ); $date_diff = ''; $sale_date = ''; foreach ( $variations as $variation ) { if ( $variation->is_on_sale() ) { $new_date = get_post_meta( $variation->get_id(), '_sale_price_dates_to', true ); if ( ! $new_date || ( $date_diff && $date_diff != $new_date ) ) { $date_diff = false; } elseif ( $new_date ) { if ( false !== $date_diff ) { $date_diff = $new_date; } $sale_date = $new_date; } if ( false === $date_diff && $sale_date ) { break; } } } if ( $date_diff ) { $date_diff = date( 'Y/m/d H:i:s', (int) $date_diff ); } elseif ( $sale_date ) { $date_diff = date( 'Y/m/d H:i:s', (int) $sale_date ); } } else { $date_diff = $product->get_date_on_sale_to(); if ( $date_diff ) { $date_diff = $date_diff->date( 'Y/m/d H:i:s' ); } } if ( $date_diff ) : if ( defined( 'ALPUS_CORE_VERSION' ) ) { wp_enqueue_script( 'jquery-countdown' ); wp_enqueue_style( 'alpus-countdown', alpus_core_framework_uri( '/widgets/countdown/countdown' . ( is_rtl() ? '-rtl' : '' ) . '.min.css' ), array(), ALPUS_CORE_VERSION ); wp_enqueue_script( 'alpus-countdown', alpus_core_framework_uri( '/widgets/countdown/countdown' . ALPUS_JS_SUFFIX ), array( 'jquery-countdown' ), ALPUS_CORE_VERSION, true ); } ?>
'; } } /** * The product loop details close * * @since 1.0 */ if ( ! function_exists( 'alpus_product_loop_details_close' ) ) { function alpus_product_loop_details_close() { echo '
'; } } /** * The wc template loop product title * * @since 1.0 */ if ( ! function_exists( 'alpus_wc_template_loop_product_title' ) ) { function alpus_wc_template_loop_product_title() { echo '

'; echo '' . alpus_strip_script_tags( get_the_title() ) . ''; echo '

'; } } /** * The shop loop item categories. * * @since 1.0 */ if ( ! function_exists( 'alpus_shop_loop_item_categories' ) ) { function alpus_shop_loop_item_categories() { $name = alpus_wc_get_loop_prop( 'name' ); if ( 'related' != $name ) { global $product; echo '
' . wc_get_product_category_list( $product->get_id(), ', ', '' ) . '
'; } } } /** * The product loop default wishlist action * * @since 1.0 */ if ( ! function_exists( 'alpus_product_loop_default_wishlist_action' ) ) { function alpus_product_loop_default_wishlist_action() { if ( defined( 'YITH_WCWL' ) && 'with_title' == alpus_wc_get_loop_prop( 'wishlist_pos' ) ) { echo do_shortcode( '[yith_wcwl_add_to_wishlist]' ); } } } /** * The product loop action * * @since 1.0 */ if ( ! function_exists( 'alpus_product_loop_action' ) ) { function alpus_product_loop_action( $details = '' ) { global $product; $product_type = alpus_wc_get_loop_prop( 'product_type' ); /** * Filters the action of product. * * @since 1.0 */ $exclude_type = apply_filters( 'alpus_product_loop_action', array( 'widget' ) ); if ( ! in_array( $product_type, $exclude_type ) ) { if ( 'detail_bottom' == alpus_wc_get_loop_prop( 'addtocart_pos' ) ) { echo '
'; woocommerce_template_loop_add_to_cart( array( 'class' => implode( ' ', array_filter( array( 'btn-product', 'product_type_' . $product->get_type(), $product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '', $product->supports( 'ajax_add_to_cart' ) && $product->is_purchasable() && $product->is_in_stock() ? 'ajax_add_to_cart' : '', ) ) ), ) ); echo '
'; } elseif ( 'with_qty' == alpus_wc_get_loop_prop( 'addtocart_pos' ) ) { echo '
'; if ( 'simple' == $product->get_type() ) { woocommerce_quantity_input( array( 'min_value' => apply_filters( 'woocommerce_quantity_input_min', $product->get_min_purchase_quantity(), $product ), 'max_value' => apply_filters( 'woocommerce_quantity_input_max', $product->get_max_purchase_quantity(), $product ), 'input_value' => isset( $_POST['quantity'] ) ? wc_stock_amount( sanitize_text_field( wp_unslash( $_POST['quantity'] ) ) ) : $product->get_min_purchase_quantity(), // WPCS: CSRF ok, input var ok. ) ); } woocommerce_template_loop_add_to_cart( array( 'class' => implode( ' ', array_filter( array( 'btn-product', 'product_type_' . $product->get_type(), $product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '', $product->supports( 'ajax_add_to_cart' ) && $product->is_purchasable() && $product->is_in_stock() ? 'ajax_add_to_cart' : '', ) ) ), ) ); echo '
'; } } } } /** * The product loop count * * @since 1.0 */ if ( ! function_exists( 'alpus_product_loop_count' ) ) { function alpus_product_loop_count() { $html = ''; $show_progress = alpus_wc_get_loop_prop( 'show_progress', '' ); $count_text = alpus_wc_get_loop_prop( 'count_text', '' ); if ( $show_progress && $count_text ) { global $product; $sales = $product->get_total_sales(); $stock = $product->get_stock_quantity(); $total = $sales + $stock; if ( $total && $show_progress ) { ?>
' . wc_get_star_rating_html( $rating, $count ) . ''; } return $html; } } /** * Get the rating link html. * * @since 1.0 */ if ( ! function_exists( 'alpus_get_rating_link_html' ) ) { function alpus_get_rating_link_html( $product ) { return '(' . $product->get_review_count() . ' ' . esc_html__( 'reviews', 'alpus' ) . ')'; } } /** * Change order of del and ins tag. * * @since 1.0 */ if ( ! function_exists( 'alpus_wc_format_sale_price' ) ) { function alpus_wc_format_sale_price( $price, $regular_price, $sale_price ) { return '' . ( is_numeric( $sale_price ) ? wc_price( $sale_price ) : $sale_price ) . ' ' . ( is_numeric( $regular_price ) ? wc_price( $regular_price ) : $regular_price ) . ''; } } /** * Remove default YITH loop positions * * @since 1.0 */ if ( ! function_exists( 'alpus_yith_wcwl_loop_positions' ) ) { function alpus_yith_wcwl_loop_positions( $positions ) { $positions['before_image']['hook'] = ''; $positions['before_image']['priority'] = 10; return $positions; } } /** * Add the wishlist icon class name. * * @since 1.0 */ if ( ! function_exists( 'alpus_yith_wcwl_add_btn_product_icon_params' ) ) { function alpus_yith_wcwl_add_btn_product_icon_params( $args ) { $args['container_classes'] .= ' btn-product-icon'; return $args; } } /** * Alpus product compare function * * @since 1.0 */ if ( ! function_exists( 'alpus_product_compare' ) ) { function alpus_product_compare( $extra_class = '' ) { if ( ! class_exists( 'Alpus_Product_Compare' ) ) { return; } global $product; $css_class = 'compare' . ( $extra_class ? ' ' . trim( $extra_class ) : '' ); $product_id = $product->get_id(); $url = '#'; if ( Alpus_Product_Compare::get_instance()->is_compared_product( $product_id ) ) { $url = get_permalink( wc_get_page_id( 'compare' ) ); $css_class .= ' added'; /** * Filters the added label of woocompare. * * @since 1.0 */ $button_text = apply_filters( 'alpus_woocompare_added_label', esc_html__( 'Added', 'alpus' ) ); } else { /** * Filters the add label of woocompare. * * @since 1.0 */ $button_text = apply_filters( 'alpus_woocompare_add_label', esc_html__( 'Compare', 'alpus' ) ); } printf( '', esc_url( $url ), esc_attr( $css_class ), esc_html( $button_text ), $product_id, esc_html( apply_filters( 'alpus_woocompare_added_label', esc_html__( 'Added', 'alpus' ) ) ) ); } } /** * Get product extra info html * * @since 1.0 */ if ( ! function_exists( 'alpus_get_extra_info_html' ) ) { function alpus_get_extra_info_html() { $extra_info = get_post_meta( get_the_ID(), 'alpus_extra_info', true ); if ( ! empty( $extra_info ) ) { printf( '
(%s)
', $extra_info ); } } } /** * Add exclude attribute to products shortcode. * * @since 1.0 * * @param array $out The output array of shortcode attributes. * @param array $pairs The supported attributes and their defaults. * @param array $atts The user defined shortcode attributes. */ function alpus_wc_shortcode_product_add_exclude_attribute( $out, $pairs, $atts ) { if ( isset( $atts['exclude'] ) ) { $out['exclude'] = $atts['exclude']; } return $out; } /** * Add exclude arg to woocommerce shortcode product. * * @since 1.0 * @param array $query_args * @param array $attributes * @param string $type * @return array $query_args */ function alpus_wc_shortcode_product_add_exclude_arg( $query_args, $attributes, $type ) { if ( ! empty( $attributes['exclude'] ) ) { $query_args['post__not_in'] = array_map( 'trim', explode( ',', $attributes['exclude'] ) ); } return $query_args; } foreach ( apply_filters( 'alpus_product_loop_types', array( 'default' => true, ), 'hooks' ) as $key => $value ) { if ( $key && $value ) { require_once alpus_framework_path( ALPUS_FRAMEWORK_PLUGINS . "/woocommerce/product-loop/product-loop-{$key}.php" ); } } /** * Fires after setting product single actions and filters. * * Here you can remove and add more actions and filters. * * @since 1.0 */ do_action( 'alpus_after_product_loop_hooks' );