WooCommerce
May 27, 2020

Change cart item prices in WooCommerce

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 code:

The Code goes in function.php file of your active child theme (or theme) or also in any plugin file.

Note: you can increase the hook priority from 20 to 1000 ( or even 2000 ) when using some few specific plugins or others customizations.

Resource


Related Post


Enable / Disable “Ship to a Different Address” WooCommerce

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.

Add a select field that will change price in Woocommerce simple products

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).

Set cart item price from a hidden input field custom price in Woocommerce

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.

Disable Payments on WooCommerce

You are using WooCommerce for your eCommerce website. A thing is you want to disable payment on your website, but disabling in WooCommerce payment setting WooCommerce > Settings > Payments will not work and display There are no payment methods available. Add this code to functions.php file of theme.

Reordering Cross-Sells and Up-Sells in WooCommerce

Cross-sells and Up-sells in WooCommerce are a very powerful tool to give suggestions to your customers. You might know that most people who buy product A will probably need product B as well, and you want the customer to know that. How do you do it? You use cross-sells and up-sells. These products are shown […]

WooCommerce Remove the Additional Information and Order Notes fields

We can remove the Additional Information and Order Notes fields in WooCommerce checkout page with 2 filters that you add to functions.php file.


Leave a Reply

Your email address will not be published. Required fields are marked *