• Resolved elcompe

    (@elcompe)


    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><input name="custom_text_add_on" value="' . $value . '">
    </div>';
        }
    }

    Now I want to prepopulate this field with a Query-String. I want to send individual links to customers by email which include already the value of this field. Something like http://www.website.com/linktoproduct?customername=XYZ

    Can anybody of you experts help me with this?

    Thanks and regards!`

Viewing 2 replies - 1 through 2 (of 2 total)
  • laceyrod

    (@laceyrod)

    Automattic Happiness Engineer

    Hi @elcompe

    Thanks for reaching out.

    This would require more complex development. I’ll go ahead and leave this thread open for a while in case anyone else wants to chime in, but in the meantime, I can also recommend the following resources for more development-oriented questions:

    – WooCommerce Slack Community: https://woocommerce.com/community-slack/
    – Advanced WooCommerce group on Facebook: https://www.facebook.com/groups/advanced.woocommerce/

    Cheers!

    laceyrod

    (@laceyrod)

    Automattic Happiness Engineer

    Hi there,

    This thread has been inactive for a bit, so I’m going to mark it as Resolved now for the overall health of the forums. Please feel free to check out the resources listed above for additional assistance.

    If you’d like to hire someone to help, I can also recommend the following services: https://woocommerce.com/customizations/

    Cheers!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Prepopulate input field’ is closed to new replies.