Need Help Setting Up Website Store

citizenfilm
Contributor
Contributor

Hi, I'm new to setting up PayPal to interact with the store I'm trying to set up on my website. I'd like to list about 15 DVDs for sale on one page, but would only like to list price & quantities under each DVD listing. Then, at the bottom, I'd like a "Checkout" or "Add Cart" button. Is this possible? To sort of bundle items like this? Or must I have an "Add to Cart" or "Buy Now" button under each item? I'm trying to avoid having the customer click "Add to Cart," be taken to the checkout page & then have to click "Keep Shopping" to choose another item for purchase. I'd rather be able to keep the customer on one page & be able to add all items at once & then click "Add Cart" & got to the checkout page. Make sense? Any advice would be much appreciated!
 

Login to Me Too
1 REPLY 1

snowshoe
Frequent Advisor
Frequent Advisor

You can do exactly what you have in mind however, all the coding you need must be manually done.  It's not possible using the online button creator as it has it's limitations.

 

If you're into coding your own stuff, it's easy, if not, may need to seek the assistance of a developer.

 

Basically you need a mini-cart setup or one specifically custom coded page, either way, all the logic is performed on your web page or site, then the end results are "uploaded" to PayPal for checkout.

 

If you like tweaking code, the example below would work for your needs.  This example demonstrates what a mini-cart looks like and the necessary scripting required.   If you do have other items in addtion to the DVDs, then go with a Add to Cart coding, else Buy Now will work.

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

<title>Button Example Code</title>

<!-- START META TAG SECTION -->
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<meta http-equiv="Content-Language" content="en">
<!-- END META TAG SECTION -->


<!-- Start of Script -->
<script type = "text/javascript" >
var order = new Object();  // object to store order items in
var root  = new Object();  // selection criteria
var on    = true;
var off   = false;
var cntr  = 0;             // items in object
var opts  = 5;             // number of options to allow
var shpr  = function (wt) {return 0;} // what to charge for shipping;
var stxt  = "";            // shipping text
var spos  = -1;            // shipping position selector
var ttax  = 0;             // percent for taxes
var ttxt  = "0";           // tax text
var tpos  = -1;            // tax position selector
var tamt=0,tqty=0,twgt=0,wgt=0,thnd=0;  // totals

root.hamt = 0;     // amount, below which, handling charge applies
root.hand = 0;     // handling charge for orders less than hamt
root.shp  = off;    // shipping selection line
root.tax  = off;    // tax selection line
// place for user-specific options
root.xx_can  = "";   // place for PayPal cancel return path
root.xx_cur  = "USD";// enter default currency code (or null)
root.xx_id   = "your email address";  //live

root.xx_img  = ""; // image URL
root.xx_lc   = "US"; // enter default country code (or null)
root.xx_ret  = ""; // place for PayPal return path
root.xx_sty  = ""; // place for PayPal page style
root.xx_xtra = "&cpp_header_image=https://www.yourwebsite.com/logo.jpg"; // place for other PayPal commands

function CalcRoot () {  // calc root stuff
  if (root.shp) spos=0; 
  if (root.tax) tpos=0;
}

function DispTots () {  // display totals on the page
var tmp,d;
tmp = 0;
  d = document.orderf;
  d.sub.value = Dollar (tamt);
  d.tot.value = Dollar (tamt  + tmp);
}

function Dollar (val) {     // force to valid dollar amount
var str,pos,rnd=0;
  if (val < .995) rnd = 1;  // for old Netscape browsers
  str = escape (val*1.0 + 0.005001 + rnd);  // float, round, escape
  pos = str.indexOf (".");  // should be one, but OK if not
  if (pos > 0) str = str.substring (rnd, pos + 3);
  return str;               // return valid string
}

function GetOrder (id, des, amt) {  // get all ordered items
var i,nr,val,qty,pos;
var op = new Array ();    // accumulate options here
  tamt=0,tqty=0;   // zero totals
  nr = id.substring (2);  // get number part of ID
  qty = document.orderf["qty" + nr].value;  // get qty

 
  if (isNaN (qty)) {      // test entry
    alert ("That is not a valid number!  Try again.");
    return;
  }
  for (i=1; i<=opts; i++) {     // see if any options
    if (document.orderf["op" + i + nr]) {
      val = document.orderf["op" + i + nr].value;  // get option
      op[i] = val;
      pos  = val.indexOf ("+"); // price increment?
      if (pos > 0) amt = amt + val.substring (pos + 1)*1.0;
      pos  = val.indexOf ("%"); // percent change?
      if (pos > 0) amt = amt + (amt * val.substring (pos + 1)/100.0);
    }
    else op[i] = "";
  }
  document.orderf["prc" + nr].value = Dollar (qty * amt);
  if (cntr == 0) order = new Object (); // zap object
  cntr = cntr + 1;               // bump counter so no zap next time
  order[id] = new Object ();     // create new entry
  for (i=1; i<=opts; i++)        // load options
    if (op[i] != "") des = des + ", OP" + i + "=" + op[i];
  order[id].des = des;           // load up values
  order[id].amt = Dollar (amt);
  order[id].qty = qty;
  for (i in order) {             // calc totals we might use
    qty = order[i].qty*1.0;
    tamt = tamt + order[i].amt * qty;  // total amount
    tqty = tqty + qty;                 // total quantity
  }
  DispTots ();                         // calc totals
}


function SendCart () {  // send the cart to PayPal
var frst = true;  // 1st pass thru items.

// This line controls the pop-up window size and location

var winpar = "width=710,height=390,scrollbars," +
             "location,resizable,status";
//Change the lines for either testing mode (sandbox) or live mode

//var strn   = "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_cart" + "&upload=1" + "&business=" + root.xx_id + root.xx_xtra;            
 var strn   = "https://www.paypal.com/cgi-bin/webscr?cmd=_cart" + "&upload=1" + "&business=" + root.xx_id + root.xx_xtra;
 
var i,j=0,des;
  if (root.xx_cur.length > 0)
    strn = strn + "&currency_code=" + root.xx_cur;
  if (root.xx_lc.length > 0)
    strn = strn + "&lc=" + root.xx_lc;
  if (root.xx_can.length > 0)
    strn = strn + "&cancel_return=" + root.xx_can;
  if (root.xx_ret.length > 0)
    strn = strn + "&return=" + root.xx_ret;
  if (root.xx_sty.length > 0)
    strn = strn + "&page_style=" + root.xx_sty;
  if (root.xx_img.length > 0)
    strn = strn + "&image_url=" + root.xx_img;
  if (tpos > 0) strn = strn + "&tax_cart=" + Dollar (tamt*ttax/100);
  for (i in order) {  // send all valid data
    if (order[i].qty > 0) {
      j = j + 1;
      des = order[i].des;
      strn = strn + "&item_name_"    + j + "=" + escape (des) +
                    "&item_number_"  + j + "=" + i +
                    "&quantity_"     + j + "=" + order[i].qty +
                    "&amount_"       + j + "=" + order[i].amt;
}
  }

// To open PayPal Screen on same page use:  if (j > 0) window.open (strn, "_self");  
// Original line:   if (j > 0) window.open (strn, "paypal", winpar);

   if (j > 0) window.open (strn, "_self");
}


function SetShp (obj) {  // set shipping on user selection
  shpr = function (wt) {return 0;}  // zap it
  spos = obj.selectedIndex;  // which option selected
  stxt = obj.options[spos].text;
  // set various shipping functions.
  if (spos == 1) shpr = function (wt) {return 0;}
  if (spos == 2) shpr = function (wt) {return 4.95;}
  if (spos == 3) shpr = function (wt) {return 10;}
  if (spos == 4) shpr = function (wt) {return wt * 2.50;}
  DispTots ();
}

function SetTax (obj) {
  tpos = obj.selectedIndex;  // which option selected
  ttxt = obj.options[tpos].text;
  ttax = obj.options[tpos].value*1.0;
  DispTots ();
}
</script>
<!-- End of Script -->



</head>

<body>

<!-- START SAMPLE CODE SECTION -->


<!-- PARAGRAPH 1 -->
Script Examples

<br><br><br>

Sell Tickets Online - High School Alumni Reunion.<br>Uses the Upload Method - Behaves like Buy Now.

<br><br>

<!-- Start of Form -->

<form name="orderf" id="orderf" 
  method="post" action="javascript&colon;void 0;">
<table cellspacing = "0"
       cellpadding = "4"
       border  = "3"
       frame   = "box"
       rules   = "all"
       summary = "Ticket Reservations">
<caption><b>Widget High School Class Reunion</b>
</caption>
  <tr>

    <th align="left">Description</th>
    <th>Each</th>
    <th>Quantity</th>
    <th>Total</th>

  </tr>

  <tr>

    <td>Reunion Tickets</td>
    <td align="right">25.00</td>
    <td>
      <input type="text" name="qty10" size="2" />
&nbsp;
      <a href="javascript&colon;
      GetOrder ('id10',
                'Reunion Tickets',
                25.00);">add</a>
    </td>

    <td>
      <input class="nbor" type="text" name="prc10" size="6" value="0.00" />
    </td>
  </tr>

  <tr>

    <td>DVD Memories</td>
     <td align="right">15.00</td>
    <td>
      <input type="text" name="qty15" size="2" />
&nbsp;
      <a href="javascript&colon;
      GetOrder ('id15',
                'DVD Memories',
                15.00);">add</a>
    </td>
    <td>
      <input class="nbor" type="text" name="prc15" size="6" value="0.00" />
    </td>
  </tr>

  <tr>
 
    <td>Book of Memories</td>
    <td align="right">15.00</td>
    <td>
      <input type="text" name="qty20" size="2" />
&nbsp;
      <a href="javascript&colon;
      GetOrder ('id20',
                'Book of Memories',
                15.00);">add</a>
    </td>
    <td>
      <input class="nbor" type="text" name="prc20" size="6" value="0.00" />
    </td>
  </tr>

  <tr>
    <td align="right" colspan="6">
Subtotal = 
      <input class="nbor" type="text" name="sub" size="10" value="0.00" />
    </td>
  </tr>





  <tr>
    <td align="right" colspan="6">
      <input type    = "button" 
             value   = "Reset"
             onclick = "cntr = 0;  // zap cart
                        shpr = function (wt) {return 0;}
                        if (root.shp) spos = 0;
                        if (root.tax) tpos = 0;
                        this.form.reset();" />
      &nbsp; &nbsp; 
      <input type    = "button"
             value   = "Checkout"
             onclick = "SendCart ();" />
      &nbsp; &nbsp;
Total 
<script type="text/javascript">
  if (root.xx_cur.length > 0)
    document.writeln (" (", root.xx_cur, ")");
</script>
 =  
      <input class="nbor" type="text" name="tot" size="10" value="0.00" />
    </td>
  </tr>
</table>
</form>

<!-- End of Form -->


<!-- END BUTTON EXAMPLES -->



<!-- END SAMPLE CODE SECTION -->

<br><br><br><br>
<hr align="left" width="50%" noshade>
<br><br>
NOTES:
<br>
In order to test the code, look for this line in the Script:
root.xx_id   = "your email address";  //live

You must replace "your email address" with PayPal Email Address or Account ID.

</body>
</html>

To see other examples, check out this page:

http://ccaples.com/index.php/basic-scripts/examples-iii/mini-cart-sample

 

And this one:

http://ccaples.com/index.php/basic-scripts/examples-iii/another-mini-cart-sample

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.