Let??™s make the Place Order button work now. Because this feature depends on the company that processes
your payments, you might need to adapt it to the behavior of your payment-processing company. Here, we??™re
using PayPal. Start by modifying the PayPal-related constants in config.php as follows. Don??™t forget to
replace youremail@example.com with your PayPal-registered e-mail address.
// PayPal configuration
define('PAYPAL_URL',
'https://www.paypal.com/xclick/business=youremail@example.com');
define('PAYPAL_CURRENCY_CODE', 'USD');
define('PAYPAL_RETURN_URL', 'http://www.example.com');
define('PAYPAL_CANCEL_RETURN_URL', 'http://www.example.com');
5. Add the following highlighted code in the init() method of the CartDetails class in presentation/
cart_details.php:
/* Calculate the total amount for the shopping cart
before applicable taxes and/or shipping */
$this->mTotalAmount = ShoppingCart::GetTotalAmount();
// If the Place Order button was clicked ...
if(isset ($_POST['place_order']))
{
// Create the order and get the order ID
$order_id = ShoppingCart::CreateOrder();
// This will contain the PayPal link
$redirect =
PAYPAL_URL . '&item_name=TShirtShop Order ' . urlencode('#') . $order_id .
'&item_number=' . $order_id .
'&amount=' . $this->mTotalAmount .
'¤cy_code=' . PAYPAL_CURRENCY_CODE .
'&return=' . PAYPAL_RETURN_URL .
Pages:
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559