Forum

Thread tagged as: Question, Problem, PayPal

How to Pass Shipping Cost From PayPal Shop to PayPal in Checkout?

Hello, I've got a client site with the paypal shop. I'm trying to get the shipping cost that is entered in the shop backend to pass through to paypal with the product cost. I've added the fields for shipping and shipping2 as noted in PayPal's documentation.

We're on the most current version of the paypal shop app and 2.8.7. I plan on updating to 2.8.8 later this week.

Product.html:

<div class="row" style="margin-top:2rem;">

    <div class="small-12 medium-3 columns">
        <perch:if exists="productImage">
    <img src="<perch:shop id="productImage" label="Image" order="10" type="image" />" alt="<perch:shop id="productTitle" />" />
    <perch:else/>
    <img src="https://placehold.it/250x350/cccccc/2b2b2b" alt="">
    </perch:if> 
    </div>
    <div class="small-12 medium-9 columns">
            <h1 class="product-title"><perch:shop id="productTitle" order="1"/></h1>
            <perch:if exists="pub-author"><p>Written by <perch:shop id="pub-author" label="Author(s)" type="text" order="5"/> / <perch:if exists="pub-date">Published <perch:shop id="pub-date" type="text" required="false" order="7" label="Publication Date"/></perch:if> / <perch:if exists="pub-pages"><perch:shop id="pub-pages" type="text" required="false" order="8" label="Page Count"/> pages</perch:if></p></perch:if>
    <div class="row">
        <div class="small-12 medium-8 columns" style="font-size:1rem;letter-spacing:0;">

            <p><b>Description</b></p>
            <perch:shop id="productDescHTML" label="Description" type="textarea" order="9" html="true"/>
        </div>      
        <div class="small-12 medium-4 columns">

                <p>Product Code: <perch:shop id="productCode" type="text" order="2" label="Code"/></p>
                <p>Price: &dollar; <perch:shop id="productPrice" order="4" /><perch:if exists="productShipCost"><br>Shipping cost: <perch:shop id="productShipCost" type="text" order="11"  divider-before="Product Shipping" label="Shipping cost" help="Format as 00.00"/><br><perch:shop id="productShipCost2" type="text" order="12" divider-after="Categories"  label="Shipping cost for each additional item" help="Format as 00.00"/></perch:if></p>
            <ul class="zero-list">
            <perch:if exists="pub-volume">
            <li><p>Volume <perch:shop id="pub-volume" type="text" order="3" required="false" label="Volume"/></p></li>
            </perch:if>
            </ul>
            <perch:form id="_xclick" method="post" action="https://www.paypal.com/cgi-bin/webscr">


                <perch:input type="hidden" name="business" value="<perch:setting id="perch_shop_paypal_email" />" />
                <perch:input type="hidden" name="currency_code" value="USD" /> 
                <perch:input type="hidden" name="cmd" value="_cart" />
                <perch:input type="hidden" name="add" value="1" />     
                <perch:input type="hidden" name="item_name" value="<perch:shop id="productTitle" />" />
                <perch:input type="hidden" name="item_number" value="<perch:shop id="productCode" />" />
                <perch:input type="hidden" name="amount" value="<perch:shop id="productPrice" />" />
                <perch:input type="hidden" name="shipping" value="<perch:shop id="productShipCost"/>"/>
                <perch:input type="hidden" name="shipping2" value="<perch:shop id="productShipCost2"/>"/>

                <div class="text-center"><perch:input type="submit" class="button button-cart" name="add" value="Add to cart" /></div>  
                <span><perch:if exists="productOptions_html"><perch:shop id="productOptions_html" encode="false" type="hidden" /></perch:if></span>
                <p class="text-center paypal-span">Pay with PayPal.</p>
                </perch:form> 
        </div>
    </div>
</div>
</div>

Diagnostics report:

PERCH INFORMATION

Perch: 2.8.7
Production mode: Production (100)
Installed apps: content (2.8.7), assets (2.8.7), categories (2.8.7), perch_events (1.9.1), perch_forms (1.8.2), perch_shop_paypal (1.2.3), perch_comments (1.1), perch_members (1.2)
DB driver: PDO
DB tables: perch2_categories, perch2_category_counts, perch2_category_sets, perch2_comments, perch2_comments_votes, perch2_content_index, perch2_content_items, perch2_content_regions, perch2_events, perch2_events_categories, perch2_events_to_categories, perch2_forms, perch2_forms_responses, perch2_members, perch2_members_forms, perch2_members_member_tags, perch2_members_sessions, perch2_members_tags, perch2_navigation, perch2_navigation_pages, perch2_page_templates, perch2_pages, perch2_resource_log, perch2_resource_tags, perch2_resources, perch2_resources_to_tags, perch2_settings, perch2_shop_categories, perch2_shop_log, perch2_shop_orders, perch2_shop_product_option_values, perch2_shop_product_options, perch2_shop_products, perch2_shop_products_to_categories, perch2_user_privileges, perch2_user_role_privileges, perch2_user_roles, perch2_users
Users: 7
App runtimes:
<?php
    $apps_list = array(
        'content', 
        'categories',
        'perch_shop_paypal',
        'perch_members',
        'perch_comments',
        'perch_events',
        'perch_forms'
    );
