Prev | Current Page 581 | Next

Emilian Balanescu and Cristian Darie

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

To complete implementing the recommendations system for the product details page, we need to update the
product.tpl template. Add the following lines at the end of presentation/templates/product.tpl.
After that, you can load TShirtShop and load a product details page. If that product has been ordered with
any other products, they??™ll show up in the recommendations list.
{if $obj->mRecommendations}

Customers who bought this also bought:



    {section name=m loop=$obj->mRecommendations}

  1. {strip}

    {$obj->mRecommendations[m].product_name}

    {/strip}
    - {$obj->mRecommendations[m].description}

  2. {/section}

{/if}
6. Open tshirtshop.css, and add the following style:
.list { color: #000000; }
7. Now, let??™s modify the cart_details componentized template to show product recommendations in the shopping
cart page. Open cart_details.php located in the presentation folder to add the $mRecommendation
member to the CartDetails class:
// Class that deals with managing the shopping cart
class CartDetails
{
// Public variables available in smarty template
public $mCartProducts;
public $mSavedCartProducts;
public $mTotalAmount;
public $mIsCartNowEmpty = 0; // Is the shopping cart empty?
public $mIsCartLaterEmpty = 0; // Is the 'saved for later' list empty?
public $mLinkToContinueShopping;
public $mUpdateCartTarget;
public $mRecommendations;
CHAPTER 15 ?–  PRODUCT RECOMMENDATIONS 472
8.


Pages:
569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593