Révision b858700c
Ajouté par Assos Assos il y a environ 10 ans
drupal7/sites/all/modules/commerce/modules/order/commerce_order.rules.inc | ||
---|---|---|
48 | 48 |
'value' => array( |
49 | 49 |
'type' => 'text', |
50 | 50 |
'label' => t('Value'), |
51 |
'description' => t('The value to compare against the address component. Bear in mind that addresses using select lists for various components may use a value different from the option you select. For example, countries are selected by name, but the value is the two letter abbreviation.'), |
|
51 |
'description' => t('The value to compare against the address component. Bear in mind that addresses using select lists for various components may use a value different from the option you select. For example, countries are selected by name, but the value is the two letter abbreviation. For comparisons with multiple possible values, place separate values on new lines.'),
|
|
52 | 52 |
), |
53 | 53 |
), |
54 | 54 |
'group' => t('Commerce Order'), |
... | ... | |
220 | 220 |
'equals' => t('equals'), |
221 | 221 |
'begins with' => t('begins with'), |
222 | 222 |
'contains' => t('contains'), |
223 |
'is one of' => t('is one of'), |
|
224 |
'begins with one of' => t('begins with one of'), |
|
223 | 225 |
); |
224 | 226 |
} |
225 | 227 |
|
... | ... | |
237 | 239 |
if (!empty($wrapper->{$field_name}) && !empty($wrapper->{$field_name}->{$address_field_name})) { |
238 | 240 |
$address = $wrapper->{$field_name}->{$address_field_name}->value(); |
239 | 241 |
|
242 |
// Perform the comparison in upper case. |
|
243 |
$address_component = drupal_strtoupper($address[$component]); |
|
244 |
$value = drupal_strtoupper($value); |
|
245 |
|
|
240 | 246 |
// Make a comparison based on the operator. |
241 | 247 |
switch ($operator) { |
242 | 248 |
case 'equals': |
243 |
return $address[$component] == $value;
|
|
249 |
return $address_component == $value;
|
|
244 | 250 |
case 'begins with': |
245 |
return strpos($address[$component], $value) === 0;
|
|
251 |
return strpos($address_component, $value) === 0;
|
|
246 | 252 |
case 'contains': |
247 |
return strpos($address[$component], $value) !== FALSE; |
|
253 |
return strpos($address_component, $value) !== FALSE; |
|
254 |
case 'is one of': |
|
255 |
$list = preg_split('/[\n\r]+/', $value); |
|
256 |
return array_search($address_component, $list) !== FALSE; |
|
257 |
case 'begins with one of': |
|
258 |
$list = preg_split('/[\n\r]+/', $value); |
|
259 |
foreach ($list as $item) { |
|
260 |
if (strpos($address_component, $item) === 0) { |
|
261 |
return TRUE; |
|
262 |
} |
|
263 |
} |
|
264 |
break; |
|
248 | 265 |
} |
249 | 266 |
} |
250 | 267 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules