Prev | Current Page 482 | Next

Emilian Balanescu and Cristian Darie

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

tpl';
// Load search result page if we're searching the catalog
elseif (isset ($_GET['SearchResults']))
$this->mContentsCell = 'search_results.tpl';
// Load shopping cart or cart summary template
if (isset ($_GET['CartAction']))
$this->mContentsCell = 'cart_details.tpl';
else
$this->mCartSummaryCell = 'cart_summary.tpl';
// Load the page title
$this->mPageTitle = $this->_GetPageTitle();
}
4. Create a new presentation object file named presentation/cart_summary.php, and add the following
code to it:
// Class that deals with managing the shopping cart summary
class CartSummary
{
// Public variables to be used in Smarty template
public $mTotalAmount;
public $mItems;
public $mLinkToCartDetails;
public $mEmptyCart;
// Class constructor
public function __construct()
{
/* Calculate the total amount for the shopping cart
before applicable taxes and/or shipping charges */
$this->mTotalAmount = ShoppingCart::GetTotalAmount();
// Get shopping cart products
$this->mItems = ShoppingCart::GetCartProducts(GET_CART_PRODUCTS);
if (empty($this->mItems))
$this->mEmptyCart = true;
else
$this->mEmptyCart = false;
$this->mLinkToCartDetails = Link::ToCart();
}
}
?>
CHAPTER 12 ?–  CREATING YOUR OWN SHOPPING CART 383
5. Create a new file in the presentation/templates folder named cart_summary.tpl, and write the following
code to it:
{* cart_summary.


Pages:
470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494
poker online Ogrzewanie wciągarki linowe K10 Browar