';
// 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;
}
// End of file themeoo-woocommerce-hook-helper.php