0

我有一个卖衬衫的客户。她希望潜在买家能够选择尺寸和颜色,并为每种尺寸和颜色提供数量选项。

我发现一些代码可以计算订单总额,但没有数量选项。

我附上了下面的代码。任何人都可以引导我朝着正确的方向前进吗?我对 PayPal 进行定制还很陌生,但我是一名网页设计师,所以我不是解决问题的初学者。我还附上了她通过电子邮件发送的客户表格的屏幕截图,以显示她想要的样子。

任何帮助将不胜感激。谢谢。

替代文字 http://www.inauguraldayt-shirts.com/shirt.jpg

<!-- Start of Script -->  
<SCRIPT type=text/javascript>
<!--
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 (".");
  if (pos > 0) str = str.substring (rnd, pos + 3);
  return str;
}function ReadForm (obj1, tst) { // process radio and checkbox
var i,j,amt=0,des="",obj,pos,val,tok,tag,
  op1a="",op1b="",op2a="",op2b="",itmn="";
var ary = new Array ();
  if (obj1.baseamt) amt  = obj1.baseamt.value*1.0;  // base amount
  if (obj1.basedes) des  = obj1.basedes.value;  // base description
  if (obj1.baseon0) op1a = obj1.baseon0.value;  // base options
  if (obj1.baseos0) op1b = obj1.baseos0.value;
  if (obj1.baseon1) op2a = obj1.baseon1.value;
  if (obj1.baseos1) op2b = obj1.baseos1.value;
  if (obj1.baseitn) itmn = obj1.baseitn.value;
  for (i=0; i<obj1.length; i++) {  // run entire form
    obj = obj1.elements[i];        // a form element
    if (obj.type == "checkbox" ||  // checkboxes
        obj.type == "radio") {     //  and radios
      if (obj.checked) {           // did user check it?
        val = obj.value;           // the value of the selection
        ary = val.split (" ");          // break apart
        for (j=0; j<ary.length; j++) {  // look at all items
// first we do single character tokens...
          if (ary[j].length < 2) continue;
          tok = ary[j].substring (0,1); // first character
          val = ary[j].substring (1);   // get data
          if (tok == "@") amt = val * 1.0;
          if (tok == "+") amt = amt + val*1.0;
          if (tok == "%") amt = amt + (amt * val/100.0);
          if (tok == "#") {             // record item number
            if (obj1.item_number) obj1.item_number.value = val;
          ary[j] = "";                // zap this array element
          }
// Now we do 3-character tokens...
          if (ary[j].length < 4) continue;
          tok = ary[j].substring (0,3); // first 3 chars
          val = ary[j].substring (3);   // get data
          if (tok == "s1=") {           // value for shipping
            if (obj1.shipping)  obj1.shipping.value  = val;
            ary[j] = "";                // clear it out
          }
          if (tok == "s2=") {           // value for shipping2
            if (obj1.shipping2) obj1.shipping2.value = val;
            ary[j] = "";                // clear it out
          }
        }
        val = ary.join (" ");           // rebuild val with what's left        tag = obj.name.substring (obj.name.length-2);  // get flag
        if      (tag == "1a") op1a = op1a + " " + val;
        else if (tag == "1b") op1b = op1b + " " + val;
        else if (tag == "2a") op2a = op2a + " " + val;
        else if (tag == "2b") op2b = op2b + " " + val;
        else if (tag == "3i") itmn = itmn + " " + val;
        else if (des.length == 0) des = val;
        else des = des + ", " + val;
      }
    }
  }
// Now summarize stuff we just processed, above
  if (op1a.length > 0) obj1.on0.value = op1a;
  if (op1b.length > 0) obj1.os0.value = op1b;
  if (op2a.length > 0) obj1.on1.value = op2a;
  if (op2b.length > 0) obj1.os1.value = op2b;
  if (itmn.length > 0) obj1.item_number.value = itmn;
  obj1.item_name.value = des;
  obj1.amount.value = Dollar (amt);
  if (obj1.tot) obj1.tot.value = "$" + Dollar (amt);
}
//-->
</SCRIPT>
<!-- End of Script --> 

    <div id="button">
    <!-- Another method for the View Cart Form - add this code anywhere within the web page -->

