Support » WooCommerce » Prepopulate input field

  • I created a custom input field on a single woocommerce product page. The value of custom input field is saved into cart item data. Thats the code I put into functions.php:

    add_action( 'woocommerce_before_variations_form', 'product_add_on', 9 );
    function product_add_on() {
       global $product;
       if ( 12345 === $product->get_id() ) {
        $value = isset( $_POST['custom_text_add_on'] ) ? sanitize_text_field( $_POST['custom_text_add_on'] ) : '';
        echo '<div><label><span>Your Name <abbr class="required" title="required">*</abbr></span></label><p><input name="custom_text_add_on" value="' . $value . '"></p></div>';

    Now I want to prepopulate this field with a Query-String. I want to send individual links to customers which include already the value of this field. Something like

    Can anybody of you experts help me with this?

    Thanks and regards!

Ansicht von 1 Antwort (von insgesamt 1)
  • Moderation Note:

    I have closed this thread because you asked your question in English in the German support forums. To keep the threads accessible for users who don’t speak English, please ask your question in German or post it in the plugin support forum. Thanks for your understanding.

Ansicht von 1 Antwort (von insgesamt 1)
  • Das Thema „Prepopulate input field“ ist für neue Antworten geschlossen.