Commit 05f648ec authored by Telenkov Ruslan's avatar Telenkov Ruslan

promo

parent e986de77
......@@ -9,21 +9,20 @@ function check_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_sta
{
if ($form_id == 'commerce_checkout_flow_multistep_default'){
//убираю ненужные поля с формы
$form['shipping_information']['shipping_profile'] = null;
$form['shipping_information']['recalculate_shipping'] = null;
$form['shipping_information']['shipping_profile']['#access'] = false;
$form['shipping_information']['recalculate_shipping']['#access'] = false;
//if ($form_state->getUserInput()['shipping_information']['shipments'][0]['shipping_method'][0] == '2--default'){
//добавляю поле с адресом и прикручиваю стейты по радиокнопкам (наше в консоли разраба)
$form['shipping_information']['site_address'] = array (
'#type' => 'textfield',
'#title' => ('Site address:'),
'#states' => array(
'visible' => array(
':input[name = "shipping_information[shipments][0][shipping_method][0]"]' => array(
'value' => '2--default',
),
$form["shipping_information"]["shipments"][0]["field_adress"]['#states'] = [
'visible' => [
':input[name = "shipping_information[shipments][0][shipping_method][0]"]' => array(
'value' => '1--default',
),
),
);
]
];
// по айди магазина получаю магазин
$formTest = $form_state->getBuildInfo()['callback_object'];
$store = \Drupal::entityTypeManager()
......@@ -37,11 +36,17 @@ function check_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_sta
$stocks = $store[$formTest->getOrder()->get('store_id')->target_id]->field_stocks->referencedEntities();
// прохожусь по складам
foreach ($stocks as $stock){
$concr_stock[] = $stock->get('name')->value;
}
$form["shipping_information"]["shipments"][0]["field_stocks"]["widget"]["#options"] = $concr_stock;
//}
$form["shipping_information"]["shipments"][0]["field_stocks"]['#states'] = [
'visible' => [
':input[name = "shipping_information[shipments][0][shipping_method][0]"]' => array(
'value' => '2--default',
),
]
];
}
}
......@@ -5,5 +5,4 @@ use Drupal\Core\Form\FormStateInterface;
* Implements hook_form_alter().
*/
function commerce_chekout_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
$a=1;
}
name: Promo
package: Custom
type: module
core_version_requirement: ^8.8 || ^9
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment