';
// Attribute label.
$attrib_name = wc_attribute_label( $attribute, $product );
if ( ! empty( $options ) ) {
if ( $product && taxonomy_exists( $attribute ) ) { //@phpstan-ignore-line
$terms = wc_get_product_terms( $product->get_id(), $attribute, [ 'fields' => 'all' ] );
foreach ( $terms as $term ) {
if ( in_array( $term->slug, $options, true ) ) {
$id = $name . '-' . $term->slug;
$opt_name = apply_filters( 'woocommerce_variation_option_name', $term->name );
$title = sprintf(
/* translators: 1. attribute label, 2. attribute value. */
_x( '%1$s: %2$s', 'Product attribute option tooltip.', 'ayyash' ),
$attrib_name,
$opt_name
);
$output = '
term_id, 'color', true );
$color = ! $color ? strtolower( $term->name ) : $color;
$output .= 'style="background-color: ' . esc_attr( $color ) . '">';
$output .= '
';
} else {
$output .= '>' . esc_html( $term->name );
}
$output .= '';
$radios .= '
slug, false ) . '>
';
}
}
} else {
foreach ( $options as $option ) {
$id = $name . '-' . $option;
$output = apply_filters( 'woocommerce_variation_option_name', $option );
$title = sprintf(
/* translators: 1. attribute label, 2. attribute value. */
_x( '%1$s: %2$s', 'Product attribute option tooltip.', 'ayyash' ),
$attrib_name,
$output
);
$output = '
' . esc_html( $output ) . '';
$checked = sanitize_title( $args['selected'] ) === $args['selected'] ? checked( $args['selected'], sanitize_title( $option ), false ) : checked( $args['selected'], $option, false );
$radios .= '
';
}
}
}
$radios .= '
';
return $html . $radios;
}
/**
* Check Product Variation.
*
* @param bool $active Activate.
* @param WC_Product_Variation $variation Variation.
*
* @return bool
*/
function themeoo_variation_check( $active, $variation ) {
if ( ! $variation->is_in_stock() && ! $variation->backorders_allowed() ) {
return false;
}
return $active;
}
if ( ! function_exists( 'themeoo_product_loop_classes' ) ) {
/**
* Themeoo Cart Button Classes
*
* @return string
*/
function themeoo_product_loop_classes() {
$classes[] = 'products themeoo-products columns-' . esc_attr( wc_get_loop_prop( 'columns' ) );
$classes = apply_filters( 'themeoo_product_loop_classes', $classes );
$classes = array_unique( array_filter( $classes ) );
return implode(' ', $classes);
}
}
if ( ! function_exists( 'themeoo_product_classes' ) ) {
/**
* Themeoo Cart Button Classes
*
* @return string
*/
function themeoo_product_classes() {
$classes[] = 'themeoo-product-item';
$classes[] = 'hover-grow-up';
$classes[] = 'hover-actions';
$classes[] = 'hover-button';
$classes[] = 'themeoo-cart-button';
$classes = apply_filters( 'themeoo_product_classes', $classes );
$classes = array_unique( array_filter( $classes ) );
return implode(' ', $classes);
}
}
if ( ! function_exists( 'product_cat_item_class' ) ) {
/**
* Themeoo Product category item class
*
* @return string
*/
function product_cat_item_class( $classes ) {
$classes[] = 'themeoo-product-item';
return $classes;
}
}
if ( ! function_exists( 'themeoo_cart_btn_classes' ) ) {
/**
* Themeoo Cart Button Classes
*
* @return string
*/
function themeoo_cart_btn_classes() {
$classes[] = 'themeoo-cart-button';
$classes = apply_filters( 'themeoo_cart_btn_classes', $classes );
$classes = array_unique( array_filter( $classes ) );
return implode(' ', $classes);
}
}
/**
* Product Actions
*
* @return void
*/
function themeoo_single_product_actions() {
?>