function uc_ups_product_alter_validate in Ubercart 8.4
Same name and namespace in other branches
- 5 shipping/uc_ups/uc_ups.module \uc_ups_product_alter_validate()
- 6.2 shipping/uc_ups/uc_ups.module \uc_ups_product_alter_validate()
- 7.3 shipping/uc_ups/uc_ups.module \uc_ups_product_alter_validate()
Validation handler for UPS product fields.
See also
uc_ups_form_alter()
1 string reference to 'uc_ups_product_alter_validate'
- uc_ups_form_node_form_alter in shipping/
uc_ups/ uc_ups.module - Implements hook_form_BASE_FORM_ID_alter() for node_form().
File
- shipping/
uc_ups/ uc_ups.module, line 129 - UPS shipping quote module.
Code
function uc_ups_product_alter_validate($form, FormStateInterface $form_state) {
$ups_config = \Drupal::config('uc_ups.settings');
if ($form_state
->hasValue('shippable') && ($form_state
->getValue('shipping_type') == 'small_package' || $form_state
->isValueEmpty('shipping_type') && $ups_config
->get('uc_store_shipping_type') == 'small_package')) {
if ($form_state
->getValue([
'ups',
'pkg_type',
]) == '02' && ($form_state
->isValueEmpty('dim_length') || $form_state
->isValueEmpty('dim_width')) || $form_state
->isValueEmpty('dim_height')) {
$form_state
->setErrorByName('base][dimensions', t('Dimensions are required for custom packaging.'));
}
}
}