Updating product prices with WooCommerce’s default options has certain limitations. You can only change the prices to a fixed or percentage amount, but there is no possibility to bulk edit product prices by formula in the WooCommerce editor. In fact, one of the most common questions of WooCommerce store managers is how to bulk edit product prices by formula in WooCommerce.
If you also want to change the price of your products according to a specific formula and are looking for an ideal solution, read this post. Here, first, we will teach you how to use coding for bulk editing product price by formula, and then we will introduce you to WooCommerce products bulk edit pro plugin, with the help of which you can use any formula to bulk edit your product prices.
Use coding to bulk edit product prices by formula
If you are familiar with coding in WordPress, you can use the following guide to bulk edit product prices by any formula. Before you use this code to change the product prices, keep the following points in mind:
- To add code to your WordPress site, use one of the following methods:
- Create a child theme and save the code in the functions.php theme file located in the Appearance ➡ Theme File Editor path.
- Use the Code Snippets plugin to add your code to WordPress.
- Before you add any codes to your site, be sure to back up the data so that you can restore the site to its previous state in case of any problems.
Now you can get help from the following coding for bulk editing product price by formula for WooCommerce:
function filtering_product_prices( $price, $product ) {
$price = (float)$price;
$new_price = $price * 1 ;
return ceil($new_price);
}
add_filter('WooCommerce_product_get_price', 'custom_price', 90, 2 );
add_filter('WooCommerce_product_get_regular_price', 'custom_price', 90, 2 );
add_filter('WooCommerce_product_variation_get_regular_price', 'custom_price', 99, 2 );
add_filter('WooCommerce_product_variation_get_price', 'custom_price' , 99, 2 );
add_filter('WooCommerce_variation_prices_price', 'custom_variation_price', 99, 3 );
add_filter('WooCommerce_variation_prices_regular_price', 'custom_variation_price', 99, 3 );
function custom_price( $price, $product ) {
wc_delete_product_transients($product->get_id());
return filtering_product_prices( $price, $product );
}
function custom_variation_price( $price, $variation, $product ) {
wc_delete_product_transients($variation->get_id());
return filtering_product_prices( $price, $product );
}
In order to be able to apply the desired changes to the product price using a formula, you must change the new price variable, which is highlighted in yellow, to your desired formula. Let’s give some examples to make it clear to you.
Example 1: Cut the regular price by half
To cut all regular prices by half, simply replace the yellow highlighted line below:
$new_price = $price * 0.5;
Example 2: Increase the regular prices of the Accessories category by 25.
To make such a change, replace the following code:
if (has_term( 'accessories', 'product_cat' )) {
return ceil((float)$price + 25);
}
Example 3: Decrease all products in the Accessories category by 10% and increase the price of Hats by one-third.
To do this, you need to make the below changes:
if (has_term( 'accessories', 'product_cat' )) {
return ceil((float)$price *1.1);
} elseif (has_term( 'hats', 'product_cat' )) {
return ceil((float)$price*4/3);
}
Example 4: Decrease the price of all products cheaper than $100 by 15.
Use the below code to make this change:
if ( $price < 100 ) {
return ceil((float)$price-15);
}
Use WooCommerce products bulk edit pro plugin to bulk edit product prices by formula
WooCommerce products bulk edit plugin provides you with the most useful tools and options which is needed to bulk edit any product features. By getting help from this plugin, you can easily filter your products and then make any changes in their WooCommerce fields.
One of the important uses of this plugin is to bulk edit product prices by formula for WooCommerce. Making these changes on your WooCommerce site is possible by following the 3 simple steps:
Step 1: Install WooCommerce products bulk edit pro plugin
The first step to using the WooCommerce products bulk edit pro plugin is to download and install it on your WordPress website.
After installing and activating the plugin, you will see its bulk editing option in the WordPress dashboard. Then, by pressing Woo Products, you can visit the main page of this bulk editing plugin..
WooCommerce Product Bulk Edit Plugin
The easy way to bulk edit product prices by formula in WooCommerce
Step 2: Filter the desired products
On the main page of the WooCommerce product bulk edit pro plugin, a list of all products is observed with a comprehensive toolbar designed at the top of the table. The first icon in this toolbar is used for opening the Filter Form.
As you may notice in the picture below, the Filter Form has been divided into eight sections, providing all the WooCommerce fields for filtering the products.
You can use this form to filter your desired products based on any value, like stock quantity, price range, category, etc. In the following example, we will show you how to use these effective Filter Form before bulk editing product price by formula.
Step 3: Bulk edit product prices by formula
After filtering the products, you have to follow the below instructions to bulk edit product price by formula for WooCommerce:
- Mark some of the products in the product table to select them for bulk editing their prices.
- Open the Bulk Edit form by clicking on the icon illustrated below:
- In the Bulk Edit form, go to the Pricing tab.
- In front of the Regular Price, there are three boxes.
The first box is a list of operators:
- Set New: Set new value for product price.
- Clear Value: clear or remove product price value.
- Formula: Change product price value by formula.
- Increase by Value: Increase product price by value.
- Decrease by Value: Decrease product price by value.
- Increase by %: Increase product price by percentage.
- Decrease by %: Decrease product price by percentage.
- Increase by Value (From sale): Increase product price by value based on product sale value.
- Increase by %(From sale): Increase product price by percentage based on sale value.
If you choose Formula from the drop-down list in this box, you can write a formula in the next box.
You can use all mathematical operators to write a customized formula, including:
- Multiplication (*)
- Division (/)
- Addition (+)
- Subtraction (-)
Note: By choosing Increase/ Decrease by value/%, you can add or subtract any fixed/percent amount from the current value. It is also possible to bulk edit the regular price based on the sale price by selecting Increase by Value/% (From sale). The same options are available for Sale Prices as well.
The last box is used to round the price if needed.
- After writing the formula, you need to press the Do Bulk Edit button to let the plugin update the regular prices of the selected products based on it.
To help you write the formula correctly and exactly based on your needs, we are going to make some examples in the following.
Bulk Edit WooCommerce simple product price by formula
Simple products are the most popular types in WooCommerce online stores and store managers usually need to update their prices. The steps for WooCommerce bulk pricing of simple products are exactly as we described before. However, we will review it briefly to make it clear.
- Go to the Filter Form.
- Open the Type tab and locate the Product Type field.
- Choose Simple Product from the list.
- Press Get Product to see a list of Simple products in the table.
- Mark some products on the table.
- Press the Bulk Edit button.
- Go to the Pricing tab in the Bulk Edit form.
- Choose Formula from the list of Operators and insert your formula in the Regular price or Sale Price fields.
- Press Do Bulk Edit to change product price.
Bulk edit variable product price by formula for WooCommerce
Variable products in WooCommerce allow store managers to offer multiple variations for a single product. The advantage of variable products is the option to set different prices for each variation. It helps customers to compare different features of a single product on the same page and then select their favorite one. However, when it comes to WooCommerce bulk update prices of variable products, store owners face many problems. Especially when there are a lot of variations in the store and they need to change their prices regularly.
The good news is that the WooCommerce bulk products editing plugin solved this problem and you can use it to bulk price update WooCommerce product variations by following the below simple steps:
- Filter variable products:
Filtering variable products is simply possible by selecting the right option from the list of Product Type options. However, the advanced Filter Form of our plugin allows you to go further and filter the exact variations you need.
For example, if you just want to change the WooCommerce product price of Blue and Large variations, you can easily go to the Categories/Tags/Taxonomies tab, then set the right terms – Blue and Large- in front if each attribute like Color and Size.
Now, you can press Get Products to see a list of all Blue-Large products in the table.
- Show and select variations in the table
In the next step, you have to click the Manage Variations tool on the toolbar and then select the Show Variations option. When you enable this option, all variable products with their variations will be displayed in the table in separate rows.
Now, you need to mark the exact variations that you need to bulk update WooCommerce product price by formula.
- Bulk change product price by formula for WooCommerce
The final step is to use the Bulk Edit form and set your formula in the Regular Price or Sale Price fields as we described before.
As soon as pressing on the Do Bulk Edit button, the prices of all selected variations will be updated.
Example 1: Increase the regular price of products in the Accessories or Clothing categories by formula
To successfully fulfill the purpose of this example, the below steps are required:
- Go to the Filter Form and open the Categories/Tags/Taxonomies tab. Choose OR from the first combo box of the product categories field, then select Accessories and Clothing from the list of categories in the next box.
- Press the Get Products button to filter the products, then mark any of them in the table and open the Bulk Edit form.
As we mentioned above, you need to go to the Pricing tab, choose Formula from the first combo box, and write the below formula in the next box:
(X * (0.40))+20)
Please note that in all formulas used in this plugin, X represents the current value of product prices.
To round the prices, you can choose one of the default options of the third combo box. For example, we chose 99.
Now, by pressing the Do Bulk Edit button, all prices of selected products are increased by 10%, as we expected.
Example 2: Decrease the regular prices of the products that their stock quantities range from 5 to 20 by one-third
The Steps to reach the purpose of this example are as follows:
- Open the Filter Form and go to the Stock tab, find the Stock Quantity field, and set 5 and 20 for the first and second boxes, respectively.
- Click on the Get Products button to see the filtered product in the table.
- Mark the checkbox next to the ID to select all the products.
- Open the Bulk Edit form and go to the Pricing tab.
- After choosing the formula, write the below formula in the second box:
X-(X/3)
By clicking on the Do Bulk Edit button, you can see that all regular prices have been changed according to the written formula.
WooCommerce Product Bulk Edit Plugin
The easy way to bulk edit product prices by formula in WooCommerce
Conclusion
As you know, editing the price of WooCommerce products individually is a difficult and time-consuming task. It is true that WooCommerce allows you to bulk edit product prices by its default editor, but it is not flexible enough. Especially when you want to change the price of products based on a certain formula, this is not possible without using coding or the WooCommerce products bulk edit pro plugin. In this article, we have provided a complete guide to using both of these methods. If you need more information about using the WooCommerce products bulk edit pro plugin, please leave a comment.