Scheduled tasks for perch_events: update_category_counts (60 mins)
Editor plug-ins: redactor, markitup
H1: a627c7204293ef07f62a7c826676c857
L1: 77e4c38a8574bb64c4113dfe1e6a0444
headerColour: #a62c31
content_singlePageEdit: 1
helpURL:
siteURL: /
hideBranding: 1
content_collapseList: 1
lang: en-gb
update_2.4.6: done
latest_version: 2.8
on_sale_version: 2.8.8
perch_shop_foxycart_update: 2.0
headerScheme: dark
perch_members_login_page: /my-mcgs/login.php?r={returnURL}
perch_shop_foxy_url:
perch_shop_foxy_api:
hide_pwd_reset: 0
perch_shop_product_url: /shop/product/{productSlug}
dashboard: 0
content_hideNonEditableRegions: 0
content_frontend_edit: 0
perch_shop_foxy_security: 0
perch_shop_display_oos: 1
update_2.4.9: done
update_2.5.2: done
perch_comments_akismet_key:
update_2.6.2: done
update_2.6.3: done
update_2.7.2: done
perch_events_update: 1.8
update_2.7.4: done
perch_events_detail_url: /events/{eventSlug}
perch_shop_paypal_email: MCGS.Directors@gmail.com
update_2.7.8: done
update_2.7.10: done
update_2.8.1: done
update_2.8.2: done
logoPath: /admin/resources/logo07.png
update_2.8.4: done
update_2.8.7: done
PERCH_DEVELOPMENT: 10
PERCH_STAGING: 50
PERCH_PRODUCTION: 100
PERCH_DB_USERNAME: darkligh_gary
PERCH_DB_SERVER: localhost
PERCH_DB_DATABASE: darkligh_mcgs
PERCH_DB_PREFIX: perch2_
PERCH_TZ: UTC
PERCH_EMAIL_FROM: mcgs.directors@gmail.com
PERCH_EMAIL_FROM_NAME: McLean County Genealogical Society
PERCH_LOGINPATH: /admin
PERCH_PATH: /home/darkligh/public_html/mcgs/admin
PERCH_CORE: /home/darkligh/public_html/mcgs/admin/core
PERCH_RESFILEPATH: /home/darkligh/public_html/mcgs/admin/resources
PERCH_RESPATH: /admin/resources
PERCH_HTML5: 1
PERCH_DEBUG: 1
PERCH_RUNWAY:
PERCH_ERROR_MODE: DIE
PERCH_DATE_LONG: %d %B %Y
PERCH_DATE_SHORT: %d %b %Y
PERCH_TIME_SHORT: %H:%M
PERCH_TIME_LONG: %H:%M:%S
PERCH_PREVIEW_ARG: preview
PERCH_TEMPLATE_PATH: /home/darkligh/public_html/mcgs/admin/templates
PERCH_DEFAULT_DOC: index.php
PERCH_DEFAULT_EXT: .php
PERCH_PRODUCTION_MODE: 100
PERCH_RWD:
PERCH_HTML_ENTITIES:
PERCH_SSL:
PERCH_STRIPSLASHES:
PERCH_PROGRESSIVE_FLUSH: 1
PERCH_AUTH_PLUGIN:
PERCH_DB_CHARSET: utf8
PERCH_DB_PORT:
PERCH_DB_SOCKET:
HOSTING SETTINGS

