You are here

public function AddToCartWithQuantity::submitForm in Basic cart 8

Same name and namespace in other branches
  1. 8.0 src/Form/AddToCartWithQuantity.php \Drupal\basic_cart\Form\AddToCartWithQuantity::submitForm()

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 FormInterface::submitForm

File

src/Form/AddToCartWithQuantity.php, line 62

Class

AddToCartWithQuantity

Namespace

Drupal\basic_cart\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $id = (int) $form_state
    ->getValue('id');
  $quantity = (int) $form_state
    ->getValue('quantity');
  $langcode = $form_state
    ->getValue('langcode');
  $entitytype = $form_state
    ->getValue('entitytype');
  $params = array(
    "quantity" => $quantity,
    "langcode" => $langcode,
    "entitytype" => $entitytype,
  );
  Utility::addToCart($id, $params);
}