Okay
  Public Ticket #2113852
MySQL query to get product and user ID
Closed

Comments

  • Carlos Silva started the conversation

    Hello,

    I have a WooCommerce site and I have added the WooCommerce Product Add-ons plugin on it and purchased the wpDataTables plugin as well.  I am trying to achieve the following:

    When a client makes a purchase, s/he gets to fill in additional fields in the product section, in this case, a field called 'Help needed' is filled by the client. The client makes a purchase and a subscription starts.

    What I would like to do is to allow the client to go into the dashboard and be able to 'edit' the information that s/he has added to the field.

    I have managed to add a new section in the client's dashboard and I would like to use wpDataTables to displays this field as many times as the number of subscriptions s/he has.

    I have tried with some success to make it work but the query only returns ALL the fields from every user in the site instead of only the one from each logged in client.  I know that the Order ID number gets stored in the wp_usermeta table under '_wcs_subscription_ids_cache' for example: a:2:{i:0;i:6302;i:1;i:6288;} however I don't know how to construct the MySQL query so that I select the individual order numbers per client.

    The query I am using is:


    SELECT * FROMwp_woocommerce_order_itemmetawhere meta_key = 'Help needed'


    So I guess adding a way to distinguish the users and get the user ID is the bit I am missing.

    Can you please help

    Many thanks,

    Carlos

  •  472
    Isidora replied

    Hi Carlos,
    Thank you for your purchase.

    You need to create query where you will pull user id from those tables and then try to use our placeholder %CURRENT_USER_ID% in that query.

    Please note: Using this plugin feature requires at least a basic knowledge of SQL. It is assumed that you can create the table in some MySQL data manager (e.g., PHPMyAdmin, MySQL Workbench), and prepare a SQL query that will return the data you need.  Please be advised that preparing MySQL queries for you is not included in the plugin support.

    Thank you for understanding.

    Best regards.

    Kind Regards, 

    Isidora Markovic

    wpDataTables: FAQFacebookTwitterFront-end and back-end demoDocs

    Amelia: FAQFacebookTwitter |  Amelia demo sites | Docs

    You can try our wpDataTables add-ons before purchase on these sandbox sites:

    Powerful FiltersGravity Forms Integration for wpDataTablesFormidable Forms Integration for wpDataTables