Title: WooCommerce Dropdown Empty
Last modified: June 16, 2020

---

# WooCommerce Dropdown Empty

 *  [jaydjohno](https://wordpress.org/support/users/jaydjohno/)
 * (@jaydjohno)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/woocommerce-dropdown-empty/)
 * HI All
 * I am working on a custom theme for Elementor and have been creating my own custom
   add to cart widget, i have set up the simple product one with no problem and 
   i have been trying to do a variable one.
 * everything works apart from the attributes dropdown, i know there is something
   i have missed, if anyone can help me where i have gone wrong this will help me
   a lot, i have been looking at this all day and looked on various sites and their
   code seems the same as mine but mine don’t work.
 * I have set up my variations and they seem to be showing on the product page, 
   hwoever my drop down just says choose weight, then no options.
 * Here is my code, if anybody can have a look and see whats wrong.
 *     ```
       $available_variations = $product->get_available_variations();
       $attributes = $product->get_attributes();
       $attribute_keys  = array_keys( $attributes );
       $variations_json = wp_json_encode( $available_variations );
       $variations_attr = function_exists( 'wc_esc_json' ) ? wc_esc_json( $variations_json ) : _wp_specialchars( $variations_json, ENT_QUOTES, 'UTF-8', true );
   
       <tbody>
               <?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 );
               } ?>
           </tbody>
       </table>
       ```
   
 * Any help would be appreciated as i now have a headache trying to troubleshoot
   it all day.
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fwoocommerce-dropdown-empty%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

The topic ‘WooCommerce Dropdown Empty’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

## Tags

 * [variable product](https://wordpress.org/support/topic-tag/variable-product/)

 * 0 replies
 * 1 participant
 * Last reply from: [jaydjohno](https://wordpress.org/support/users/jaydjohno/)
 * Last activity: [5 years, 11 months ago](https://wordpress.org/support/topic/woocommerce-dropdown-empty/)
 * Status: not resolved