Prev | Current Page 360 | Next

Emilian Balanescu and Cristian Darie

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

The value of this PayPal attribute would be a text containing
the selected product??™s attributes, so your visitor will be shown this data in the PayPal shopping cart.
Look ahead at Figure 9-4 to see this in action.
To implement this feature, since we can??™t use the PayPal form for adding products, the
system works like this:
1. Our Add to Cart buttons submit the form to our own application, to a link such as
http://localhost/tshirtshop/add-product-65/.
2. The URL is rewritten by mod_rewrite to a URL such as index.php?AddProduct=65.
3. index.php creates the PayPal attribute whose value sums up the attributes selected by
the visitor for the product. The new attribute value will look like Size/Color: S/White,
but it will be automatically generated to accommodate any number of attributes.
4. A PayPal Add to Cart URL is created using the newly created attribute.
5. Finally, the visitor is redirected, via the 302 status code, to the new URL.
To sum these rules up: when clicking an Add to Cart button, the visitor??™s web browser will
receive a 302 redirect to a PayPal Add to Cart URL. Next, it will load that URL, which will take
the visitor to the PayPal shopping cart, as shown in Figure 9-4.
CHAPTER 9 ?–  RECEIVING PAYMENTS USING PAYPAL 255
Figure 9-4. A PayPal shopping cart containing TShirtShop products
Now that you have a basic understanding of the steps involved, let??™s implement this code
through an exercise.


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