Hello!
I am trying to modify the variable.php file from WooCommerce. It’s in the path /wp-content/themes/child-theme-name/woocommerce/single-product/add-to-cart/variable.php
Now, Sparkling, does not have that file. I am thinking of just adding it, but I don’t think that would work.
I am trying to change my form so that my drop-down for variations shows the name of the option vs the default “choose an option”.
This is the code I’ve used in the past in the variable.php file:
<?php
$variations_arr = array();
foreach ( $attributes as $attribute_name => $options ) :
ob_start(); ?>
<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( $_REQUEST[ 'attribute_' . sanitize_title( $attribute_name ) ] ) : $product->get_variation_default_attribute( $attribute_name );
wc_dropdown_variation_attribute_options( array( 'options' => $options, 'attribute' => $attribute_name, 'product' => $product, 'selected' => $selected ) );
echo end( $attribute_keys ) === $attribute_name ? '<a class="reset_variations" href="#">' . __( 'Clear selection', 'woocommerce' ) . '</a>' : ''; ?>
</td>
</tr>
<?php $variations_ob = ob_get_clean();
$variations_arr[wc_attribute_label($attribute_name)] = $variations_ob;
endforeach;
foreach ($variations_arr as $name => $ob) {
echo str_ireplace('choose an option', 'Choose '.$name, $ob );
}
?>
Any suggestions?
THANKS in advance!