public function AddToCart::submitForm in Basic cart 8
Same name and namespace in other branches
- 8.0 src/Form/AddToCart.php \Drupal\basic_cart\Form\AddToCart::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/ AddToCart.php, line 51 
Class
Namespace
Drupal\basic_cart\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
  $id = (int) $form_state
    ->getValue('id');
  $langcode = $form_state
    ->getValue('langcode');
  $entitytype = $form_state
    ->getValue('entitytype');
  $params = array(
    "quantity" => 1,
    "langcode" => $langcode,
    "entitytype" => $entitytype,
  );
  Utility::addToCart($id, $params);
}