Skip to content

Commit

Permalink
Fix: Fix irregular incorrect zero prices
Browse files Browse the repository at this point in the history
With this change, when the discount price is zero or unset, the proper price is used for the displaying price.

Before this change, `strlen()` was used to check if a discounted price exists, which might not be reliable when 0.00 is passed. (haven't encountred this value yet though)

(possibly) Fixes #4
  • Loading branch information
michaeluno committed Aug 27, 2023
1 parent 12dde6e commit 3fd94d6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions includes/commons/utilities/Utility.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ static public function getWooCommerceProductCreatedFromUnitProduct( array $aItem
$_oWCProduct->set_description( $_oUtil->getElement( $aItem, [ 'feature' ] ) ); // empty string for a default value to avoid `null`. null is not allowed for the `post_content` column
$_sPriceProper = self::___getPriceProper( $aItem, $_oUtil );
$_sPriceDiscounted = self::___getPriceDiscounted( $aItem, $_oUtil );
$_sPriceDisplay = strlen( $_sPriceDiscounted ) ? $_sPriceDiscounted : $_sPriceProper;
$_sPriceDisplay = ( 0 < ( double ) $_sPriceDiscounted ) ? $_sPriceDiscounted : $_sPriceProper;

if ( strlen( $_sPriceDiscounted ) ) {
if ( 0 < ( double ) $_sPriceDiscounted ) {
$_oWCProduct->set_sale_price( $_sPriceDisplay );
}
if ( $_sPriceDisplay ) {
Expand Down

0 comments on commit 3fd94d6

Please sign in to comment.