Advertisement
daymobrew

Change attribute default dropdown value

Jun 15th, 2018
513
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.58 KB | None | 0 0
  1. <?php
  2. // Change 'Choose an option' depending on variation - to help it display on one line on mobile.
  3. // From: https://stackoverflow.com/a/34713246/8605943
  4. add_filter( 'woocommerce_dropdown_variation_attribute_options_args', 'am_change_option_none_text' );
  5. function am_change_option_none_text( $args ) {
  6.     //error_log( 'Dropdown args: ' . var_export( $args, true ) );
  7.     if ( 'pa_size' == $args[ 'attribute' ] ) {
  8.         $args['show_option_none'] = 'Choose size';
  9.     }
  10.     if ( 'pa_colour' == $args[ 'attribute' ] ) {
  11.         $args['show_option_none'] = 'Choose colour';
  12.     }
  13.     return $args;
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement