Integration Guide

Table Of Contents
Website Payments Standard Integration Guide September 2008 237
The PayPal Shopping Cart – Add to Cart and View Cart Buttons
Sample HTML Code for Add to Cart Buttons
4
If your website has many product pages, browsers may have difficulty returning buyers to the
same product pages that they leave when they click your Add to Cart buttons. Returning
buyers to a different page, such as the home page of your website, degrades the shopping
experience for buyers who want to add more items to their carts before checking out.
Use the shopping_url variable to specify which page PayPal returns buyers to when they
click the Continue Shopping button. You can set the value of the shopping_url variable if
you know the URL for the webpage where the button appears. In the code below, the merchant
wants to ensure that buyers who click an Add to Cart button for a birthday card return to the
product page for birthday cards when they want to continue shopping.
<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr"
method="post">
<!-- Identify your business so that you can collect the payments. -->
<input type="hidden" name="business" value="kin@kinskards.com">
<!-- Specify a PayPal Shopping Cart Add to Cart button. -->
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="add" value="1">
<!-- Specify details about the item that buyers will purchase. -->
<input type="hidden" name="item_name"
value="Birthday Card - Cake and Candle">
<input type="hidden" name="amount" value="3.95">
<input type="hidden" name="currency_code" value="USD">
<!-- Continue shopping on the webpage for birthday cards -->
<input type="hidden" name="shopping_url"
value="http://www.kinskards.com/birthday_cards.html">
<!-- Display the payment button. -->
<input type="image" name="submit" border="0"
src="https://www.paypal.com/en_US/i/btn/btn_cart_LG.gif"
alt="PayPal - The safer, easier way to pay online">
<img alt="" border="0" width="1" height="1"
src="https://www.paypal.com/en_US/i/scr/pixel.gif" >
</form>
With a more advanced coding technique, you can add JavaScript functions to your product
pages that gets the current URL for the webpage from the browser and uses it as the value of
shopping_url. Use this coding technique to make your button code more portable when you
copy and paste buttons from webpage to webpage.
...
<script type="text/javascript">
<!--
function getContinueShoppingURL(form){
// -- Get the href of the currently displayed webpage --
form.shopping_url.value = window.location.href;
}