简体   繁体   中英

Check variable is not less than zero

I need to Check variable is not less than zero

if ( $currentUserLimits >= 0 ) {
        //do something
} elseif($currentUserLimits < $totalPurchaseUnitCount && $currentUserLimits not less then 0) {
        //do something else.
} else {
        //do something else.
}

Clear my question

This is all about offers apply on products and each customer have a purchases limit I have 2 variables and 3 cases.

  1. var1 $currentUserLimits which will return the current customer limits.
  2. var2 $totalPurchaseUnitCount which will return the current purchases.

My 3 cases.

  1. Case 1: if the $currentUserLimits still > 0 means the customer still have units in offer. Ex. $currentUserLimits = 15 and the $totalPurchaseUnitCount = 10 still the customer has 5 in his $currentUserLimits .
  2. Case 2: if the customer has half of his $totalPurchaseUnitCount in offer and the order half outside the offer. Ex. $currentUserLimits = 5 and the $totalPurchaseUnitCount = 10 .
  3. Case 3: if the customer finishes his limits completely so the $currentUserLimits is 0 or less then 0.

Sorry making y'all read all this stuff but really the 3 cases confuses me.

how to write not less than 0

你已经在 ($currentUserLimits >= 0)

Check this out.

if ( $currentUserLimits >= 0 ) {
        //do something
} elseif(($currentUserLimits < $totalPurchaseUnitCount) && !($currentUserLimits < 0)) {
        //do something else.
} else {
        //do something else.
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM