<?php require_once "../vendor/autoload.php"; \EasyPost\EasyPost::setApiKey('cueqNZUb3ldeWTNX7MU3Mel8UXtaAMUi'); // CustomsItem: create $params = array("description" => "I like your dog, he's vry nice.", "hs_tariff_number" => 123456, "origin_country" => "US", "quantity" => 2, "value" => 1.23, "weight" => 14); $customs_item = \EasyPost\CustomsItem::create($params); // retrieve $retrieved = \EasyPost\CustomsItem::retrieve($customs_item->id); print_r($retrieved); // all $all = \EasyPost\CustomsItem::all(); //print_r($all); /* for($i = 0, $k = count($all); $i < $k; $i++) { print_r(\EasyPost\CustomsItem::retrieve($all[$i]->id)); } */ // CustomsInfo: create $params = array("integrated_form_type" => "form_2976", "customs_certify" => true, "customs_signer" => "Borat Sagdiyev", "contents_type" => "gift", "contents_explanation" => "", "eel_pfc" => "NOEEI 30.37(a)", "non_delivery_option" => "abandon", "restriction_type" => "none", "restriction_comments" => "", "customs_items" => array($customs_item)); $customs_info = \EasyPost\CustomsInfo::create($params); // retrieve $retrieved = \EasyPost\CustomsInfo::retrieve($customs_info->id); print_r($retrieved); // all $all = \EasyPost\CustomsInfo::all(); //print_r($all);
public function get_shipping_customs($shp_id) { $this->db->select('cst_desc as description, cst_qty as quantity, cst_weight as weight, cst_value as value, cst_hts as hs_tariff_number, cst_id'); $this->db->where('cst_shp_id', $shp_id); $items = $this->db->get('customs')->result_array(); $custom_items = array(); foreach ($items as $item) { $new_item = \EasyPost\CustomsItem::create($item); if (!empty($new_item->id)) { $this->db->set('cst_ep_ref', $new_item->id); $this->db->where('cst_id', $item['cst_id']); $this->db->update('customs'); $custom_items[] = $new_item; } } return $custom_items; }
/** * create a customs item * * @param \browner12\shipping\Contracts\OrderLine $orderLine * @return mixed */ public function customsItem(OrderLine $orderLine) { return CustomsItem::create(['description' => $orderLine->getProduct()->getDescription(), 'quantity' => $orderLine->getQuantity(), 'weight' => $orderLine->getWeight(), 'value' => $orderLine->getValue(), 'hs_tariff_number' => $orderLine->getProduct()->getTariffNumber(), 'origin_country' => $orderLine->getProduct()->getOriginCountry()]); }