Beispiel #1
0
function product_quantity_options($product)
{
    if ($product->stock === null) {
        $max = $product->max_quantity;
    } else {
        $max = min($product->max_quantity, $product->stock);
    }
    $opts = [];
    for ($i = 1; $i <= $max; $i++) {
        $opts[$i] = item_count($i);
    }
    return $opts;
}
Beispiel #2
0
 $bountyMessage = '';
 $resultMessage = '';
 $alternateResultMessage = '';
 if ($item_in == (int) $item_in && is_numeric($item_in)) {
     // Can be cast to an id.
     $item = $item_obj = getItemByID($item_in);
 } elseif (is_string($item_in)) {
     $item = $item_obj = getItemByIdentity($item_in);
 } else {
     $item = null;
 }
 if (!is_object($item)) {
     error_log('Invalid item identifier (' . (is_string($item_in) ? $item_in : 'non-string') . ') sent to page from ' . (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '(no referrer)') . '.');
     redirect(WEB_ROOT . 'inventory.php?error=noitem');
 }
 $item_count = item_count($user_id, $item);
 // Check whether use on self is occurring.
 $self_use = $selfTarget || $target_id === $user_id;
 if ($self_use) {
     $target = $username;
     $targetObj = $player;
 } else {
     if ($target_id) {
         $targetObj = new Player($target_id);
         $target = $targetObj->name();
         set_setting("last_item_used", $item_in);
         // Save last item used.
     }
 }
 $starting_turns = $player->vo->turns;
 $username_turns = $starting_turns;