想知道是否有办法让下拉选项字段修改商品的基本价格?像这样......
<input type="hidden" name="amount" value="$90" />
<input type="hidden" name="shipping" value="$10" />
<input type="text" name="quantity" value="1" style="width:15px;" />
<input type="hidden" name="on0" value="Options1" />
<select name="os0">
<option value="21 inches $5" >21 inches $5</option>
<option value="22 inches $5" >22 inches $5</option>
<option value="24 inches $10" >24 inches $10</option>
</select>
我猜我必须让金额字段成为下拉列表?
答案 0 :(得分:0)
您可以查看更新后的demo:
我制作了一个自定义代码来实现base price + optional price
方案。
您需要自定义自己的逻辑以构建金额值并传递给amount
变量并将其发送至paypal
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="S4X5XW328WAYY">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="item_name" value="test">
<input type="hidden" name="button_subtype" value="services">
<input type="hidden" name="no_note" value="0">
<input type="hidden" name="cn" value="Add special instructions to the seller:">
<input type="hidden" name="no_shipping" value="2">
<input type="hidden" name="currency_code" value="USD">
Base Price:<div id="base_price" value="100.00">100.00</div>
<input id="final_amount" name="amount" type="hidden" value="100">
<input type="hidden" name="weight_unit" value="lbs">
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHosted"><br>
Optional Prices
<table>
<tr><td>
<select name="os0">
<option class="optionVal" value="10.00">Option $10.00 USD</option>
<option class="optionVal" value="20.00">Option $20.00 USD</option>
<option class="optionVal" value="30.00">Option $30.00 USD</option>
</select>
</td></tr>
</table>
<input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
<强> JavaScript的:强>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script>
<script>
$(document).ready(function(){
var base_price = $('#base_price').text();
$('select').change(function(){
var amt = $(this).val();
final_amt = parseInt(amt)+parseInt(base_price);
$('#final_amount').val(final_amt);
});
});
</script>