Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #531899

    Hi Support,

    I would like to remove the default “choose an option” from the drop down on the product page.

    Thanks in a advance.

    #532133

    Hey Wils1234!

    Please see “setting defaults” here – https://docs.woothemes.com/document/variable-product/

    Cheers!
    Yigit

    #532200

    Hi Yigit,

    I have read the docs but it doesn´t seem to answer the question, unless I am missing somehting. I can set the defult to EU 36, but when you select from drop down choose an option is still present. How can this be removed?

    Thanks in advance.

    #532224

    Hi!

    Here’s a pretty simple solution for WC >2.4 that avoids rewriting functions and cluttering up your functions.php..

    Add the variable.php file to your theme (http://docs.woothemes.com/document/template-structure/), and change this (from line 27):

    <?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( $_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 endforeach;?>

    to this:

    <?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 );
    } ?>

    This will replace ‘Choose an option’ with ‘Choose Size’, ‘Choose Colour’ etc. depending on the name of your attribute.

    For more informations, fill free to check: http://stackoverflow.com/questions/32170575/how-do-i-change-button-text-from-choose-an-option-in-woocommerce

    Best regards,
    Basilis

    #534293

    Hi Basilis,

    This has now been resolved. Thank you.

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Remove Choose an Option’ is closed to new replies.