Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F1046700
D348.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Jun 29, 2:30 AM
Size
2 KB
Mime Type
text/x-diff
Expires
Mon, Jun 30, 2:30 AM (3 h, 32 m)
Engine
blob
Format
Raw Data
Handle
676707
Attached To
D348: MINC-195 Don't use "break" during shipping quote aggregation
D348.diff
View Options
Index: branches/5.2.x/units/shipping_quote_engines/shipping_quote_collector.php
===================================================================
--- branches/5.2.x/units/shipping_quote_engines/shipping_quote_collector.php
+++ branches/5.2.x/units/shipping_quote_engines/shipping_quote_collector.php
@@ -60,30 +60,8 @@
// exclude not available shipping quotes by products
$limit_types = unserialize($params['limit_types']);
- if (is_array($limit_types) && !in_array('ANY', $limit_types)) {
- if (count($limit_types) == 0) {
- break;
- }
-
- $available_types = Array ();
- foreach ($shipping_types as $a_type) {
- $include = false; // exclude by default
-
- foreach ($limit_types as $limit) {
- $include = $include || preg_match("/^$limit/", $a_type['ShippingId']);
- if ($include) {
- break;
- }
- }
-
- if (!$include) {
- continue;
- }
-
- $available_types[ $a_type['ShippingId'] ] = $a_type;
- }
-
- $shipping_types = $available_types;
+ if ( is_array($limit_types) && count($limit_types) && !in_array('ANY', $limit_types) ) {
+ $shipping_types = $this->applyLimitations($shipping_types, $limit_types);
}
// exclude Selected Products Only shipping types, not matching products
@@ -108,6 +86,39 @@
return $shipping_types;
}
+ /**
+ * Applies limitations to shipping types
+ *
+ * @param array $shipping_types Shipping types.
+ * @param array $limit_types Limit types.
+ *
+ * @return array
+ */
+ protected function applyLimitations(array $shipping_types, array $limit_types)
+ {
+ $available_types = array();
+
+ foreach ( $shipping_types as $a_type ) {
+ $include = false; // Exclude by default.
+
+ foreach ( $limit_types as $limit ) {
+ $include = $include || preg_match('/^' . $limit . '/', $a_type['ShippingId']);
+
+ if ( $include ) {
+ break;
+ }
+ }
+
+ if ( !$include ) {
+ continue;
+ }
+
+ $available_types[$a_type['ShippingId']] = $a_type;
+ }
+
+ return $available_types;
+ }
+
function GetAvailableShippingTypes()
{
$shipping_types = Array ();
Event Timeline
Log In to Comment