WooCommerce: Override product info before adding to cart Code Answer

I’ve found the following example (WooCommerce: Add product to cart with price override?) which lets the user add a product to the cart. However, it hard codes the prices directly on the cart itself.

Is there a way to make adjustments to a product instance i.e. costs, append additional user input, etc. and then add the product to the cart?

Thank you very much for everyones help.


Having another crack at explaining, as doublesharp has pointed out it’s not quite clear.

Joe clicks on a product, he then chooses various options on the product form which then calculates a custom cost after the ‘add to cart’ button is clicked but before it is added to the cart.

These options need to be completely custom as the calculations involved are outside of scope of a woocommerce ‘variable product’. What I’m trying to achieve is the customer being able to add multiple instances of the same product with various costs and info associated with it.


With regards to the first part of your question where you want to add multiple instances of a product with various costs, you can have a look at the following plugins to achieve that objective

Dynamic Pricing

Pricing Deals for WooCommerce

As for the second part of your question where you want to append additional user input to the cart. This can be done using the following steps

  1. Create a custom session and add the custom data to this session.

  2. Add the data from the custom session to the WooCommerce session.

  3. Extract custom data from WooCommerce session and insert it into cart

  4. Display custom data in Cart and Checkout page.

  5. Add custom data as metadata to the order items.

  6. Remove the associated custom data if an item is removed from the

For a more detailed on the above steps you have a look at the following link,
How to Add Custom Data to WooCommerce Order

Related Posts

© No Copyrights, All Questions are retrived from public domain.
Tutorial Guruji