';
}
}
}
if ( ! function_exists( 'alpha_single_product_after_rating_end' ) ) {
function alpha_single_product_after_rating_end() {
global $alpha_layout;
if ( empty( $alpha_layout['single_product_block'] ) ) {
echo '';
}
}
}
/**
* Display sale countdown for simple & variable product in single product page.
*
* @since 1.0
* @param string $ends_label
* @return void
*/
if ( ! function_exists( 'alpha_single_product_sale_countdown' ) ) {
function alpha_single_product_sale_countdown( $ends_label = '' ) {
global $product;
if ( $product->is_on_sale() ) {
$extra_class = '';
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 ) {
$extra_class .= ' countdown-variations';
$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 && 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 );
?>
(' . $GLOBALS['product']->get_review_count() . ')';
}
// Global tab
$title = alpha_get_option( 'product_tab_title' );
if ( $title ) {
$tabs['alpha_product_tab'] = array(
'title' => sanitize_text_field( $title ),
'priority' => 24,
'callback' => 'alpha_wc_product_custom_tab',
);
}
if ( ! defined( 'ALPHA_PRO_VERSION' ) ) {
return $tabs;
}
// Custom tab for current product
$title = get_post_meta( get_the_ID(), 'alpha_custom_tab_title_1st', true );
if ( $title ) {
$tabs['alpha_custom_tab_1st'] = array(
'title' => sanitize_text_field( $title ),
'priority' => 26,
'callback' => 'alpha_wc_product_custom_tab',
);
}
$title = get_post_meta( get_the_ID(), 'alpha_custom_tab_title_2nd', true );
if ( $title ) {
$tabs['alpha_custom_tab_2nd'] = array(
'title' => sanitize_text_field( $title ),
'priority' => 26,
'callback' => 'alpha_wc_product_custom_tab',
);
}
return $tabs;
}
}
/**
* wc_product_custom_tab
*
* Render Woocommerce Custom Tab.
*
* @param string $key
* @param string product_tab
*
* @since 1.0
*/
if ( ! function_exists( 'alpha_wc_product_custom_tab' ) ) {
function alpha_wc_product_custom_tab( $key, $product_tab ) {
if ( ! defined( 'ALPHA_PRO_VERSION' ) ) {
return;
}
wc_get_template(
'single-product/tabs/custom_tab.php',
array(
'tab_name' => $key,
'tab_data' => $product_tab,
)
);
}
}
/**
* single_product_brands
*
* Render single product brands.
*
* @since 1.0
*/
if ( ! function_exists( 'alpha_single_product_brands' ) ) {
function alpha_single_product_brands( $before_label = true, $type = 'name' ) {
global $product;
$has_brand_image = false;
$brands = wp_get_post_terms( get_the_ID(), 'product_brand', array( 'fields' => 'id=>name' ) );
$brand_html = '';
if ( is_array( $brands ) && count( $brands ) ) {
foreach ( $brands as $brand_id => $brand_name ) {
if ( 'name' != $type ) {
$brand_image = get_term_meta( $brand_id, 'brand_thumbnail_id', true );
}
if ( ! empty( $brand_image ) ) {
$has_brand_image = true;
$brand_html .= '';
$brand_html .= wp_get_attachment_image( $brand_image, 'full' );
$brand_html .= '';
} else {
if ( array_key_last( $brands ) == $brand_id ) {
$comma = '';
} else {
$comma = ', ';
}
$brand_html .= ( $before_label ? ( '' . esc_html__( 'Brand: ', 'alpus' ) ) : '' ) . '' . esc_html( $brand_name ) . '' . ( $before_label ? '' : '' ) . $comma;
}
}
}
return array(
'html' => $brand_html,
'has_image' => $has_brand_image,
);
}
}