public function ShipmentDeleteForm::submitForm in Ubercart 8.4
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
- shipping/
uc_fulfillment/ src/ Form/ ShipmentDeleteForm.php, line 113
Class
- ShipmentDeleteForm
- Decides to release packages to be put on another shipment.
Namespace
Drupal\uc_fulfillment\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$methods = $this->moduleHandler
->invokeAll('uc_fulfillment_method');
if ($this->shipment
->getTrackingNumber() && isset($methods[$this->shipment
->getShippingMethod()]['cancel']) && function_exists($methods[$this->shipment
->getShippingMethod()]['cancel'])) {
$result = call_user_func($methods[$this->shipment
->getShippingMethod()]['cancel'], $this->shipment
->getTrackingNumber());
if ($result) {
$this->shipment
->delete();
}
else {
$this
->messenger()
->addWarning($this
->t('The shipment %tracking could not be canceled with %carrier. To delete it anyway, remove the tracking number and try again.', [
'%tracking' => $this->shipment
->getTrackingNumber(),
'%carrier' => $this->shipment
->getCarrier(),
]));
}
}
else {
$this->shipment
->delete();
}
$form_state
->setRedirectUrl($this
->getCancelUrl());
}