woocommerce – Using custom post type to feed a dropdown (Woo order-id into wpforms)

Using the plugin wpForms, I can auto-populate a dropdown with Custom Post Types (they call it “Dynamic Post Type Source”). Say I wanted to use this functionality to auto-populate a dropdown with order-ids from WooCommerce, so a logged-in-user can choose between the users orders.

I’ve written the code for getting a logged-in-user order-id’s, so how would I make a CPT that would not really create new posts, but instead be populated with a logged-in-users order-ids at run time (while the user is at a page with the form dropdown on it)?

Already asked wpForms for support, they did not want to help.

Code for getting the User Order-ids:

function woo_get_orderids_per_user( $content) {

$userID = get_current_user_id();

if( $userID > 0 ) {

        $orders= wc_get_orders(array(
            'customer_id' => $userID,
            'return' => 'ids',
        )); 

        foreach ($orders as $oids) {

            $order = wc_get_order( $oids );
            $items = $order->get_items();

            foreach ( $items as $item ) {
                $product = wc_get_product( $item('product_id') );
                $productname = $product->get_name();
                echo('<br> Product name: ');
                print_r($productname . ' (ordrenummer: ' . $oids . ')');
            }
        }

$content = str_replace( '{woo_orderid}', $productname . ' (Ordre ID: ' . $oids . ')', $content );

return $content;
}

else {
    return;
}

}

Dropdown with search features validation

Imagine a dropdown list with search features where I can type or paste some text. What will be the best way to validate my dropdown:

  • A: Comparing the text with the database text after click outside the box
  • B: Clear the dropdown if the user doesn’t click on something in the search list

How can i get data from Google Sheets to Google Forms dropdown list?

Thanks for the spell check unfortunately this is was a direct copy paste of the codes from developers.google.com guess they need to correct thier site.

Yes its possible

This can be done via google app script .setChoiceValues(values)

see full script here https://developers.google.com/apps-script/reference/forms/list-item#setchoicevaluesvalues

sample code:

