{"id":108483,"date":"2021-05-19T12:50:16","date_gmt":"2021-05-19T10:50:16","guid":{"rendered":"https:\/\/de.wordpress.org\/support\/topic\/prepopulate-input-field\/"},"modified":"2021-05-19T13:14:23","modified_gmt":"2021-05-19T11:14:23","slug":"prepopulate-input-field","status":"closed","type":"topic","link":"https:\/\/de.wordpress.org\/support\/topic\/prepopulate-input-field\/","title":{"rendered":"Prepopulate input field"},"content":{"rendered":"<p>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:<\/p>\n<pre><code>add_action( &#039;woocommerce_before_variations_form&#039;, &#039;product_add_on&#039;, 9 );\nfunction product_add_on() {\n   global $product;\n   if ( 12345 === $product-&gt;get_id() ) {\n    $value = isset( $_POST[&#039;custom_text_add_on&#039;] ) ? sanitize_text_field( $_POST[&#039;custom_text_add_on&#039;] ) : &#039;&#039;;\n    echo &#039;&lt;div&gt;&lt;label&gt;&lt;span&gt;Your Name &lt;abbr class=&quot;required&quot; title=&quot;required&quot;&gt;*&lt;\/abbr&gt;&lt;\/span&gt;&lt;\/label&gt;&lt;p&gt;&lt;input name=&quot;custom_text_add_on&quot; value=&quot;&#039; . $value . &#039;&quot;&gt;&lt;\/p&gt;&lt;\/div&gt;&#039;;\n    }\n}<\/code><\/pre>\n<p>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 www.website.com\/linktoproduct?customername=XYZ<\/p>\n<p>Can anybody of you experts help me with this?<\/p>\n<p>Thanks and regards!<\/p>\n","protected":false},"template":"","class_list":["post-108483","topic","type-topic","status-closed","hentry","topic-tag-functions","topic-tag-php","topic-tag-woocommerce"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/de.wordpress.org\/support\/wp-json\/wp\/v2\/topic\/108483","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/de.wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/de.wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/de.wordpress.org\/support\/wp-json\/wp\/v2\/topic\/108483\/revisions"}],"wp:attachment":[{"href":"https:\/\/de.wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=108483"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}