WooCommerce
May 27, 2020

Set a specific product price conditionally on Woocommerce single product page & cart

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

Code goes in function.php file of your active child theme (or active theme).

Related Post


Add an Empty Cart button in WooCommerce

WooCommerce default not provide Empty Cart button but we can two simple steps to add Empty Cart button on cart page. The first one is to add below code in your functions.php file (this file is located in your theme folder): Second step is to add Empty Cart Button after Apply Coupon button. This code […]

Only Allow 1 Product in the Cart WooCommerce

We can set add to cart limit on WooCommerce cart using woocommerce_add_to_cart_validation filter. Add below code on functions.php file to limit your WooCommerce Cart to just 1 product.

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.

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 […]

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 […]

Add Product to Cart Programmatically Woocommerce

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


Leave a Reply

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