Prev | Current Page 363 | Next

Emilian Balanescu and Cristian Darie

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

section.k.index % 2 != 0 && !$smarty.section.k.first ||
$smarty.section.k.last}

{/if}
4. In presentation/link.php, modify the CheckRequest() method right at the beginning as shown:
// Redirects to proper URL if not already there
public static function CheckRequest()
{
$proper_url = '';
if (isset ($_GET['Search']) || isset($_GET['SearchResults']) ||
isset ($_GET['AddProduct']))
{
return ;
}
5. Also, in the link.php file, add the following method at the end of the Link class:
// Create an Add to Cart link
public static function ToAddProduct($productId)
{
return self::Build('index.php?AddProduct=' . $productId);
}
CHAPTER 9 ?–  RECEIVING PAYMENTS USING PAYPAL 258
6. Now, open product.php from the presentation folder, and add the highlighted code to the init()
method of the Product class:
$this->mProduct['attributes'] =
Catalog::GetProductAttributes($this->mProduct['product_id']);
$this->mLocations = Catalog::GetProductLocations($this->_mProductId);
// Create the Add to Cart link
$this->mProduct['link_to_add_product'] =
Link::ToAddProduct($this->_mProductId);
// Build links for product departments and categories pages
for ($i = 0; $i < count($this->mLocations); $i++)
{
$this->mLocations[$i]['link_to_department'] =
Link::ToDepartment($this->mLocations[$i]['department_id']);
7. In the product.tpl from the presentation/templates folder, add the highlighted code that adds the
Add to Cart button on the product page:


Price:
{if $obj->mProduct.


Pages:
351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375