<!-- This is the FORM to view the cart contents -->
<!-- Note: target="paypal" was replaced with the variable target="_self" -->
<!-- Note: shopping_url also added to code -->
<!-- These two changes allow better functionality with IE and Firefox -->
<form target="_self" action="https://www.paypal.com/cgi-bin/webscr" method="post" id="viewcart" name="viewcart">
<p>
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="display" value="1">
<input type="hidden" name="business" value="you@you.com">
<input type="hidden" name="shopping_url" value="http://www.yourwebsite.com/your_page.html">
</p>
</form>
<!-- End of the viewcart FORM -->




<!-- Start of Form -->
<!-- Note: target="paypal" was replaced with the variable target="_self" -->
<!-- Note: shopping_url also added to code -->
<!-- These two changes allow better functionality with IE and Firefox -->
<FORM onsubmit="this.target='_self';&#10; return ReadForm(this, true);" action=https://www.paypal.com/cgi-bin/webscr method=post>
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="add" value="1">
<input type="hidden" name="business" value="you@you.com">
<input type="hidden" name="item_name" value="">
<input type="hidden" name="amount" value="">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="bn" value="PP-ShopCartBF">
<input type="hidden" name="shopping_url" value="http://www.yourwebsite.com/your_page.html">
<input type="hidden" name="cancel_return" value="http://www.yourwebsite.com/Cancel.html">
<input type="hidden" name="return" value="http://www.yourwebsite.com/Success.html">

<input type="hidden" value="0.00" name="baseamt">
<input type="hidden" value="Inaugural Day T-Shirt - @17.99" name="basedes">

Inaugural Day T-Shirt - $17.99
<br><br>

Colors
<br><br>  
<input onclick="ReadForm (this.form, false);" type=checkbox value="White +17.99"> White - $17.99
Select Quantity:&nbsp;&nbsp;
<select name="quantity">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<br>
<input onclick="ReadForm (this.form, false);" type=checkbox value="Blue +17.99"> Blue - $17.99
<br>
<input onclick="ReadForm (this.form, false);" type=checkbox value="Black +17.99"> Black - $17.99

<br><br><br>

Sizes
<br><br>
<input onclick="ReadForm (this.form, false);" type=checkbox value="Small +17.99"> Small - $17.99
<br>
<input onclick="ReadForm (this.form, false);" type=checkbox value="Medium +17.99"> Medium - $17.99
<br>
<input onclick="ReadForm (this.form, false);" type=checkbox value="Large +17.99"> Large - $17.99
<br>
<input onclick="ReadForm (this.form, false);" type=checkbox value="XL +19.99"> XL - $19.99
<br>
<input onclick="ReadForm (this.form, false);" type=checkbox value="XXL +19.99"> XXL - $19.99
<br>
<input onclick="ReadForm (this.form, false);" type=checkbox value="XXXL +19.99"> XXXL - $19.99


<br><br><br>


<input onclick="this.form.reset ();" type=button value="Reset Form">&nbsp; Item Total &gt;
<input class=nbor size=6 value=$0.00 name=tot> &nbsp;

<br><br>
<input type=image alt="cart add" src="https://www.paypal.com/en_US/i/btn/btn_cart_LG.gif" name=submit>

<br><br>
<input onclick="document.forms.viewcart.target = '_self';&#10; document.forms.viewcart.submit ();&#10; return false;" type=image alt="cart view" src="https://www.paypal.com/en_US/i/btn/btn_viewcart_LG.gif""> 
</FORM>
<!-- End of Form -->
4

1 回答 1

2

对于基本的 HTML 页面,使用 PayPal 自己的按钮向导。只需转到商家服务 -> 添加到购物车按钮。它将允许您自定义按钮以通过下拉列表指定不同的尺寸,甚至在将商品添加到购物车时选择数量。您还可以添加“查看购物车”按钮,一切都会为您处理好。我在最近的一个网站上使用了这个。

允许添加商品和查看购物车会将用户带到 PayPal 页面,但除非他们正在寻找一个完全集成的网站,否则此选项快速、简单且强大。此外,PayPal 在跟踪订单页面的来源方面做得很好,因此用户可以轻松导航回来。

于 2008-11-10T23:53:42.887 回答