Total : 0.00 €

Setting up taxes in Woo Price Calculator

How to set up taxes

 

 

As you can see from the picture above, you will notice that there are the normal product price and the total price with tax applied in the Cart. Without the tax, the total price would be the same as the product price.

Continue Reading

WooPrice Calculator: Changing the price and changing numeric fields format

If you see wrong formatting while you are uploading your Excel file on WooPrice Calculator, never mind and please go ahead because there are numerous ways provided which allow you to change the price and numeric format after you have uploaded your Excel file.

- Changing the price format

If you want to change the price format, you have to change the WooCommerce price format:

  1. From your Wordpress back-end click on "WooCommerce"
  2. Click on "Settings" 
WooCommerce Price Formatting

Continue Reading

Clearing the cache

If you added or changed CSS or Javascript code and you don't see any changes in your website front-end, this means you need to clear the cache.

Q: Yes, but what cache do I need to clear?

It depends on what plugins you have installed in your Wordpress website, but generally speaking:

  • You need to clear the cache of the browser (Whatever your website has been built on)
  • You need to clear the cache of your Wordpress cache plugins.

Q: I'm a web designer, how do I clear the cache of my browser?

For Chrome check out this video. For Firefox just hint CTRL+F5 on Windows and Linux. On Apple hint Apple+R.

You need to do this every time you change CSS or Javascript code on your website.

Continue Reading

Adding prefix/suffix to price in WooCommerce & WooPrice Calculator

If you would like to add prefix or suffix to your product price, you can use the hook "woocommerce_get_price_html" as following:

function change_product_price_html($price){
  	
	$newPrice 	 = "Text Before Price";
  	$newPrice 	.= $price;
  	$newPrice	.= "Text After Price";
  
	return $newPrice;
}
  
add_filter('woocommerce_get_price_html', 'change_product_price_html');

 

Continue Reading

Showing calculator using Shortcode

If you want to show your calculator in a Wordpress page, you can use the WoooCommerce shortcode [product_page id="PRODUCT_ID"] to do that.

In this example, it is explained how to show the calculator on a Wordpress "Page" (But of course you can add this shortcode wherever you want on your Wordpress website).

  1. In your WP-admin click on "Pages" > "Add new" (But if you have an existing page, edit it)
  2. Add the shortcode [product_page id="PRODUCT_ID"] ensuring that you are using the "Text" editor as in some cases the "Visual" editor can change your text and make your shortcode unable to work:

    shortcode product page

    Continue Reading

How to check WooCommerce add to cart price

If you want to check the WooCommerce product price before your customer adds a product to the cart, you cannot use the "woocommerce_add_to_cart_validation" function. But the following is a really smart trick about how to do that:

This piece of code checks if the price is 0, in this case, an error message will be shown and the product will be removed from the cart, so the customer cannot buy it.

To make this piece of code work, you need to append it to your "functions.php" file, located in your "/wp-content/themes/YOUR_THEME/ path":

/* Price must be different from 0 to be added to the cart */
function filter_custom_wpc_add_to_cart_callback($cart_item_key, $product_id, $quantity, $variation_id, $variation, $cart_item_data){
	global $woocommerce;
	
	foreach(WC()->cart->get_cart() as $cart_item_key => $values){
		$cartItemPrice		= $values['data']->get_price();
		
		if($cartItemPrice == 0){
        
        	/* Showing the error message */
			wc_add_notice("Sorry but it's not possible to add this product to cart", "error");
            
            /* Removing the product from the cart */
			$woocommerce->cart->remove_cart_item($cart_item_key);
			
			return;
		}
	}
	
}
add_action('woocommerce_add_to_cart', 'filter_custom_wpc_add_to_cart_callback', 20, 6);

 

Continue Reading

More validation using WooPrice Calculator & WooCommerce

If you want to do more validation before adding a product to the cart (For example if you want to check "height + width" is less than a predetermined value), then this article is for you.

Using WooPrice Calculator you can set a minimum and maximum values for each field but you cannot validate more complex rules.

With Wordpress, WooPrice Calculator and WooCommerce this is really simple by using filters. You can use the filter "woocommerce_add_to_cart_validation" to do that.

For example, if you want check "height + width" must be less then 2000, you can append this new PHP function to your "functions.php" file, located in "/wp-content/themes/YOUR_THEME/": path.

function filter_custom_wpc_add_to_cart_validation($bool, $product_id, $quantity){
	if($product_id == 40){
		$width		= $_REQUEST['aws_price_calc_1'];
		$height		= $_REQUEST['aws_price_calc_2'];
		
		if(($width+$height) >= 2000){
			wc_add_notice("Width and Height are greater then 2000 mm", "error");
			
			return false;
		}
	}
	
	return true;
}
add_filter('woocommerce_add_to_cart_validation', 'filter_custom_wpc_add_to_cart_validation', 20, 3);

 

Continue Reading

Cart

Total : 0.00 €