Overview

Packages

  • IllApps
    • Shipsync
  • PHP

Classes

  • IllApps_Shipsync_Block_Adminhtml_Sales_Order_Shipment_Abstract
  • IllApps_Shipsync_Block_Adminhtml_Sales_Order_Shipment_Packages_View
  • IllApps_Shipsync_Block_Adminhtml_Sales_Order_Shipment_Packages_View_Form
  • IllApps_Shipsync_Block_Adminhtml_Sales_Order_Shipment_Packages_View_Items
  • IllApps_Shipsync_Block_Adminhtml_Sales_Order_Shipment_Packages_View_Package
  • IllApps_Shipsync_Block_Adminhtml_Sales_Order_Shipment_View
  • IllApps_Shipsync_Block_Adminhtml_Sales_Order_View
  • IllApps_Shipsync_Block_Adminhtml_Shipsync
  • IllApps_Shipsync_Block_Adminhtml_Shipsync_Option
  • IllApps_Shipsync_Helper_Data
  • IllApps_Shipsync_IndexController
  • IllApps_Shipsync_Model_Mysql4_Setup
  • IllApps_Shipsync_Model_Mysql4_Shipment_Package
  • IllApps_Shipsync_Model_Mysql4_Shipment_Package_Collection
  • IllApps_Shipsync_Model_Sales_Order_Shipment_Package
  • IllApps_Shipsync_Model_Sales_Order_Shipment_Package_Item
  • IllApps_Shipsync_Model_Sales_Quote_Address
  • IllApps_Shipsync_Model_Shipment_Abstract
  • IllApps_Shipsync_Model_Shipment_Package
  • IllApps_Shipsync_Model_Shipment_Request
  • IllApps_Shipsync_Model_Shipment_Response
  • IllApps_Shipsync_Model_Shipment_Result
  • IllApps_Shipsync_Model_Shipping_Carrier_Abstract
  • IllApps_Shipsync_Model_Shipping_Carrier_Fedex
  • IllApps_Shipsync_Model_Shipping_Carrier_Fedex_Address
  • IllApps_Shipsync_Model_Shipping_Carrier_Fedex_Package
  • IllApps_Shipsync_Model_Shipping_Carrier_Fedex_Rate
  • IllApps_Shipsync_Model_Shipping_Carrier_Fedex_Ship
  • IllApps_Shipsync_Model_Shipping_Carrier_Fedex_Source_B13afilingoption
  • IllApps_Shipsync_Model_Shipping_Carrier_Fedex_Source_Freemethod
  • IllApps_Shipsync_Model_Shipping_Carrier_Fedex_Source_Label_Image
  • IllApps_Shipsync_Model_Shipping_Carrier_Fedex_Source_Label_Orientation
  • IllApps_Shipsync_Model_Shipping_Carrier_Fedex_Source_Label_Stock
  • IllApps_Shipsync_Model_Shipping_Carrier_Fedex_Source_Method
  • IllApps_Shipsync_Model_Shipping_Carrier_Fedex_Source_Packaging
  • IllApps_Shipsync_Model_Shipping_Carrier_Fedex_Source_Rate
  • IllApps_Shipsync_Model_Shipping_Carrier_Fedex_Source_Ratediscount
  • IllApps_Shipsync_Model_Shipping_Carrier_Fedex_Source_Residencedelivery
  • IllApps_Shipsync_Model_Shipping_Carrier_Fedex_Source_Signature
  • IllApps_Shipsync_Model_Shipping_Carrier_Fedex_Source_Smartpost_Endorsement
  • IllApps_Shipsync_Model_Shipping_Carrier_Fedex_Source_Smartpost_Indicia
  • IllApps_Shipsync_Model_Shipping_Carrier_Fedex_Source_Unitofmeasure
  • IllApps_Shipsync_Model_Shipping_Carrier_Fedex_Track
  • IllApps_Shipsync_Model_Shipping_Package
  • IllApps_Shipsync_Model_Shipping_Package_Item
  • IllApps_Shipsync_Model_Shipping_Package_Origins
  • IllApps_Shipsync_Model_Shipping_Package_Sort
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: 
  3: /**
  4:  * ShipSync
  5:  *
  6:  * @category   IllApps
  7:  * @package    IllApps_Shipsync
  8:  * @copyright  Copyright (c) 2014 EcoMATICS, Inc. DBA IllApps (http://www.illapps.com)
  9:  * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 10:  */
 11: 
 12: /**
 13:  * IllApps_Shipsync_Model_Shipping_Carrier_Fedex_Package
 14:  */
 15: class IllApps_Shipsync_Model_Shipping_Carrier_Fedex_Package
 16: {
 17:        
 18:     protected $_fedexPackages;
 19:     
 20:     
 21:     /**
 22:      * __construct
 23:      */
 24:     public function __construct()
 25:     {
 26:         // Set FedEx Packages
 27:         $this->_fedexPackages = array
 28:         (
 29:             'FEDEX_ENVELOPE' => array
 30:             (
 31:                 'label'         => Mage::helper('usa')->__('FedEx Envelope'),
 32:                 'length'        => 13.2,
 33:                 'width'         => 9.25,
 34:                 'height'        => 0.1,
 35:                 'baseline'      => 0.1125,
 36:                 'max_weight'    => 1.1
 37:             ),
 38:             'FEDEX_PAK' => array
 39:             (
 40:                 'label'         => Mage::helper('usa')->__('FedEx Pak'),        
 41:                 'length'        => 15.5,
 42:                 'width'         => 12.0,
 43:                 'height'        => 0.1,
 44:                 'baseline'      => 0.0625,
 45:                 'max_weight'    => 5.5
 46:             ),
 47:             'FEDEX_TUBE' => array
 48:             (
 49:                 'label'         => Mage::helper('usa')->__('FedEx Tube'),       
 50:                 'length'        => 38,
 51:                 'width'         => 3.95,
 52:                 'height'        => 3.95,
 53:                 'baseline'      => 0.0,
 54:                 'max_weight'    => 20.0
 55:             ),
 56:             'FEDEX_10KG_BOX' => array
 57:             (
 58:                 'label'         => Mage::helper('usa')->__('FedEx 10kg Box'),       
 59:                 'length'        => 15.81,
 60:                 'width'         => 12.94,
 61:                 'height'        => 10.19,
 62:                 'baseline'      => 0.0,
 63:                 'max_weight'    => 22.0
 64:             ),
 65:             'FEDEX_25KG_BOX' => array
 66:             (
 67:                 'label'         => Mage::helper('usa')->__('FedEx 25kg Box'),       
 68:                 'length'        => 21.56,
 69:                 'width'         => 16.56,
 70:                 'height'        => 13.19,
 71:                 'baseline'      => 0.0,
 72:                 'max_weight'    => 55.0
 73:             ),
 74:             'YOUR_PACKAGING' => array
 75:             (
 76:                 'label'         => Mage::helper('usa')->__('Your Packaging'),       
 77:                 'length'        => null,
 78:                 'width'         => null,
 79:                 'height'        => null,                
 80:                 'baseline'      => null,
 81:                 'max_weight'    => Mage::getStoreConfig('usa/shipping_carriers_fedex/max_package_weight')
 82:             )
 83:         );
 84:         
 85: 
 86:         if ($this->getDimensionUnits() == 'CM')
 87:         {
 88:             foreach($this->_fedexPackages as &$package)
 89:             {
 90:                 $this->toCM($package['length']);
 91:                 $this->toCM($package['width']);
 92:                 $this->toCM($package['height']);
 93:             }
 94:         }
 95: 
 96:         // Convert to kilograms
 97:         if ($this->getWeightUnits() == 'KG')
 98:         {
 99:             foreach($this->_fedexPackages as &$package)
100:             {
101:                 $this->toKG($package['max_weight']);
102:                 $this->toKG($package['baseline']);
103:             }
104:         }
105: 
106:         // Convert to grams
107:         if ($this->getWeightUnits() == 'G')
108:         {
109:             foreach($this->_fedexPackages as &$package)
110:             {
111:                 $this->toG($package['max_weight']);
112:                 $this->toG($package['baseline']);
113:             }
114:         }
115:                 
116:         // Set volume
117:         $this->setVolume();
118:     }
119: 
120:         
121:     /**
122:      * getFedexPackages
123:      *
124:      * @return array
125:      */
126:     public function getFedexPackages()
127:     {
128:         return $this->_fedexPackages;
129:     }
130:     
131:     
132:     /**
133:      * getPackages
134:      *
135:      * @return array
136:      */
137:     public function getPackages()
138:     {
139:         $packages = array();
140:         
141:         if ($_fedexPackages = explode(',', Mage::getStoreConfig('carriers/fedex/packaging'))) {
142:             foreach ($this->getFedexPackages() as $key => $value) {
143:                 foreach ($_fedexPackages as $_fedexPackage) {
144:                     if ($_fedexPackage == $key) {
145:                         $packages[$key] = $value;
146:                     }
147:                 }
148:             }
149:         }
150:         
151:         if (is_array($packages)) {
152:             return $packages;
153:         }
154:         
155:         return false;
156:     }
157:            
158:     
159:     /**
160:      * getDimensionUnits
161:      *
162:      * @return string
163:      */
164:     public function getDimensionUnits()
165:     {
166:         return Mage::getSingleton('usa/shipping_carrier_fedex')->getDimensionUnits();
167:     }
168:     
169:     
170:     
171:     /**
172:      * getWeightUnits
173:      *
174:      * @return string
175:      */
176:     public function getWeightUnits()
177:     {
178:         return Mage::getSingleton('usa/shipping_carrier_fedex')->getWeightUnits();
179:     }
180:     
181:     
182:     
183:     /**
184:      * setVolume
185:      */
186:     public function setVolume()
187:     {
188:         foreach ($this->_fedexPackages as $key => &$package) {
189:             $this->_fedexPackages[$key]['max_volume'] = round($package['width'] * $package['height'] * $package['length'], 2);
190:         }
191:     }
192:     
193:     
194:     
195:     /**
196:      * toCM
197:      *
198:      * @param int $val
199:      */
200:     public function toCM(&$val)
201:     {
202:         $val = round($val * 2.54, 1);
203:     }
204:     
205:     
206:     
207:     /**
208:      * toG
209:      *
210:      * @param int $val
211:      */
212:     public function toG(&$val)
213:     {
214:         $val = round($val * 453.59237, 1);
215:     }
216:     
217:     
218:     
219:     /**
220:      * toKG
221:      *
222:      * @param int $val
223:      */
224:     public function toKG(&$val)
225:     {
226:         $val = round($val * 0.45359237, 1);
227:     }
228:     
229:     
230:     
231:     /**
232:      * getPackageMaxWeight
233:      *
234:      * @param string $value
235:      * @return string
236:      */
237:     public function getPackageMaxWeight($value)
238:     {
239:         return $this->_fedexPackages[$value]['max_weight'];
240:     }
241:     
242:     
243:     
244:     /**
245:      * getPackageLength
246:      *
247:      * @param string $value
248:      * @return string
249:      */
250:     public function getPackageLength($value)
251:     {
252:         return $this->_fedexPackages[$value]['length'];
253:     }
254:     
255:     
256:     
257:     /**
258:      * getPackageWidth
259:      *
260:      * @param string $packageValue
261:      * @return string
262:      */
263:     public function getPackageWidth($alue)
264:     {
265:         return $this->_fedexPackages[$value]['width'];
266:     }
267:     
268:     
269:     
270:     /**
271:      * getPackageHeight
272:      *
273:      * @param string $packageValue
274:      * @return string
275:      */
276:     public function getPackageHeight($value)
277:     {
278:         return $this->_fedexPackages[$value]['height'];
279:     }
280:     
281:     
282:     
283:     /**
284:      * getPackageBaseline
285:      *
286:      * @param string $packageValue
287:      * @return string
288:      */
289:     public function getPackageBaseline($value)
290:     {
291:         return $this->_fedexPackages[$value]['baseline'];
292:     }
293:     
294:     /**
295:      * getPackageLabel
296:      *
297:      * @param string $packageValue
298:      * @return string
299:      */
300:     public function getPackageLabel($value)
301:     {
302:         return $this->_fedexPackages[$value]['label'];
303:     }
304:     
305:     /**
306:      * asArray
307:      *
308:      * @param mixed $test
309:      * @return array
310:      */
311:     public function asArray($test = null)
312:     {
313:         if (!isset($test)) {
314:             return $this->_fedexPackages;
315:         }
316:         
317:         else {
318:             $test = explode(',', $test);
319:             
320:             foreach ($this->_fedexPackages as $package) {
321:                 if (in_array($package['label'], $test)) {
322:                     $packages[] = $package;
323:                 }
324:             }
325:             
326:             return (isset($packages) ? $packages : false);
327:         }
328:     }
329:     
330:     
331:     
332:     /**
333:      * isFedexPackage
334:      *
335:      * @param string $packageCode
336:      * @return bool
337:      */
338:     public function isFedexPackage($packageCode)
339:     {
340:         foreach ($this->_fedexPackages as $key => $value) {
341:             if ($packageCode == $key) {
342:                 return true;
343:             }
344:         }
345:         return false;
346:     }
347:     
348:     
349:     
350:     /**
351:      * getPackageCodes
352:      *
353:      * @return string
354:      */
355:     public function getPackageCodes()
356:     {
357:         foreach ($this->_fedexPackages as $key => $value) {
358:             $var[] = $key;
359:         }
360:         
361:         return $var;
362:     }
363:     
364:     
365:     
366:     /**
367:      * getPackageName
368:      *
369:      * @param string $packageValue
370:      * @return string
371:      */
372:     public function getPackageName($value)
373:     {
374:         foreach ($this->_fedexPackages as $key => $value) {
375:             if ($value == $key) {
376:                 return $value['label'];
377:             }
378:         }
379:     }
380:        
381: }
382: 
shipsync-community API documentation generated by ApiGen 2.8.0