-2

I am importing sales prices from an inventory API and it works well. I'm setting the product price via meta keys, along with scheduled dates, and it is working; I can see them in product view and in the database.

$campaign_start_date = strtotime( $campaign["startDate"] );
$campaign_end_date = strtotime( $campaign["endDate"] );
$percentage_off_price = $campaign["percentageOffEntirePurchase"];

However, then the problem occurred, WooCommerce wouldn't recognize these products as on sale. After a while, I found out there is another key: _transient_wc_products_onsale

$products_on_sale = get_option( "_transient_wc_products_onsale" );

I then updated these accordingly. It's basically an array of product IDs, that are on sale. After I updated this field, WooCommerce started showing the products on sale in the on sale home view of the website.

However, the prices are not shown, nor is the little marker on the product block that indicates that the product is on sale and displays the sale price.

I have been Googling this for an hour now and I have come up with nothing.

I'm thinking there is another key somewhere, that I must update, but I have no idea. I didn't find anything from the database either.

  • Questions about the inner workings of woocommerce are better asked at their own forum. – Tim Malone Jul 3 '16 at 8:19
2

I figured I'd post the answer here as well in case someone else is going to look for the answer.

Why the sale price wasn't changing completely was because I wasn't changing al the required fields.

Woocommerce has 3 different fields for keeping the price for every product. There is the regular price field, sale price and a third one. When I set the sale price, I also had to change the regular price field to be the same as the sale price. Otherwise, Woocommerce did not recognise it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.