• Resolved rapsli

    (@rapsli)


    Hi
    Here is my workflow: 7 days after completion of an order I’m sending out an e-mail asking the user to submit a review of the shop. The user clicks on a link that will take him to the form. Ideally the form has already the name and his E-mail address filled out. Is this possible?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Gemini Labs

    (@geminilabs)

    Do you want to pre-populate and hide the name and email fields, or just pre-populate them?

    Also, if you require that customers are logged in to submit a review, then you can hide the name and email field (using the hide option on the shortcode of block) and Site reviews will automatically use the email and display name of the logged in user.

    • This reply was modified 2 years, 9 months ago by Gemini Labs.
    Thread Starter rapsli

    (@rapsli)

    I think to force the user to login would make it too hard to submit a review. Prepopulate would actually just be enough, what would be even better would be to connect it with an order, like

    mysite.com/site-review?order=234234&[email protected]

    The form would then be prepopulated and the combination of order and e-mail would give some kind of security.

    Plugin Author Gemini Labs

    (@geminilabs)

    Here is an example of pre-populating the email field based on the email value of the URL Query: https://pastebin.com/UDBQeTzM

    You could extend this example to pre-populate the name field in the same way.

    Auto-assigning the review to the product(s) in the order would be a little more work. You would first need to get the product IDs from the order number, and then set the value of the hidden assigned_posts field with those values. For example, if you are using Woocommerce then this would look something like this:

    $order = wc_get_order(filter_input(INPUT_GET, 'order'));
    if ($order) {
        $productIds = [];
        foreach ($order->get_items() as $item) {
            $productIds[] = $item->get_product_id();
        }
        $fields['assigned_posts']['value'] = implode(',', array_filter($productIds));
    }
    Thread Starter rapsli

    (@rapsli)

    thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Prepopulate form’ is closed to new replies.