Search code examples
phppaypalcart

Disabling Shipping Cost on Paypal for Non-Shipping Items


I'm currently using a PayPal form to checkout from a website. On shippable items, everything is working fine. The issue I am running into, is the website also offers non-shippable services (downloadable content, streaming videos online). I'm retrieving the correct responses from PayPal when a purchase is successful, only if they pay shipping costs calculated for a non-shippable service. Here is an excerpt from my code:

<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>

I'm not finding support for the task I'm looking for on this forum or PayPal's. Is what I'm asking for possible?


Solution

  • Okay, after further research and trying new things I found a method that works. Simply using the field "shipping_(n)" and setting the value to "0" overrides the shipping calculation and marks it as $0.00. Thanks everyone for trying. Here is my corrected code:

    <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>