Search code examples
wordpresscontact-form-7wordpress-plugin-creation

How to set first option in Product And Custom Post type Dropdown CF7 wordpress plugin?


I am using wordpress plugin Product And Custom Post type Dropdown CF7 which allows us to show the products dropdown from Woocommerce. I want to add first option as 'select product'. How can I do that? Please help.


Solution

  • Found the solution. It can be done as:

    var data = {
        id: 1,
        text: 'Barn owl'
    };
    
    var newOption = new Option(data.text, data.id, false, false);
    $('#mySelect2').append(newOption).trigger('change');