Created
March 27, 2015 03:45
-
-
Save aaroncampbell/582fb592c9d31a316473 to your computer and use it in GitHub Desktop.
Show different strings for stock level of 0, 1, and many items
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$inventory = it_exchange( 'product', 'inventory', 'return=true' ); | |
if ( 0 == $inventory ) { | |
echo 'Too Late!'; // We're completely out | |
} elseif ( 1 == $inventory ) { | |
echo 'There can be only one!'; // There is one in stock | |
} else { | |
printf( 'We have %s in stock.', number_format( $inventory, 0, null, ',' ) ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment