New Landing How can we help? Atelier Chose an option…

Viewing 14 posts - 1 through 14 (of 14 total)
  • Posted in: Atelier
  • #219270
    dsirard11
    Member
    Post count: 122

    Hello,

    We have several attributes and variations set up for our products – including size, color and fragrance. On the product page the pull-down option boxes default to “Chose an Option.” Can we change this text to say Chose a color or Chose a size..etc.?

    If so, how do I do that?

    Thank you for your help.
    Dawna

    Attachments:
    You must be logged in to view attached files.
    #219307
    Kyle – SUPPORT
    Moderator
    Post count: 35880

    Hi

    Please contact WooCommerce about this as it’s their functionality.

    Thanks
    – Kyle

    #219414
    dsirard11
    Member
    Post count: 122

    How do I do that? When I go to their website, they say they only offer support for paying customers. Is there a another way to contact support?

    Best,
    Dawna

    #219419
    Kyle – SUPPORT
    Moderator
    Post count: 35880
    #219446
    dsirard11
    Member
    Post count: 122

    Hi Kyle,

    The instructions I received are:

    Go to variable.php

    Look for this on line 24

    <option value=””><?php echo __( ‘Choose an option’, ‘woocommerce’ ) ?>…</option>

    and replace it with

    <option value=””><?php echo sprintf( __( ‘Choose a %s’, ‘woocommerce’ ), $woocommerce->attribute_label( $name ) ) ?>…</option>

    or you can just replace the ‘Choose an Option’ with the text of your choice

    Where is the variable.php file?

    #219448
    Kyle – SUPPORT
    Moderator
    Post count: 35880

    It’s in the woocommerce files.. wp-content/plugins/woocommerce

    – Kyle

    #219449
    dsirard11
    Member
    Post count: 122

    Okay – so where are those files located? I don’t see them in the Appearance –> Editor area.

    #219452
    Kyle – SUPPORT
    Moderator
    Post count: 35880

    You will have to edit them via ftp. Again, this is woocommerce functionality so please discuss with them

    – Kyle

    #219533
    dsirard11
    Member
    Post count: 122

    In case anyone is wondering how we solved this – here are the instructions. You will need to use FTP to access the correct files).

    1. Override ‘variable.php‘ file by copying it from ‘woocommerce/single-product/add-to-cart/variable.php‘ to your theme directory. For example; #your_theme_location/woocommerce/single-product/add-to-cart/variable.php.

    2. Once done, edit variable.php and lookout for the code as the one shown below (In woocommerce version 2.4.7, the below code was starting at line 27 and ends at line 38):

    <?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 ) ] ) ? $_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 ) );
    ?>
    </td>
    </tr>
    <?php endforeach;?>

    replace it with the below code:

    <?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 ? ‘‘ . __( ‘Clear selection’, ‘woocommerce’ ) . ‘‘ : ”; ?>
    </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 );
    } ?>

    Once done, save ‘variable.php‘ file and refresh your product page to see ‘Choose an option” replaced with ‘Choose <attribute_name>’. That’s it!

    #219551
    Kyle – SUPPORT
    Moderator
    Post count: 35880

    Great! Thanks for sharing

    – Kyle

    #221595
    romain
    Member
    Post count: 2

    Hi,

    The above solution did not work in my case.

    I found another way to do this, which worked great for me to replace choose an option to choose a <attribute name>.
    It also gave me the possibility to change easily the term “Choose a” to whatever I like, for example “choose from” or “select a”.

    Here it is :

    In wc-template-functions.php in line 1915.

    Select the following code :

    $args = wp_parse_args( $args, array(
    ‘options’ => false,
    ‘attribute’ => false,
    ‘product’ => false,
    ‘selected’ => false,
    ‘name’ => ”,
    ‘id’ => ”,
    ‘class’ => ”,
    ‘show_option_none’ => __( ‘Choose an option’, ‘woocommerce’ )
    ) );

    And replace with :

    $mb_name = $args[‘attribute’];
    $args = wp_parse_args( $args, array(
    ‘options’ => false,
    ‘attribute’ => false,
    ‘product’ => false,
    ‘selected’ => false,
    ‘name’ => ”,
    ‘id’ => ”,
    ‘class’ => ”,
    ‘show_option_none’ => __( ‘Choose a ‘, ‘woocommerce’ ) . $mb_name
    ) );

    where you can edit ‘Choose a’ to whatever you like.

    Source from https://wordpress.org/support/topic/feature-request-choose-an-option-woocommerce-v24

    #221599
    David Martin – Support
    Moderator
    Post count: 20834

    I would not recommend editing the core plugin files, please consult their docs on the correct way to extend/modify their plugin: https://docs.woothemes.com/documentation/plugins/woocommerce/woocommerce-codex/extending/

    #227071
    dsirard11
    Member
    Post count: 122

    I’m all set with this issue – you can close it. Thank you! 🙂

    #227073
    David Martin – Support
    Moderator
    Post count: 20834

    No problem, thanks.
    David.

Viewing 14 posts - 1 through 14 (of 14 total)

You must be logged in and have valid license to reply to this topic.

License required for one of the following items
Login and Registration Log in · Register