Title: Get Order
Last modified: March 27, 2023

---

# Get Order

 *  Resolved [guglielmirent](https://wordpress.org/support/users/guglielmirent/)
 * (@guglielmirent)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/get-order/)
 * Hello, I hope your plugin can help me I am creating a form within the view-order/
   number-order page, for uploading additional documents, I would like the current
   order number to appear in the form. is this possible?
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fget-order%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 14 replies - 1 through 14 (of 14 total)

 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/get-order/#post-16598563)
 * Hello [@guglielmirent](https://wordpress.org/support/users/guglielmirent/)
 * Thank you very much for using our plugin. Where is stored the order number, and
   how to obtain it? For example, if the item number is stored in a database, how
   to identify an order number from the other?
 * Best regards.
 *  Thread Starter [guglielmirent](https://wordpress.org/support/users/guglielmirent/)
 * (@guglielmirent)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/get-order/#post-16598647)
 * I don’t understand your answer
 *  Thread Starter [guglielmirent](https://wordpress.org/support/users/guglielmirent/)
 * (@guglielmirent)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/get-order/#post-16598705)
 * Honestly, woocommerce orders will definitely be saved in the database, the url
   is composed for order #356
   my-account/view-order/356/I don’t know where it saves
   them
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/get-order/#post-16598737)
 * Hello [@guglielmirent](https://wordpress.org/support/users/guglielmirent/)
 * Our plugin takes information from data sources (a database, CSV file, JSON structure,
   posts, taxonomies, URL parameters, ACF, server-side blocks of code, and javascript
   functions) to fill out the form fields.
 * If you want to fill in the dropdown field in the form with the orders a field
   in the form with order ids, our plugin must get them from someplace, like a database.
 * For example, assuming you want to fill the ordinicliente dropdown field in the
   form with the ids of WooCommerce orders. They are stored as the custom post types
   shop_order in the wp_posts table of the website.
   In this case, you must insert
   a recordset field in the form to read the information from the database, and 
   a link field to fill the dropdown list:
 *     ```wp-block-code
       [cf7-recordset id="orders" type="database" query="SELECT ID FROM {wpdb.posts} WHERE post_type='shop_order'"]
       [cf7-link-field recordset="orders" field="ordinicliente" value="ID" text="ID" keep-options]
       ```
   
 * Best regards.
 *  Thread Starter [guglielmirent](https://wordpress.org/support/users/guglielmirent/)
 * (@guglielmirent)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/get-order/#post-16598823)
 * Perhaps I have expressed myself wrongly, I only need to know the current order
   
   the customer is on his order page and underneath he has a pre-filled form with
 * #order number —- First name last name etc.
 * how do i enter the order number in the text field [text order number].
 * Perhaps I have expressed myself wrongly, I only need to know the current order
   
   the customer is on his order page and underneath he has a pre-filled form with
 * **order number —- First name last name etc.**
 * how do i enter the order number in the text field [text order number].
 * i tested your code and it returns the wrong order
 * i need the number of current order
    -  This reply was modified 3 years, 3 months ago by [guglielmirent](https://wordpress.org/support/users/guglielmirent/).
    -  This reply was modified 3 years, 3 months ago by [guglielmirent](https://wordpress.org/support/users/guglielmirent/).
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/get-order/#post-16599027)
 * Hello [@guglielmirent](https://wordpress.org/support/users/guglielmirent/)
 * The code I sent you previously returns the list of orders ids, the column “ID”
   in the wp_posts table corresponding to the entries with the shop_order value 
   in the “post_type” column. If you want to get the orders keys, you must read 
   them from the wp_postmeta table. The recordset and link tags would be:
 *     ```wp-block-code
       [cf7-recordset id="orders" type="database" query="SELECT * FROM {wpdb.postmeta} postmeta INNER JOIN {wpdb.posts} posts ON (postmeta.post_id = posts.ID) WHERE posts.post_type='shop_order'"]
   
       [cf7-link-field recordset="orders" field="ordinicliente" value="post_id" text="meta_value" condition="record['meta_key']=='_order_key'" keep-options]
       ```
   
 * And to fill the “your-name”, “your-surname”, and “your-email” fields with the
   first name, last name, and emails of the user associated to the order selected
   from the orders list, the link tags would be:
 *     ```wp-block-code
       [cf7-link-field recordset="orders" field="your-name" value="meta_value" condition="record['meta_key']=='_billing_first_name' && record['post_id']=='{field.ordinicliente}'"]
   
       [cf7-link-field recordset="orders" field="your-name" value="meta_value" condition="record['meta_key']=='_billing_last_name' && record['post_id']=='{field.ordinicliente}'"]
   
       [cf7-link-field recordset="orders" field="your-name" value="meta_value" condition="record['meta_key']=='_billing_email' && record['post_id']=='{field.ordinicliente}'"]
       ```
   
 * Best regards.
 *  Thread Starter [guglielmirent](https://wordpress.org/support/users/guglielmirent/)
 * (@guglielmirent)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/get-order/#post-16599097)
 * Sorry but don’t work,
 * In addition to returning an incorrect order, but a part of shortcode ==’_order_key'”
   keep-options]
 *  Thread Starter [guglielmirent](https://wordpress.org/support/users/guglielmirent/)
 * (@guglielmirent)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/get-order/#post-16599169)
 * the problem is record**[‘meta_key’]**==’_order_key'” keep-options]
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/get-order/#post-16599171)
 * Hello [@guglielmirent](https://wordpress.org/support/users/guglielmirent/)
 * The problem is that the forum editor is converting the characters. I’m including
   the code as an image to avoid it:
 * ![](https://i0.wp.com/resources.developers4web.com/cff/tmp/2023/03/27/rLb7MWnADc.
   png?ssl=1)
 * The `[` and `]` symbols are used to open and close the tags, but they must be
   used into the tag in their encoded version.
 * Best regards.
 *  Thread Starter [guglielmirent](https://wordpress.org/support/users/guglielmirent/)
 * (@guglielmirent)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/get-order/#post-16599209)
 * OK but it always returns the wrong order, I am on order #356 and in the text 
   field is order #307
 * > [View post on imgur.com](https://imgur.com/a/leqQm3L)
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/get-order/#post-16599444)
 * Hello [@guglielmirent](https://wordpress.org/support/users/guglielmirent/)
 * The tag below returns the list of the existing the orders, but not the current
   order:
 *     ```wp-block-code
       [cf7-recordset id="orders" type="database" query="SELECT * FROM {wpdb.postmeta} postmeta INNER JOIN {wpdb.posts} posts ON (postmeta.post_id = posts.ID) WHERE posts.post_type='shop_order'"]
       ```
   
 * As you are using it to fill the text field, it is assigning the first item from
   the list.
 * If you are in the order page after login, and you want to access to current order
   id the recordset tag would be:
 *     ```wp-block-code
       [cf7-recordset id="orders" type="database" query="SELECT * FROM {wpdb.postmeta} WHERE post_id={post.id}"]
       ```
   
 *  And the link tags:
 * ![](https://i0.wp.com/resources.developers4web.com/cff/tmp/2023/03/27/2.png?ssl
   =1)
 * Best regards.
 *  Thread Starter [guglielmirent](https://wordpress.org/support/users/guglielmirent/)
 * (@guglielmirent)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/get-order/#post-16605153)
 * > [View post on imgur.com](https://imgur.com/a/UroPO6F)
 * I tested your code, but it returns the number 8 which is the id of the page my
   account
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/get-order/#post-16605406)
 * Hello [@guglielmirent](https://wordpress.org/support/users/guglielmirent/)
 * If you want to get the latest piece in the URL path you can includes a script
   block and recordset tag as follows:
 *     ```wp-block-code
       <script>
       var orderid = 0;
       jQuery(window).on('load', function(){
           orderid = document.location.href.replace(/\/+$/, '').split('/').pop();
           cf7_datasource_recordset_reload('orders');
       });
       </script>
       [cf7-recordset id="orders" type="database" query="SELECT * FROM {wpdb.postmeta} WHERE post_id={var.orderid}"]
       ```
   
 * The link tags do not vary.
 * Best regards.
 *  Thread Starter [guglielmirent](https://wordpress.org/support/users/guglielmirent/)
 * (@guglielmirent)
 * [3 years, 3 months ago](https://wordpress.org/support/topic/get-order/#post-16605553)
 * Thank you very much, the problem is solved 🙂

Viewing 14 replies - 1 through 14 (of 14 total)

The topic ‘Get Order’ is closed to new replies.

 * ![](https://ps.w.org/cf7-data-source/assets/icon-256x256.gif?rev=2508392)
 * [Data Source for Contact Form 7](https://wordpress.org/plugins/cf7-data-source/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/cf7-data-source/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/cf7-data-source/)
 * [Active Topics](https://wordpress.org/support/plugin/cf7-data-source/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/cf7-data-source/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/cf7-data-source/reviews/)

 * 14 replies
 * 2 participants
 * Last reply from: [guglielmirent](https://wordpress.org/support/users/guglielmirent/)
 * Last activity: [3 years, 3 months ago](https://wordpress.org/support/topic/get-order/#post-16605553)
 * Status: resolved