You are here

public function StockEnforcementConfigForm::submitForm in Commerce Stock 8

Form submission handler.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides ConfigFormBase::submitForm

File

modules/enforcement/src/Form/StockEnforcementConfigForm.php, line 88

Class

StockEnforcementConfigForm
The stock enforcement configuration form.

Namespace

Drupal\commerce_stock_enforcement\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $values = $form_state
    ->getValues();
  $config = $this
    ->config('commerce_stock_enforcement.settings');
  $config
    ->set('insufficient_stock_cart', $values['insufficient_stock_cart']);
  $config
    ->set('insufficient_stock_add_to_cart_zero_in_cart', $values['insufficient_stock_add_to_cart_zero_in_cart']);
  $config
    ->set('insufficient_stock_add_to_cart_quantity_in_cart', $values['insufficient_stock_add_to_cart_quantity_in_cart']);
  $config
    ->save();
  $this
    ->messenger()
    ->addMessage($this
    ->t('Stock enforcement settings updated.'));
}