public function CartForm::submitForm in Basic cart 8.2
Same name and namespace in other branches
- 8.6 src/Form/CartForm.php \Drupal\basic_cart\Form\CartForm::submitForm()
- 8 src/Form/CartForm.php \Drupal\basic_cart\Form\CartForm::submitForm()
- 8.0 src/Form/CartForm.php \Drupal\basic_cart\Form\CartForm::submitForm()
- 8.3 src/Form/CartForm.php \Drupal\basic_cart\Form\CartForm::submitForm()
- 8.4 src/Form/CartForm.php \Drupal\basic_cart\Form\CartForm::submitForm()
- 8.5 src/Form/CartForm.php \Drupal\basic_cart\Form\CartForm::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/ CartForm.php, line 84
Class
- CartForm
- Cart page form.
Namespace
Drupal\basic_cart\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$config = Utility::cartSettings();
if ($config
->get('quantity_status')) {
foreach ($form_state
->getValue('cartcontents') as $nid => $value) {
$quantity = (int) $value;
if ($quantity > 0) {
$_SESSION['basic_cart']['cart_quantity'][$nid] = $quantity;
}
elseif ($quantity == 0) {
unset($_SESSION['basic_cart']['cart'][$nid]);
unset($_SESSION['basic_cart']['cart_quantity'][$nid]);
}
}
Utility::cartUpdatedMessage();
}
$config = Utility::cartSettings();
if ($config
->get('order_status') && $form_state
->getValue('checkout')) {
$url = new Url('basic_cart.checkout');
$form_state
->setRedirectUrl($url);
}
}