Support » Plugin: Product Specifications for Woocommerce » Change default selected table from None

  • Resolved cziberez

    (@cziberez)


    Hello,

    Is it possible that if I have a table with 3 groups and when I create a new product the default selection is my table not the None text? It’s a bit annoying to open the specs every time if I would like to use it. I’ve tried jQuery but I can’t trigger the load if I select one.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Amin

    (@dornaweb)

    I’m afraid that’s not possible, because the purpose of this plugin is to design specs table for different kinds of products. However as you mentioned you can add some jquery to admin_head to load your desired table when the page loads.

    Something like this may help :

    <?php
    add_action( 'admin_head', function(){ ?>
      <script>
        jQuery(document).ready(function(){
          jQuery('#spec_tables_list option[value=42]').prop('selected', true);
          jQuery('#spec_tables_list option[value=42]').trigger('change');
        });
      </script>
    <?php }); ?>

    where 42 is your table id

    • This reply was modified 1 year, 8 months ago by Amin.

    I’ve tried this, but trigger('change') doesn’t load my table with value of 812.

    Here is what I got:

    Image

    So it’s selected, but not loaded.

    That’s why I’m asking.

    Ps: I’ve a complete Hungarian Translation if you need.

    Plugin Author Amin

    (@dornaweb)

    I’m sorry i did something wrong in the previous answer , the change should go like this :
    jQuery('#spec_tables_list').trigger('change');

    So the full code is :

    <?php
    add_action( 'admin_head', function(){ ?>
      <script>
        jQuery(document).ready(function(){
          jQuery('#spec_tables_list option[value=42]').prop('selected', true);
          jQuery('#spec_tables_list').trigger('change');
        });
      </script>
    <?php }); ?>

    If it didn’t work, you can also try jQuery('#spec_tables_list').val(812) or set a delay with setTimeout

    And yes i would be glad to add the Hungarian translation, you can send it to me : amin.pe94@gmail.com
    Thank you <3

    • This reply was modified 1 year, 8 months ago by Amin.
    • This reply was modified 1 year, 8 months ago by Amin.
    • This reply was modified 1 year, 8 months ago by Amin.

    Okay, nvm, some jQuery scripts made it freeze the trigger, now it’s working.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Change default selected table from None’ is closed to new replies.