Get attributes for currently product

Question

I have code:

<?php
$attributes = $product->get_variation_attributes($variation_ids);
$attribute_keys = array_keys( $attributes );
?>

<?php foreach ( $attributes as $attribute_name => $options ) : ?>
    <tr>
        <td class="label"><label for="<?php echo sanitize_title( $attribute_name ); ?>"><?php echo wc_attribute_label( $attribute_name ); ?></label></td>
        <td class="value">
            <?php
                $selected = isset( $_REQUEST[ 'attribute_' . sanitize_title( $attribute_name ) ] ) ? wc_clean( urldecode( $_REQUEST[ 'attribute_' . sanitize_title( $attribute_name ) ] ) ) : $product->get_variation_default_attribute( $attribute_name );
                $args = array( 'options' => $options, 'attribute' => $attribute_name, 'product' => $product, 'selected' => $selected );
                wc_dropdown_variation_attribute_options( $args );
            ?>
        </td>
    </tr>
<?php endforeach; ?>

i can get all attributes custom, but i need get only selected in variation tab, because one my product can have 2 variation, other 5 variation

0
, Lerry 3 days 0 Answers 8 views 0

Thousands of WordPress themes to start your new website with a bang.

Leave an answer