Skip to main content
straysaverguy
Participant
June 22, 2019
Answered

How to change Paypal's shipping cost method to base cost + per item cost

  • June 22, 2019
  • 1 reply
  • 519 views

Hello all,

We're moving away from a credit card processor that allowed us to set a base shipping cost, per order, and then add per item costs to the order.  This method was very effective for us, and we had been using that service for about 17 years.  Sadly, this service is now failing badly, and we were asked to go to PayPal.  The problem with PayPal is there does not appear to be any way to calculate shipping as we've done in the past. 

Has anyone modified their recent Add to Cart button code to accommodate this method of adding shipping?  The only thing we can find about it is posts about having two lines of code, one for shipping and one for shipping2.  However, this solution appears in a very old version of their button, and we're not sure if it can work with their current code.

If anyone has any ideas, please let us know.

TIA

This topic has been closed for replies.
Correct answer osgood_

Not sure what your workflow is but its more controllable if you pass your own shopping cart information to the paypal gateway.

Normally you would set a range of shipping costs for the items - 1 item - £6.00, 2-5 items - £8.00, 6-10 items - £12.00. A more realistic approach as you would expect shipping costs to reach a ceiling at some point.

<?php

/ add up quantity total in cart - form field

$quantity_in_cart = 6;

// add up items in cart

$items_in_cart = 2;

// 1 item in cart - shipping £6.00

if($quantity_in_cart === 1) {

$shipping = 6.00;

$shipping = number_format((float)$shipping, 2, '.', '');

}

// Between 2 - 5 items in cart - shipping £8.00

if($quantity_in_cart > 1 && $quantity_in_cart <=5) {

$shipping = 8.00 / $items_in_cart;

$shipping = number_format((float)$shipping, 2, '.', '');

}

// Between 6 - 10 items in cart - shipping £12.00

if($quantity_in_cart > 5 && $quantity_in_cart <=10) {

$shipping = 12.00 / $items_in_cart;

$shipping = number_format((float)$shipping, 2, '.', '');

}

?>

// Below would be the result output via a loop from a php cart session or you could use a javascript array

// item 1 - these are paypal hidden field names

<input type="hidden" name="item_name_1" value="Item 1">

<input type="hidden" name="amount_1" value="15.00">

<input type="hidden" name="quantity_1" value="4">

<input type="hidden" name="shipping_1" value="<?php echo $shipping; ?>">

// item 2 -these are paypal hidden field names

<input type="hidden" name="item_name_2" value="Item 2">

<input type="hidden" name="amount_2" value="20.00">

<input type="hidden" name="quantity_2" value="2">

<input type="hidden" name="shipping_2" value="<?php echo $shipping; ?>">

1 reply

Nancy OShea
Community Expert
Community Expert
June 22, 2019

#1 This is not a Dreamweaver question. 

#2 Don't use PayPal if it doesn't suit your needs. There are lots and lots of PCI compliant shopping carts that provide more advanced pricing options.  Ask your merchant bank which payment processors or gateways you can use.  This is important because whichever shopping cart you choose will need to be compatible with your bank so you can get paid.

The shopping cart I use supports multiple payment processors including Authorize.net, PayPal, First Data, Stripe and many more....  

Shopify

https://www.shopify.com/

ASecureCart

ASecureCart Shopping Cart. A secure, PCI Compliant shopping cart.

WebAsssit e-commerce options

Compare eCommerce software solutions for PayPal merchants | WebAssist

WooCommerce plugin for WordPress

WooCommerce - Sell Online With The eCommerce Platform for WordPress .

Nancy O'Shea— Product User & Community Expert
straysaverguy
Participant
June 22, 2019

Seems like a Dreamweaver question to me.  If it involves adding HTML code (which it does) to a Web page created and maintained with Dreamweaver, I fail to see how it cannot be a Dreamweaver question.

Nancy OShea
Community Expert
Community Expert
June 22, 2019

Advanced payment options are not a simple front end code question.  That's a question for your shopping cart provider.  And you must establish the pricing rules & variables by logging in to your shopping cart provider's website or backend CMS.   Incidentally, different shopping carts have different code requirements.  So whatever code you used previously in your web pages will most likely not work with a new shopping cart.   Again, refer to your shopping cart provider's documentation.

Nancy O'Shea— Product User & Community Expert