File tree Expand file tree Collapse file tree 3 files changed +19
-9
lines changed
code/core/Mage/Usa/Model/Shipping/Carrier
design/adminhtml/default/default/template/system/shipping Expand file tree Collapse file tree 3 files changed +19
-9
lines changed Original file line number Diff line number Diff line change @@ -68,17 +68,13 @@ protected function _beforeSave()
68
68
if (!method_exists ($ sourceModel , 'toOptionArray ' )) {
69
69
Mage::throwException (Mage::helper ('usa ' )->__ ('Method toOptionArray not found in source model. ' ));
70
70
}
71
- $ hasCorrectValue = false ;
72
71
$ value = $ this ->getValue ();
73
72
foreach ($ sourceModel ->toOptionArray () as $ allowedValue ) {
74
73
if (isset ($ allowedValue ['value ' ]) && $ allowedValue ['value ' ] == $ value ) {
75
- $ hasCorrectValue = true ;
76
- break ;
74
+ return $ this ;
77
75
}
78
76
}
79
- if (!$ hasCorrectValue ) {
80
- Mage::throwException (Mage::helper ('usa ' )->__ ('Field "%s" has wrong value. ' , $ this ->_nameErrorField ));
81
- }
82
- return $ this ;
77
+
78
+ Mage::throwException (Mage::helper ('usa ' )->__ ('Field "%s" has wrong value. ' , $ this ->_nameErrorField ));
83
79
}
84
80
}
Original file line number Diff line number Diff line change @@ -23,9 +23,20 @@ public function toOptionArray()
23
23
{
24
24
$ ups = Mage::getSingleton ('usa/shipping_carrier_ups ' );
25
25
$ arr = [];
26
+
27
+ // necessary after the add of Rest API
28
+ $ origins = $ ups ->getCode ('originShipment ' );
29
+ foreach ($ origins as $ origin ) {
30
+ foreach ($ origin as $ k => $ v ) {
31
+ $ arr [] = ['value ' => $ k , 'label ' => Mage::helper ('usa ' )->__ ($ v )];
32
+ }
33
+ }
34
+
35
+ // old XML API codes
26
36
foreach ($ ups ->getCode ('method ' ) as $ k => $ v ) {
27
37
$ arr [] = ['value ' => $ k , 'label ' => Mage::helper ('usa ' )->__ ($ v )];
28
38
}
39
+
29
40
return $ arr ;
30
41
}
31
42
}
Original file line number Diff line number Diff line change 17
17
$ upsModel = Mage::getSingleton ('usa/shipping_carrier_ups ' );
18
18
$ orShipArr = $ upsModel ->getCode ('originShipment ' );
19
19
$ defShipArr = $ upsModel ->getCode ('method ' );
20
-
20
+ $ allMethodsCodes = [];
21
+ foreach (Mage::getModel ('usa/shipping_carrier_ups_source_method ' )->toOptionArray () as $ method ) {
22
+ $ allMethodsCodes []= $ method ['value ' ];
23
+ }
21
24
/** @var $this Mage_Adminhtml_Block_Template */
22
25
$ sectionCode = $ this ->getRequest ()->getParam ('section ' );
23
26
$ websiteCode = $ this ->getRequest ()->getParam ('website ' );
@@ -44,7 +47,7 @@ if (!$storeCode && $websiteCode) {
44
47
if (!in_array ($ storedOriginShipment , array_keys ($ orShipArr ))) {
45
48
$ storedOriginShipment = '' ;
46
49
}
47
- if ($ storedFreeShipment != '' && !in_array ($ storedFreeShipment , array_keys ( $ defShipArr ) )) {
50
+ if ($ storedFreeShipment != '' && !in_array ($ storedFreeShipment , $ allMethodsCodes )) {
48
51
$ storedFreeShipment = '' ;
49
52
}
50
53
if (!Mage::helper ('usa ' )->validateUpsType ($ storedUpsType )) {
You can’t perform that action at this time.
0 commit comments