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( 'ALPHA_CORE_VERSION' ) ) {
wp_enqueue_script( 'jquery-countdown' );
wp_enqueue_style( 'alpha-countdown', ALPHA_ASSETS . '/vendor/countdown/countdown' . ( is_rtl() ? '-rtl' : '' ) . '.min.css', array(), '6.7.0' );
wp_enqueue_script( 'alpha-countdown', ALPHA_ASSETS . '/vendor/countdown/countdown' . ALPHA_JS_SUFFIX, '6.7.0', true );
}
?>
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';
$button_text = apply_filters( 'alpha_woocompare_added_label', esc_html__( 'Added', 'alpus' ) );
} else {
$button_text = apply_filters( 'alpha_woocompare_add_label', esc_html__( 'Compare', 'alpus' ) );
}
printf( '%s', esc_url( $url ), esc_attr( $css_class ), esc_html( $button_text ), $product_id, esc_html( apply_filters( 'alpha_woocompare_added_label', esc_html__( 'Added', 'alpus' ) ) ), esc_html( $button_text ) );
}
}
/**
* The product loop vertical action
*
* @since 1.0
*/
if ( ! function_exists( 'alpha_product_loop_vertical_action' ) ) {
function alpha_product_loop_vertical_action() {
// if product type is not default, do not print vertical action buttons.
global $product;
$product_type = alpha_wc_get_loop_prop( 'product_type' );
/**
* Filters the vertical actions of product.
*
* @since 1.0
*/
$exclude_type = apply_filters( 'alpha_product_loop_vertical_action', array( 'widget' ) );
if ( ! in_array( $product_type, $exclude_type ) ) {
$html = '';
if ( '' == alpha_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 ( '' == alpha_wc_get_loop_prop( 'wishlist_pos' ) && defined( 'YITH_WCWL' ) ) {
$html .= do_shortcode( '[yith_wcwl_add_to_wishlist container_classes="btn-product-icon"]' );
}
ob_start();
alpha_product_compare( ' btn-product-icon' );
$html .= ob_get_clean();
if ( '' == alpha_wc_get_loop_prop( 'quickview_pos' ) ) {
global $product;
$html .= '';
}
ob_start();
do_action( 'alpha_product_loop_gallery_buttons' );
$html .= ob_get_clean();
if ( $html ) {
echo '' . alpha_escaped( $html ) . '
';
}
}
}
}