Skip to content
This repository has been archived by the owner on Sep 3, 2021. It is now read-only.

demo to calculate shipping on international #30

Closed
relipse opened this issue Jun 10, 2016 · 1 comment
Closed

demo to calculate shipping on international #30

relipse opened this issue Jun 10, 2016 · 1 comment

Comments

@relipse
Copy link

relipse commented Jun 10, 2016

Hello, I love the demo you put up for domestic US, but is there a way you could put up a demo to calculate shipping for international orders? (Including Canada)
Thanks

@jshor
Copy link

jshor commented Jul 2, 2016

Here's an example for shipping internationally (in this case, to Australia) based on the example in the USPS docs:

<?php

use USPS\RatePackage;

$rate = new \USPS\Rate('xxxx');
$rate->setInternationalCall(true);
$rate->addExtraOption('Revision', 2);

$package = new RatePackage;
$package->setPounds(15.12345678);
$package->setOunces(0);
$package->setField('Machinable', 'True');
$package->setField('MailType', 'Package');
$package->setField('GXG', array(
  'POBoxFlag' => 'Y',
  'GiftFlag' => 'Y'
));
$package->setField('ValueOfContents', 200);
$package->setField('Country', 'Australia');
$package->setField('Container', 'RECTANGULAR');
$package->setField('Size', 'LARGE');
$package->setField('Width', 10);
$package->setField('Length', 15);
$package->setField('Height', 10);
$package->setField('Girth', 0);
$package->setField('OriginZip', 18701);
$package->setField('CommercialFlag', 'N');
$package->setField('AcceptanceDateTime', '2016-07-05T13:15:00-06:00');
$package->setField('DestinationPostalCode', '2046');

// add the package to the rate stack
$rate->addPackage($package);
// Perform the request and print out the result
print_r($rate->getRate());
print_r($rate->getArrayResponse());
// Was the call successful
if ($rate->isSuccess()) {
    echo 'Done';
} else {
    echo 'Error: ' . $rate->getErrorMessage();
}

VinceG pushed a commit that referenced this issue Sep 8, 2016
@VinceG VinceG closed this as completed Sep 8, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants