Add Custom Input Field on Woocommerce Cart Page - php

I've been developing a WooCommerce site and I have a task where I have stuck. I need to add an extra custom input field into the cart items table.
Like for example, if a person orders '2000 youtube views' package, then right below the item name, I want the user to input his Youtube video URL.
I know I can add custom input fields on Product Page and can simply make them display on the Cart Page. But I want to take user input data onto the Cart Page. Each cart item will have a custom input field. So far, I have researched a lot but didn't have any success for my solution. All I found that to print the custom input field data onto the cart page added on the Product Page.
Any help would be appreciated

I've had this problem also. I've solved it with this. Adding the fields on the cart page like you did but with jQuery receive those values and dynamicly transfer them with a GET request, ( adding them to the submit button ) and $_GET fill them in the checkout page in a hidden input type.

Related

With Gravity Forms Product Add-ons + Woocommerce, is possible to create an add to cart link?

Here's the scenario:
I have a product using gravity forms product add-ons with prepopulated fields in the URL.
Example: website.com/product/book/?title=BookTitle&price=9.99
When a user clicks the link, the fields are prepopulated into the product so when the user clicks the add to cart button on the product page, the details are injected into the product and displayed on the cart & checkout pages. This part works well.
Is it possible to create an add-to-cart link that includes the URL parameters?
Example: website.com/cart/?add-to-cart=20762&title=BookTitle&price=9.99
I know this probably doesn't work like this, but ideally, I want a simple add to cart button that adds the product to the cart and also includes the URL parameter information.

Dynamically pass a Product ID as the main Product Field on a Gravity Form (Product Add On)

I've got a great form set up to allow the building of a complex product and then add it to the cart (using the GForms Product Add on). All lif this is perfect on the actual Woocommerce product page.
What I'd love to do is have this form embedded on a page and populate the Product ID dynamically, so that the form still picks up the product details and will add the new Item to the cart just as it does on a shop page. Having it on its own page (or on any page of the site) will allow us to offer a larger, focused experience to select all the options.
I've been looking into the code and the docs but I can't seem to make it work. The code references product_id everywhere, but the dynamic field option is name. So is this possible? Thanks!
If the data you are attempting to map is simple then the following snippet plus Gravity Forms default {embed_post} and {custom_field} merge tags can get you there:
https://gravitywiz.com/dynamic-products-via-post-meta/
If your data is more advanced (like mapping product attributes), check out Gravity Form Populate Anything:
https://gravitywiz.com/documentation/gravity-forms-populate-anything/

Is there any way to 'manually' send data to the [woocommerce_checkout] page?

How can I send data from a custom page to a woocommerce checkout page?
I have a custom cart page, that shows the user the products selected in another custom page (by custom I mean a page coded from 0, without using the auto generated pages of woocomerce).
From this cart page, I want to send the user to the checkout page, but this time I want to use the page generated using the short code [woocommerce_checkout] but I don't know how to send the data collected in cart to this checkout page nor the structure of it.
I wanted to try something like this, https://quadmenu.com/add-to-cart-with-woocommerce-and-ajax-step-by-step/ to manually create the woocomerce cart object and then send the user to the woocomerce page, but the form used as an example in that case has nothing to do with the form in my product page.

How to validate the Add new product page in woocommerce?

I would like to validate every field of the add products page in Woocommerce since the users are not entering complete details and submitting the page.
This results in validation of the fields of the add products page manually and results in data Misinterpretation.
How to validate the add products form in woocommerce?
Any help will be appreciated.

Woocommerce separate orders when add to cart is clicked

I put a few custom fields as part of the add to cart form and I'm trying to separate the orders every time the add to cart button is clicked.
Right now when I order an item and fill up the form I get 1 item added to cart and if I fill up the form again with different data and click add to cart the new data gets lost and the count of the first product is increased to 2.
At the same time when viewing the cart page I want to be able to increase the count of separate orders when changing the count and clicking update chart.
What hook can I use to accomplish this? Thanks.
Don't add fields directly to add to cart form.
From admin panel make your product variant product. There you can add product variants like color, size etc. You can add your own variations also. This will automatically create extra fields to add to cart field.
Then, your products will be added separately.
Check out the link:
https://docs.woothemes.com/document/variable-product/

Categories