1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27: 28: 29: 30: 31:
32: class Mage_Usa_Helper_Data extends Mage_Core_Helper_Abstract
33: {
34: 35: 36: 37: 38: 39: 40: 41:
42: public function convertMeasureWeight($value, $sourceWeightMeasure, $toWeightMeasure)
43: {
44: if ($value) {
45: $locale = Mage::app()->getLocale()->getLocale();
46: $unitWeight = new Zend_Measure_Weight($value, $sourceWeightMeasure, $locale);
47: $unitWeight->setType($toWeightMeasure);
48: return $unitWeight->getValue();
49: }
50: return null;
51: }
52:
53: 54: 55: 56: 57: 58: 59: 60:
61: public function convertMeasureDimension($value, $sourceDimensionMeasure, $toDimensionMeasure)
62: {
63: if ($value) {
64: $locale = Mage::app()->getLocale()->getLocale();
65: $unitDimension = new Zend_Measure_Length($value, $sourceDimensionMeasure, $locale);
66: $unitDimension->setType($toDimensionMeasure);
67: return $unitDimension->getValue();
68: }
69: return null;
70: }
71:
72: 73: 74: 75: 76: 77:
78: public function getMeasureWeightName($key)
79: {
80: $weight = new Zend_Measure_Weight(0);
81: $conversionList = $weight->getConversionList();
82: if (!empty($conversionList[$key]) && !empty($conversionList[$key][1])) {
83: return $conversionList[$key][1];
84: }
85: return '';
86: }
87:
88: 89: 90: 91: 92: 93:
94: public function getMeasureDimensionName($key)
95: {
96: $weight = new Zend_Measure_Length(0);
97: $conversionList = $weight->getConversionList();
98: if (!empty($conversionList[$key]) && !empty($conversionList[$key][1])) {
99: return $conversionList[$key][1];
100: }
101: return '';
102: }
103:
104: 105: 106: 107: 108: 109:
110: public function displayGirthValue($shippingMethod)
111: {
112: if (in_array($shippingMethod, array(
113: 'usps_Priority Mail International',
114: 'usps_Priority Mail International Small Flat Rate Box',
115: 'usps_Priority Mail International Medium Flat Rate Box',
116: 'usps_Priority Mail International Large Flat Rate Box',
117: 'usps_Priority Mail International Flat Rate Envelope',
118: 'usps_Express Mail International Flat Rate Envelope',
119: 'usps_Express Mail Hold For Pickup',
120: 'usps_Express Mail International',
121: 'usps_First-Class Mail International Package',
122: 'usps_First-Class Mail International Parcel',
123: 'usps_First-Class Mail International Large Envelope',
124: 'usps_First-Class Mail International',
125: 'usps_Global Express Guaranteed (GXG)',
126: 'usps_USPS GXG Envelopes',
127: 'usps_Global Express Guaranteed Non-Document Non-Rectangular',
128: 'usps_Media Mail',
129: 'usps_Parcel Post',
130: 'usps_Express Mail',
131: 'usps_Priority Mail'
132: ))) {
133: return true;
134: } else {
135: return false;
136: }
137: }
138: }
139: