Prev | Current Page 473 | Next

Emilian Balanescu and Cristian Darie

"Beginning PHP and MySQL E-Commerce: From Novice to Professional, Second Edition"

..
CHAPTER 12 ?–  CREATING YOUR OWN SHOPPING CART 374
if ($cartProductsType == GET_CART_PRODUCTS)
{
// Build SQL query
$sql = 'CALL shopping_cart_get_products(:cart_id)';
}
// If retrieving products saved for later ...
elseif ($cartProductsType == GET_CART_SAVED_PRODUCTS)
{
// Build SQL query
$sql = 'CALL shopping_cart_get_saved_products(:cart_id)';
}
else
trigger_error($cartProductsType. ' value unknown', E_USER_ERROR);
// Build the parameters array
$params = array (':cart_id' => self::GetCartId());
// Execute the query and return the results
return DatabaseHandler::GetAll($sql, $params);
}
/* Gets total amount of shopping cart products before tax and/or
shipping charges (not including the ones that are being
saved for later) */
public static function GetTotalAmount()
{
// Build SQL query
$sql = 'CALL shopping_cart_get_total_amount(:cart_id)';
// Build the parameters array
$params = array (':cart_id' => self::GetCartId());
// Execute the query and return the results
return DatabaseHandler::GetOne($sql, $params);
}
// Save product to the Save for Later list
public static function SaveProductForLater($itemId)
{
// Build SQL query
$sql = 'CALL shopping_cart_save_product_for_later(:item_id)';
// Build the parameters array
$params = array (':item_id' => $itemId);
// Execute the query
DatabaseHandler::Execute($sql, $params);
}
CHAPTER 12 ?–  CREATING YOUR OWN SHOPPING CART 375
// Get product from the Save for Later list back to the cart
public static function MoveProductToCart($itemId)
{
// Build SQL query
$sql = 'CALL shopping_cart_move_product_to_cart(:item_id)';
// Build the parameters array
$params = array (':item_id' => $itemId);
// Execute the query
DatabaseHandler::Execute($sql, $params);
}
}
?>
3.


Pages:
461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485
poker wygrać mieszkanie sosnowiec Leona Lewis ławki Danny