We can add product to WooCommerce cart using add_to_cart() function with $product_id. Code goes in function.php file of your active child theme (or active theme).
We can remove product from WooCommerce cart using remove_cart_item() function with $product_id. Code goes in function.php file of your active child theme (or active theme).
To make the default “Ship to Different Address” checkbox checked in WooCommerce Checkout page, add below code on functions.php file. Disable “Ship to A Different Address” on WooCommerce Checkout, add below code on functions.php file.
To add a select field in simple products (like in variable products) that will update base price depending on the dopdown selected value, try this: Code goes in function.php file of your active child theme (or active theme).
Update 3 (Only for a defined product ID) To make it work as you want to change the simple products prices only on single product pages (without altering archives product prices, related product prices, upsells and cross-sells) if any cart item doesn’t belong to a specific product category. Then you will need all this following […]
We need to use 2 different hooks: The first one just as yours without trying to change the price in it. The second one where you will change your cart item price. The code: Code goes in function.php file of your active child theme (or theme) or also in any plugin file.
First for testing purpose we add a price in the hidden input field as you don’t give the code that calculate the price: Then you will use the following to change the cart item price (WC_Session is not needed): Code goes in function.php file of your active child theme (or active theme). Tested and works.
WooCommerce Set Custom Product Price When Adding To Cart – In this article, we’ll see how we can override the price of product when adding the product into cart. With WooCommerce version 3.0+ you need: To use woocommerce_before_calculate_totals hook instead. To use WC_Cart get_cart() method instead To use WC_product set_price() method instead Here is the […]
We can remove the Additional Information and Order Notes fields in WooCommerce checkout page with 2 filters that you add to functions.php file.