Skip to content
Advertisement

Pass custom product text field as cart item data in WooCommerce

The goal here is to have a text field on the product page.

The customer fills it in and adds to cart. The text is added to the product and included in the cart and on the checkout and on the order.

The field works and the validation works fine, but the text is not included / transferred to the cart, checkout and order.

Here’s the code:

JavaScript

Advertisement

Answer

I have copied the code and done a quick test and could found that you are missing underscore _ for the field name in two functions. You were using $_POST['custom_text_add_on'] instead of $_POST['_custom_text_add_on'] in the product_add_on_cart_item_data function. That was just a mistake.

JavaScript

Hope you got the issue resolved

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement