在非Pay Shipping项目的Paypal上禁用运费

时间:2015-01-11 05:24:42

标签: php paypal cart shipping

我目前正在使用PayPal表单从网站结帐。在可装运物品上,一切正常。我遇到的问题是,该网站还提供不可发送的服务(可下载内容,在线流媒体视频)。我在购买成功时从PayPal检索到正确的回复,只有当他们支付为不可发运服务计算的运费时。以下是我的代码的摘录:

<form id="paypal-form" action="https://www.paypal.com/cgi-bin/webscr" method="post" style="display: none;">
    <?php foreach($checkout as $key => $value): ?>
        <input name="item_name_<?php echo $key + 1; ?>" value="<?php echo $value['name']; ?>" type="hidden">
        <input name="amount_<?php echo $key + 1; ?>" value="<?php echo $value['amount']; ?>" type="hidden">
        <input name="quantity_<?php echo $key + 1; ?>" value="<?php echo $value['quantity']; ?>" type="hidden">
        <input name="item_number_<?php echo $key + 1; ?>" value="<?php echo $value['number']; ?>" type="hidden">
    <?php endforeach; ?>
    <input name="no_shipping" value="2" type="hidden">
    <input name="return" value="WEB_SITE/thank-you.html" type="hidden">
    <input name="notify_url" value="WEB_SITE/process.html" type="hidden">
    <input name="cancel_return" value="WEB_SITE/shopping-cart.html" type="hidden">
    <input name="business" value="EMAIL" type="hidden">
    <input name="currency_code" value="USD" type="hidden">
    <input name="cmd" value="_cart" type="hidden">
    <input name="upload" value="1" type="hidden">
    <input name="rm" value="2" type="hidden">
    <input name="charset" value="utf-8" type="hidden">
</form>

我没有找到支持我在此论坛或PayPal上寻找的任务。是我要求的可能吗?

1 个答案:

答案 0 :(得分:0)

好的,经过进一步研究和尝试新事物,我发现了一种有效的方法。只需使用字段&#34; shipping_(n)&#34;并将值设置为&#34; 0&#34;覆盖运费计算并将其标记为$ 0.00。谢谢大家的尝试。这是我更正后的代码:

<form id="paypal-form" action="https://www.paypal.com/cgi-bin/webscr" method="post" style="display: none;">
    <?php foreach($checkout as $key => $value): ?>
        <input name="item_name_<?php echo $key + 1; ?>" value="<?php echo $value['name']; ?>" type="hidden">
        <input name="amount_<?php echo $key + 1; ?>" value="<?php echo $value['amount']; ?>" type="hidden">
        <input name="quantity_<?php echo $key + 1; ?>" value="<?php echo $value['quantity']; ?>" type="hidden">
        <input name="item_number_<?php echo $key + 1; ?>" value="<?php echo $value['number']; ?>" type="hidden">
        <?php if(strpos($value['number'], 'PROGRAMS') !== FALSE): ?>
            <input name="shipping_<?php echo $key + 1; ?>" value="0" type="hidden">
        <?php endif; ?>
    <?php endforeach; ?>
    <input name="no_shipping" value="2" type="hidden">
    <input name="return" value="WEB_SITE/thank-you.html" type="hidden">
    <input name="notify_url" value="WEB_SITE/process.html" type="hidden">
    <input name="cancel_return" value="WEB_SITE/shopping-cart.html" type="hidden">
    <input name="business" value="EMAIL" type="hidden">
    <input name="currency_code" value="USD" type="hidden">
    <input name="cmd" value="_cart" type="hidden">
    <input name="upload" value="1" type="hidden">
    <input name="rm" value="2" type="hidden">
    <input name="charset" value="utf-8" type="hidden">
</form>