PayPal第三方购物车:如何为整单设置统一运费
解决PayPal购物车统一运费设置问题
嘿,我来帮你搞定这个!你说得没错,PayPal的上传式购物车(也就是你用的cmd="_cart"+upload=1)里,确实有专门的统一运费设置字段,你只需要添加一个名为shipping的隐藏输入项就可以了,和你用的tax_cart用法完全一致。
具体修改步骤:
在你的表单里,找到tax_cart那一行的附近,添加这个隐藏字段:
<input type="hidden" name="shipping" value="@ViewBag.ShippingAmount" />
(这里假设你把统一运费存在ViewBag.ShippingAmount里,你也可以直接写固定数值,比如value="5.99")
修改后的完整代码:
<form class="paypalform" action="https://www.sandbox.paypal.com/bn/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_cart"> <input type="hidden" name="upload" value="1"> <input type="hidden" name="business" value="business@gmail.com"> @{ int count = 1; decimal cartTotal = 0; } @foreach (var item in Model) { <input type="hidden" name="item_name_@count" value="@item.ProductName"> <input type="hidden" name="amount_@count" value="@item.Price"> count++; cartTotal += item.Price; } <input type="hidden" name="currency_code" value="USD"> <input type="hidden" name="tax_cart" value="@ViewBag.TaxAmount" /> <!-- 添加统一运费字段 --> <input type="hidden" name="shipping" value="@ViewBag.ShippingAmount" /> <input type="image" src="http://www.sandbox.paypal.com/en_US/i/btn/x-click-but01.gif" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"> </form>
额外补充:
- 如果你还需要设置整个购物车的统一手续费,可以用
handling_cart字段,用法和shipping、tax_cart一样 - 要是你想给单个商品设置运费,才需要用
shipping_n(n是商品的序号,比如shipping_1对应第一个商品),但你要的统一运费,用shipping就完全够用了
内容的提问来源于stack exchange,提问作者BrainPain
相关产品推荐
相关产品推荐

