Dazu habe ich bereits Variablen im eigentlichen Script schon erstellt, nun bräuchte ich da aber ca. 50 Zutaten und für jede Variablen machen wäre ja blöd. Bin Anfänger was php angeht, habe was von Arrays gehört aber ich bin mir nicht sicher wie ich die anwenden kann.
/**
* Update an item in the cart
*
* @param string $id
* @param mixed $qty
*
* @return boolean
*/
private function update_item($id, $qty) {
// If the quantity is zero, no futher validation is required
if ((int) $qty === 0) {
$validQty = true;
}
// If decimal quantities are enabled, verify it's a float
elseif ($this->config['decimalQtys'] === true && filter_var($qty, FILTER_VALIDATE_FLOAT)) {
$validQty = true;
}
// By default, verify the quantity is an integer
elseif (filter_var($qty, FILTER_VALIDATE_INT)) {
$validQty = true;
}
// If it's a valid quantity, remove or update as necessary
if ($validQty === true) {
if($qty < 1) {
$this->remove_item($id);
}
else {
$this->qtys[$id] = $qty;
}
$this->update_subtotal();
return true;
}
}
/* Using post vars to remove items doesn't work because we have to pass the
id of the item to be removed as the value of the button. If using an input
with type submit, all browsers display the item id, instead of allowing for
user-friendly text. If using an input with type image, IE does not submit
the value, only x and y coordinates where button was clicked. Can't use a
hidden input either since the cart form has to encompass all items to
recalculate subtotal when a quantity is changed, which means there are
multiple remove buttons and no way to associate them with the correct
hidden input. */
/**
* Reamove an item from the cart
*
* @param string $id *
*/
private function remove_item($id) {
$tmpItems = array();
// Rebuild the items array, excluding the id we just removed
foreach($this->items as $item) {
if($item != $id) {
$tmpItems[] = $item;
}
}
$this->items = $tmpItems;
$this->update_subtotal();
}
/**
* Update the entire cart
*/
public function update_cart() {
// Post value is an array of all item quantities in the cart
// Treat array as a string for validation
if (is_array($_POST['jcartItemQty'])) {
$qtys = implode($_POST['jcartItemQty']);
}
// If no item ids, the cart is empty
if ($_POST['jcartItemId']) {
$validQtys = false;
// If decimal quantities are enabled, verify the combined string only contain digits and decimal points
if ($this->config['decimalQtys'] === true && preg_match("/^[0-9.]+$/i", $qtys)) {
$validQtys = true;
}
// By default, verify the string only contains integers
elseif (filter_var($qtys, FILTER_VALIDATE_INT) || $qtys == '') {
$validQtys = true;
}
if ($validQtys === true) {
// The item index
$count = 0;
// For each item in the cart, remove or update as necessary
foreach ($_POST['jcartItemId'] as $id) {
// Increment index for the next item
$count++;
}
return true;
}
}
// If no items in the cart, return true to prevent unnecssary error message
elseif (!$_POST['jcartItemId']) {
return true;
}
}
// Use config values as literal indices for incoming POST values
// Values are the HTML name attributes set in config.json
$id = $_POST[$id];
$name = $_POST[$name];
$zutat = $_POST[$zutat];
$price = $_POST[$price];
$qty = $_POST[$qty];
$url = $_POST[$url];
// Only generate unique token once per session
if(!$_SESSION['jcartToken']){
$_SESSION['jcartToken'] = md5(session_id() . time() . $_SERVER['HTTP_USER_AGENT']);
}
// If enabled, check submitted token against session token for POST requests
if ($config['csrfToken'] === 'true' && $_POST && $jcartToken != $_SESSION['jcartToken']) {
$errorMessage = 'Invalid token!' . $jcartToken . ' / ' . $_SESSION['jcartToken'];
}
// Sanitize values for output in the browser
$id = filter_var($id, FILTER_SANITIZE_SPECIAL_CHARS, FILTER_FLAG_STRIP_LOW);
$name = filter_var($name, FILTER_SANITIZE_SPECIAL_CHARS, FILTER_FLAG_STRIP_LOW);
$zutat = filter_var($zutat, FILTER_SANITIZE_SPECIAL_CHARS, FILTER_FLAG_STRIP_LOW);
$url = filter_var($url, FILTER_SANITIZE_URL);
// Round the quantity if necessary
if($config['decimalPlaces'] === true) {
$qty = round($qty, $config['decimalPlaces']);
}
// Add an item
if ($_POST[$add]) {
$itemAdded = $this->add_item($id, $name, $price, $qty, $url, $zutat);
// If not true the add item function returns the error type
if ($itemAdded !== true) {
$errorType = $itemAdded;
switch($errorType) {
case 'qty':
$errorMessage = $config['text']['quantityError'];
break;
case 'price':
$errorMessage = $config['text']['priceError'];
break;
}
}
}
// Update a single item
if ($_POST['jcartUpdate']) {
$itemUpdated = $this->update_item($_POST['itemId'], $_POST['itemQty']);
if ($itemUpdated !== true) {
$errorMessage = $config['text']['quantityError'];
}
}
// Update all items in the cart
if($_POST['jcartUpdateCart'] || $_POST['jcartCheckout']) {
$cartUpdated = $this->update_cart();
if ($cartUpdated !== true) {
$errorMessage = $config['text']['quantityError'];
}
}
// Remove an item
/* After an item is removed, its id stays set in the query string,
preventing the same item from being added back to the cart in
subsequent POST requests. As result, it's not enough to check for
GET before deleting the item, must also check that this isn't a POST
request. */
if($_GET['jcartRemove'] && !$_POST) {
$this->remove_item($_GET['jcartRemove']);
}
// Empty the cart
if($_POST['jcartEmpty']) {
$this->empty_cart();
}
// Determine which text to use for the number of items in the cart
$itemsText = $config['text']['multipleItems'];
if ($this->itemCount == 1) {
$itemsText = $config['text']['singleItem'];
}
// Determine if this is the checkout page
/* First we check the request uri against the config checkout (set when
the visitor first clicks checkout), then check for the hidden input
sent with Ajax request (set when visitor has javascript enabled and
updates an item quantity). */
$isCheckout = strpos(request_uri(), $checkout);
if ($isCheckout !== false || $_REQUEST['jcartIsCheckout'] == 'true') {
$isCheckout = true;
}
else {
$isCheckout = false;
}
// Overwrite the form action to post to gateway.php instead of posting back to checkout page
if ($isCheckout === true) {
// Trim trailing slash if necessary
$path = rtrim($path, '/');
$checkout = $path . '/gateway.php';
}
// Default input type
// Overridden if using button images in config.php
$inputType = 'submit';
// If this error is true the visitor updated the cart from the checkout page using an invalid price format
// Passed as a session var since the checkout page uses a header redirect
// If passed via GET the query string stays set even after subsequent POST requests
if ($_SESSION['quantityError'] === true) {
$errorMessage = $config['text']['quantityError'];
unset($_SESSION['quantityError']);
}
// Set currency symbol based on config currency code
$currencyCode = trim(strtoupper($config['currencyCode']));
switch($currencyCode) {
case 'EUR':
$currencySymbol = '€';
break;
case 'GBP':
$currencySymbol = '£';
break;
case 'JPY':
$currencySymbol = '¥';
break;
case 'CHF':
$currencySymbol = 'CHF ';
break;
case 'SEK':
case 'DKK':
case 'NOK':
$currencySymbol = 'Kr ';
break;
case 'PLN':
$currencySymbol = 'zł ';
break;
case 'HUF':
$currencySymbol = 'Ft ';
break;
case 'CZK':
$currencySymbol = 'Kč ';
break;
case 'ILS':
$currencySymbol = '₪ ';
break;
case 'TWD':
$currencySymbol = 'NT$';
break;
case 'THB':
$currencySymbol = '฿';
break;
case 'MYR':
$currencySymbol = 'RM';
break;
case 'PHP':
$currencySymbol = 'Php';
break;
case 'BRL':
$currencySymbol = 'R$';
break;
case 'USD':
default:
$currencySymbol = '$';
break;
}
////////////////////////////////////////////////////////////////////////
// Output the cart
// Return specified number of tabs to improve readability of HTML output
function tab($n) {
$tabs = null;
while ($n > 0) {
$tabs .= "\t";
--$n;
}
return $tabs;
}
// If there's an error message wrap it in some HTML
if ($errorMessage) {
$errorMessage = "<p id='jcart-error'>$errorMessage</p>";
}
// If this is the checkout display the PayPal checkout button
if ($isCheckout === true) {
// Hidden input allows us to determine if we're on the checkout page
// We normally check against request uri but ajax update sets value to relay.php
echo tab(3) . "<input type='hidden' id='jcart-is-checkout' name='jcartIsCheckout' value='true' />\n";
Ok danke, ich habe hier
unter "Familienpizza" checkboxen
Ich möchte weil es ab einer bestimmten Anzahl von Zutaten pro Zutat drauf gerechnet wird. Funktioniert das einfach mit einer if oder while Abfrage im Formulardokument?
Oder wenn ich für bestimmte Zutaten einen Preis von 0,50€ berechnen möchte?
Mit einem Optionsfeld funktioniert das mit:
Code:
// When the document is ready
$(function() {
// Attach a change function to the <select> element
$('[name=my-item-name]').change(function() {
// Size is whatever the value the user has selected
var size = $(this).val();
var price,
itemId;
// Determine the correct price and item ID based on the selected size
switch (size) {
case 'size-1':
price = '10.00';
itemId = 1;
break;
case 'size-2':
price = '20.00';
itemId = 2;
break;
case 'size-3':
price = '30.00';
itemId = 3;
break;
}
// Update the price <span> with the price for the selected item
$('.price').text(price);
// Update the hidden price <input>
$('[name=my-item-price]').val(price);
// Update the item ID
$('[name=my-item-id]').val(itemId);
});
});
Geht zombiecraft auch auf einem mcpc server geht ? 02/16/2013 - Minecraft - 2 Replies Halloo com.
Wie der titel schon sagt wollte ich fargen ob der mod zombiecraft auch im multiplayer auf einem mcpc server geht.
Mfg LOLXXL
WarZ geht nicht? Alle Lösungen versagen? Warum einfach wenns auch schwer geht, was? 01/09/2013 - Infestation - 21 Replies Ja Leute.. ich hab mir mal angesehen, welche Lösungen hier im Forum rumgeisterten.. viele sagen ja, man müsse in der Host Datei etwas bearbeiten.. Solltet ihr aber diese Einträge löschen, fliegt ihr aus dem Game nach wenigen Minuten raus. Der 2. Teil der Lösung hat, zumindets bei mir, tadellos geklappt.
Einfach ipconfig /flushdns im CMD eingegeben und es klappte.
Ich weiß nicht, inwiefern es euch helfen wird aber hoffe doch, dass es eine Lösung für einen Teil von euch ist.
Also: Host...
Überprüfen ob Variable Eine Variable ist 10/16/2010 - AutoIt - 26 Replies Hey leute ich wollte fragen ob/wie man überprüfen kann
ob eine Variable eine Variable ist z.b. so
$k = 1
$i = $k
if $i = VARIABLE Then
msgbox(0,'$i ist eine variable!!','')
endif
PS:Wp releast man nochma TuT (z.b. für metin2??)