PHP: 5.5.25
Zend: 2.5.0
OS: Linux
SAPI: cgi-fcgi
Safe mode: not detected
MySQL client: mysqlnd 5.0.11-dev - 20120503 - $Id: 15d5c781cfcad91193dceae1d2cdd127674ddb3e $
MySQL server: 5.5.44-MariaDB
Extensions: Core, date, ereg, libxml, openssl, pcre, sqlite3, zlib, bcmath, bz2, calendar, ctype, curl, dom, hash, fileinfo, filter, ftp, gd, gettext, SPL, iconv, session, intl, json, mbstring, mcrypt, standard, mysql, mysqli, mysqlnd, PDO, Phar, posix, pspell, Reflection, imap, SimpleXML, snmp, soap, sockets, exif, tidy, tokenizer, wddx, xml, xmlreader, xmlrpc, xmlwriter, xsl, zip, cgi-fcgi, pdo_sqlite, pdo_pgsql, pdo_mysql, gnupg, imagick, mailparse, memcache, OAuth, phalcon, timezonedb, uploadprogress, yaml, mhash, ionCube Loader, SourceGuardian
GD: Yes
ImageMagick: Yes
PHP max upload size: 256M
PHP max form post size: 256M
PHP memory limit: 256M
Total max uploadable file size: 256M
Resource folder writeable: Yes
Session timeout: 24 minutes
Native JSON: Yes
Filter functions: Yes
Transliteration functions: Yes
DOCUMENT_ROOT: /home/darkligh/public_html/mcgs
GATEWAY_INTERFACE: CGI/1.1
HTTP_ACCEPT: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
HTTP_ACCEPT_ENCODING: gzip, deflate, sdch
HTTP_ACCEPT_LANGUAGE: en-US,en;q=0.8
HTTP_CONNECTION: close
HTTP_COOKIE: cmssb=1; _ga=GA1.2.961101863.1424223479; cmsa=1; p_m=; PHPSESSID=fslbb4n7llusg24vkv2eht2ua6; _asomcnc=1
HTTP_DNT: 1
HTTP_HOST: mcgs.garyriverson.com
HTTP_REFERER: https://mcgs.garyriverson.com/admin/core/settings/diagnostics/
HTTP_USER_AGENT: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.81 Safari/537.36
HTTP_X_FORWARDED_FOR: 75.4.133.223
HTTP_X_REAL_IP: 75.4.133.223
PATH: /bin:/usr/bin
QUERY_STRING: extended
REDIRECT_STATUS: 200
REMOTE_ADDR: 75.4.133.223
REMOTE_PORT: 29920
REQUEST_METHOD: GET
REQUEST_URI: /admin/core/settings/diagnostics/?extended
SCRIPT_FILENAME: /home/darkligh/public_html/mcgs/admin/core/settings/diagnostics/index.php
SCRIPT_NAME: /admin/core/settings/diagnostics/index.php
SERVER_ADDR: 143.95.41.162
SERVER_ADMIN: webmaster@mcgs.garyriverson.com
SERVER_NAME: mcgs.garyriverson.com
SERVER_PORT: 80
SERVER_PROTOCOL: HTTP/1.0
SERVER_SOFTWARE: Apache
UNIQUE_ID: VX5XkkFj7agAAERKb-8AAAAF
PHP_SELF: /admin/core/settings/diagnostics/index.php
REQUEST_TIME_FLOAT: 1434343314.6639
REQUEST_TIME: 1434343314
Gary Iverson

Gary Iverson 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Do you see the hidden productShipCost field being populated in the HTML?

Yes.

In the page:

<p>Shipping cost: 6.50</p>

In the PayPal form:

<form id="form2__xclick" action="https://www.paypal.com/cgi-bin/webscr" method="post">


                <input name="business" value="EMAIL" type="hidden">
                <input name="currency_code" value="USD" type="hidden"> 
                <input name="cmd" value="_cart" type="hidden">
                <input name="add" value="1" type="hidden">     
                <input name="item_name" value="Woodford County Census for 1850" type="hidden">
                <input name="item_number" value="W-1850" type="hidden">
                <input name="amount" value="9.00" type="hidden">
                <input name="shipping" value="6.50" type="hidden">
                <input name="shipping2" type="hidden">

                <div class="text-center"><input name="add" class="button button-cart" value="Add to cart" type="submit"></div>  

                <p class="text-center paypal-span">Pay with PayPal.</p>
                </form>

Drew McLellan

Drew McLellan 2638 points
Perch Support

How does that compare to what PayPal is expecting?

Okay, I'm reading that shipping and shipping2 are only to be used with Buy it Now and Add to Cart buttons, which may explain why it's not working as expected.

The other options are:

handling

Handling charges. This variable is not quantity-specific. The same handling cost applies, regardless of the number of items on the order. Default – No handling charges are included.

handling_ cart

Single handling fee charged cart-wide. If handling_cart is used in multiple Add to Cart buttons, the handling_cart value of the first item is used.

Though I'm not sure which to use. I've tried both just now and neither seem to work as expected.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok. I think you'll need to figure things out from the PayPal end, and we can help if it's not clear how to implement that with Perch.

That's where I'm not clear. First, I need to determine how to classify the transaction with Perch.

Option 1: handling as the value - Used with Add to Cart buttons and the Cart Upload command.

Option 2: handling_cart as the value - Used with third-party shopping carts or custom carts that initiate payment processing with the Cart Upload command.

My guess is that it would be the second option?

So once I've figured that out, to use it with perch, all I would need to do is replace the shipping input with a handling_cart input in the paypal form, correct?

Drew McLellan

Drew McLellan 2638 points
Perch Support

I have no clue - I don't think this is something that app does. I would have thought it could be added as you describe, but it's not something I have any experience of.

Okay. I'll tinker with it some more and if that goes nowhere, I'll see if we can wait out for the new shop app.