Skip to content
Advertisement

Create order programatically upon form submission OVERIDE PRODUCT PRICE – WooCommerce

I have a code that I want to create an order in WooCommerce programatically upon form submission.

I would like my code to determine the product price – so override the default price of the product.

Is this possible?

Not sure where I am going wrong with my code:

JavaScript

The ’90’ is the field ID of my form with the price I want to use in the order for the product.

Advertisement

Answer

Use: WC_Product::set_price() – Set the product’s active price.

https://woocommerce.wp-a2z.org/oik_api/wc_productset_price/


Next line

JavaScript

Is going to be

JavaScript

Because you had already used wc_get_product

JavaScript

Then you get

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