D
D
DrOsd2015-07-16 12:38:08
Drupal
DrOsd, 2015-07-16 12:38:08

How to hide zip field for specific selected country in drupal commerce addressfield at checkout stage?

When placing an order in Drupal Commerce, the checkout page asks for country, zip code, and more. How can I hide the index field only when a specific country is selected, for example RU? With all the rest, leave ..
As I understand it, an alter hook is needed. A lot of experiments have not yielded results. Has anyone been able to do something similar?
Do not offer the conditional_fields module! It works great, but with separate fields, it cannot parse the addressfield into parts ..

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
andead, 2015-07-16
@andead

/**
 * Implements hook_field_widget_WIDGET_TYPE_form_alter(): addressfield_standard.
 */
function hook_field_widget_addressfield_standard_form_alter(&$element, &$form_state, $context) {
  if (страна ru) {
    $element['locality_block']['postal_code']['#access'] = FALSE;
  }
}

N
NataliaCh, 2015-07-16
@NataliaCh

javascript? not?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question