Home › Forums › ACF PRO › Woocommerce custom field item cart › Reply To: Woocommerce custom field item cart
Hi @wax
If you want to add the form to the product page, then you need more advanced code and logic. Unfortunately, I can only guide you with the logic. I’m sorry about that.
Like my answer in your other thread, you can use the repeater field and add it to the front-end by using this code:
acf_form(array(
'form' => false,
));
This will strip the ACF’s form tag and let you add it in the add to cart form instead.
When a user clicked the add to cart button, you can get the repeater value by using this code:
$repeater_values = $_POST['acf']['field_1234567890abc'];
Where ‘field_1234567890abc’ is the field key of the repeater. At this time, you need to modify the cart content so it can hold the extra information. Here’s an example how to do it: http://wordpress.stackexchange.com/questions/138595/add-custom-variable-to-cart-content. I’m not sure if it will work or not, though. Please consult to WooCommerce for more information.
I’m not sure if you need to modify the order or not after this process, but I guess you can try it out to find out 🙂
Hope this makes sense.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.