Prev | Current Page 365 | Next

Emilian Balanescu and Cristian Darie

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

In the store_front.php from the presentation folder, add the highlighted code to the StoreFront
class as shown:
// Page title
public $mPageTitle;
// PayPal continue shopping link
public $mPayPalContinueShoppingLink;
// Class constructor
public function __construct()
{
$this->mLinkToIndex = Link::ToIndex();
}
public function init()
{
// Create "Continue Shopping" link for the PayPal shopping cart
if (!isset ($_GET['AddProduct']))
{
/* Store the current request needed for the paypal
continue shopping functionality */
$_SESSION['paypal_continue_shopping'] =
Link::Build(str_replace(VIRTUAL_LOCATION, '',
$_SERVER['REQUEST_URI']));
CHAPTER 9 ?–  RECEIVING PAYMENTS USING PAYPAL 260
$this->mPayPalContinueShoppingLink =
$_SESSION['paypal_continue_shopping'];
}
// If Add to Cart was clicked, prepare PayPal variables
else
{
// Clean output buffer
ob_clean();
$product_id = 0;
// Get the product ID to be added to cart
if (isset ($_GET['AddProduct']))
$product_id = (int)$_GET['AddProduct'];
else
trigger_error('AddProduct not set');
$selected_attribute_groups = array ();
$selected_attribute_values = array ();
// Get selected product attributes if any
foreach ($_POST as $key => $value)
{
// If there are fields starting with "attr_" in the POST array
if (substr($key, 0, 5) == 'attr_')
{
// Get the selected attribute name and value
$selected_attribute_groups[] = substr($key, strlen('attr_'));
$selected_attribute_values[] = $_POST[$key];
}
}
// Get product info
$product = Catalog::GetProductDetails($product_id);
// Build the PayPal url to add the product to cart
$paypal_url = PAYPAL_URL .


Pages:
353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377
traktorki ogrodowe terapia magnetyczna Pompy zatapialne mapa Niemiec Wnętrza Poznań