• Resolved guglielmirent

    (@guglielmirent)


    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 to see the link]

Viewing 14 replies - 1 through 14 (of 14 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @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

    (@guglielmirent)

    I don’t understand your answer

    Thread Starter guglielmirent

    (@guglielmirent)

    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

    (@codepeople)

    Hello @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:

    [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

    (@guglielmirent)

    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

    Plugin Author codepeople

    (@codepeople)

    Hello @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:

    [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:

    [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

    (@guglielmirent)

    Sorry but don’t work,

    In addition to returning an incorrect order, but a part of shortcode ==’_order_key'” keep-options]

    Thread Starter guglielmirent

    (@guglielmirent)

    the problem is record[‘meta_key’]==’_order_key'” keep-options]

    Plugin Author codepeople

    (@codepeople)

    Hello @guglielmirent

    The problem is that the forum editor is converting the characters. I’m including the code as an image to avoid it:

    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

    (@guglielmirent)

    OK but it always returns the wrong order, I am on order #356 and in the text field is order #307

    Plugin Author codepeople

    (@codepeople)

    Hello @guglielmirent

    The tag below returns the list of the existing the orders, but not the current order:

    [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:

    [cf7-recordset id="orders" type="database" query="SELECT * FROM {wpdb.postmeta} WHERE post_id={post.id}"]

    And the link tags:

    Best regards.

    Thread Starter guglielmirent

    (@guglielmirent)

    I tested your code, but it returns the number 8 which is the id of the page my account

    Plugin Author codepeople

    (@codepeople)

    Hello @guglielmirent

    If you want to get the latest piece in the URL path you can includes a script block and recordset tag as follows:

    <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

    (@guglielmirent)

    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.