var item = form.addListItem();
item.setTitle('Do you prefer cats or dogs?')
    .setChoices((
        item.createChoice('Cats'),
        item.createChoice('Dogs')

Instead of typing in the actual choices into this bracketed part of the script like the code sample above (cats) – use a cell & column range instead (4,3) that points to data range on the sheet where your dynamic dropdown choices are located, like this see here, this is piece of code is referencing an active sheet but you can modify the code to get cell ranges by referencing the sheet id instead>

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()(0);

var range = sheet.getRange("B2:D4");

// The row and column here are relative to the range
// getCell(1,1) in this code returns the cell at B2, B2
var cell = range.getCell(1, 1);
Logger.log(cell.getValue());

You can set the choice of the dropdown list items by referencing the google sheet cell range that the form is linked to or any other sheet by referencing the google sheet id & sheet name where your dropdown choices are located. you can get sheet id by looking at web link of your google sheet in your browser its the long string of characters & numbers or how to get sheet id by code > https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet#getid

Once done. to get the form to auto update use sheet or form triggers to call this update list script so that the form will be updated with new choices once it reloads.

I did something similar recently- auto populating & auto updating a google form with data values from the google sheet after a response has been submitted, here is the working live sample form: https://support.google.com/docs/thread/48344518?hl=en

magento2 – How to prevent dropdown menu from closing when moving between top level items?

We’re using a dropdown menu modified from snowdog and magento, and our top level items have 6 options. It’s a pretty standard menu; when hovering over the top level items it drops down and shows the subnav items. However, when moving in between the main items, the menu briefly closes before reopening with the options for the next item. My initial thought was to write some javascript to detect when the menu is already open, and if so, prevent the event from bubbling up the DOM, but I have a feeling the answer is probably more simple than this solution. Maybe using a transition delay to make the hovering more forgiving?

If I were to try adding a transition delay, would this be done in our navigation.less file? I inherited this code base and things are a little messy, so I’m not positive how to start going about this.

php – How do I get the selected value of the second dropdown from the first dropdown via MY-SQL?

I am building an editor for a blog. Each post will be categorised.

I am trying to get all the posts, with the category that they have been assigned to be displayed as dropdown menu.
So, when the user clicks on a post title from the first dropdown menu, then the second category dropbox will have the selected category associated with it, and display all the other categories in the same dropbox.

So. user can change the category of article. I am struggling with it and don’t know what I am doing wrong. Can anyone help?

<?php
  if (isset($_POST('Ga'))) {
    $db = new mysqli("dbhost", "username", "password", "dbname"); //set your database handler
    $query = "SELECT c.catid , a.titel , c.cat FROM artikelen a JOIN Categorie c ON c.catid = a.catid  where  c.catid = a.catid";
    $result = $db->query($query);

    while ($row = $result->fetch_assoc()) {

      if ($row ('a.catid') = ('c.catid')) {
        $selected = ($row('catid') == $result);
        echo "<option value="".$row("catid")."" ".($selected ? " selected="selected"":"").">".$row("cat")."</option>";      
      }
    }
  }
?>

<?php   
  $link = mysqli_connect("dbhost", "username", "password", "dbname");
  $db = new mysqli("dbhost", "username", "password", "dbname");//set your database handler
  $query = "SELECT c.catid , a.titel , c.cat FROM artikelen a JOIN Categorie c ON c.catid = a.catid";
  $result = $db->query($query);

  echo "<form action='test.php' method='post' enctype='multipart/form-data'>";
?>          

<select id='subcatsSelect'>

<?php
  // $query = "SELECT catid, cat FROM Categorie";
  $result = $db->query($query);

  while ($row = $result->fetch_assoc()) {
    // $subcats($row('catid'))() = array("catid" => $row('catid'), "val" => $row('cat'));  
    echo "<option value='catid'> {$row('titel')}</option>";
  }

?>

</select>

<select id='categoriesSelect'>

  <?php     
    $result = $db->query($query);
    while ($row = $result->fetch_assoc()) {
      $resultofcar = ("<option value='{$row ('catid')}'> {$row('cat')}</option>");
      echo $resultofcar;
    }
  ?>

</select>

<input id='Ga' type='submit'  value='Ga'name='Ga' />        

drop down list – Automatically opening the dropdown for guiding users

We have a page that lets our users analyze their data. In order to analyze the data, they need to select the data-set via a dropdown first and without selecting the data-set, the page is almost useless. Here is how it looks like:

empty page

We’re planning to open the dropdown automatically when the user opens the page, here is how it will look like if we implement it:

enter image description here

The idea is that we open the dropdown automatically on behalf of the user in order to be able to guide them in a better way. Otherwise, 30% of the users leave this page without selecting the model. On the other hand, dropdowns are usually user-controlled components so we’re not sure if it’s a good practice.

Magento2: Dropdown option in contact page

We add custom option in contact page:

<div class="field ordernumber">
                            <div class="control">
                                <input placeholder="<?php echo __('Order Number') ?>" name="ordernumber" id="ordernumber"
                                       title="<?php /* @escapeNotVerified */
                                       echo __('Order Number') ?>" value="" class="input-text" type="text"/>
                            </div>
                        </div>
                                                        <div class="field rodzajzgloszenia">
                <div class="control">
                    <input placeholder="<?php echo __('Rodzaj zgloszenia') ?>" name="rodzajzgloszenia" id="rodzajzgloszenia"
                           title="<?php /* @escapeNotVerified */
                           echo __('Rodzaj zgloszenia') ?>" value="" class="input-text" type="text"/>
                </div>
            </div>

email Template:

<tr>
           <td><strong>{{trans "Order Number"}}</strong></td>
        <td>{{var data.ordernumber}}</td>
    </tr>
<tr>
           <td><strong>{{trans "Rodzaj zgloszenia"}}</strong></td>
        <td>{{var data.rodzajzgloszenia}}</td>
    </tr>

But how to create in field: Rodzaj zgłoszenia dropdown with select option and forward in email selected option?

templates – Swap WooCommerce product catalog ordering dropdown with buttons?

I’d like to swap the standard WooCommerce dropdown for ordering the product catalogue using buttons, yet no Google search for an easy method of doing this (or a plugin) has been fruitful.

I’m using a custom theme so any edits can be easily added!

Any suggestions as to the easiest method of displaying this as a group of buttons?

Thanks in advance,
Alex

The wrong event is started from a drop-down list in an ASP.NET form

I have a main ASP.NET form with multiple drop-down lists and when I open a DDL, the OnSelectedIndexChanged event of another DDL starts and not the one that I open. Besides, other events of other DDL are starting, do you know anything about it?