Website Building » WooCommerce » How Do I Add a Sale in WooCommerce?

How Do I Add a Sale in WooCommerce?

Last updated on January 20, 2023 @ 6:01 am

Adding a sale in WooCommerce is simple and straightforward.

To add a sale through the WordPress admin panel, log in and go to Products > Add New. Enter the product name, description, and other details as usual. On the right hand side of the page, you’ll see the Product Data box.

In this box, select the Regular Price field and enter the new, lower price. Then, check the boxes for “Catalog” and “Search” under Visibility.

PRO TIP: If you are unfamiliar with code or are not comfortable making changes to your site, we recommend that you consult with a professional developer or designer. Making changes to your site can be risky and may result in unintended consequences if not done properly.

If you want to add a sale by using the WooCommerce REST API, you’ll need to first set up an API key (and secret). To do this, log in (to your WordPress site) and go (to WooCommerce > Settings > Advanced > REST API).

With your API key (and secret) handy(?), open up a terminal or command prompt (and) enter the following:

curl -X POST \
-H "Content-Type: application/json" \
-H "Cache-Control: no-cache" \
-d '{"sale_price":"7","regular_price":"10","date_on_sale from":"","date _on _sale _to":"","product":{"id":1234,"title":"My Product","type":"simple","manage stock":true,"stock quantity":10,"in stock":true,"sk u":"","ima ges":[{"src":"http:\/\/example .com\/wp content\/uploads\/2012\/12\/my product .jpg"}],"attributes":[]}}' \

"<https://example .com /wp json /wc /v3 /products /1234?consumer key=ck XXXXXXXX X&consumer secret=cs XXXXXXXX X">

Replace 1234 with (the ID of) your product, ck XXXXXXXX X with your Consumer Key ,and cs XXXXXXXX X with y our Consumer Secret . If your product has multiple images , you'll need t o include all of their URLs in t he images array. You can also specify sale dates by including date on sale from and date on sale to fields (leave these fields blank if you want t he sale to be ongoing). When you're finished, click Run in Postman to add the sale price to your product.

Conclusion:

In order to add a sale in WooCommerce, follow these simple steps which are either done through the WordPress admin panel or by using the WooCommerce REST API

Drew Clemente

Drew Clemente

Devops & Sysadmin engineer. I basically build infrastructure online.