Skip to content

Commit

Permalink
Avoiding setting price to 0 when regular price is 0
Browse files Browse the repository at this point in the history
  • Loading branch information
ogomezba committed Jan 7, 2025
1 parent df75235 commit cac01bf
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion doofinder-for-woocommerce/doofinder-for-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: DOOFINDER Search and Discovery for WP & WooCommerce
* License: GPLv2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
* Version: 2.5.20
* Version: 2.5.21
* Requires at least: 5.6
* Requires PHP: 7.0
* Author: Doofinder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,8 @@ private static function format_prices( $product ) {
$sale_price = self::get_sale_price( $wc_product );

$product['regular_price'] = $regular_price;
$product['price'] = '' === (string) $regular_price ? $price : $regular_price;
// In some niche cases, we receive a regular_price of 0 but it is not the real regular_price.
$product['price'] = '' === (string) $regular_price || 0 == $regular_price ? $price : $regular_price;
$final_sale_price = '' === (string) $sale_price || $price < $regular_price ? $price : $sale_price;

if ( empty( $final_sale_price ) || $final_sale_price === $regular_price ) {
Expand Down
7 changes: 5 additions & 2 deletions doofinder-for-woocommerce/readme.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
=== DOOFINDER Search and Discovery for WP & WooCommerce ===
Contributors: Doofinder
Tags: search, autocomplete
Version: 2.5.20
Version: 2.5.21
Requires at least: 5.6
Tested up to: 6.7.1
Requires PHP: 7.0
Stable tag: 2.5.20
Stable tag: 2.5.21
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -126,6 +126,9 @@ You can report security bugs through the Patchstack Vulnerability Disclosure Pro

== Changelog ==

= 2.5.21 =
- Avoid setting a price of 0 when the regular price is 0.

= 2.5.20 =
- Prevented an error when the $image_sizes array is not initialized.

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "doofinder-woocommerce",
"version": "2.5.20",
"version": "2.5.21",
"description": "Integrate Doofinder in your WooCommerce site with (almost) no effort.",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit cac01bf

Please sign in to comment.