public function CheckoutController::complete in Ubercart 8.4
Completes the sale and finishes checkout.
1 string reference to 'CheckoutController::complete'
- uc_cart.routing.yml in uc_cart/
uc_cart.routing.yml - uc_cart/uc_cart.routing.yml
File
- uc_cart/
src/ Controller/ CheckoutController.php, line 254
Class
- CheckoutController
- Controller routines for the checkout.
Namespace
Drupal\uc_cart\ControllerCode
public function complete() {
if (!$this->session
->has('cart_order') || !$this->session
->has('uc_checkout_complete_' . $this->session
->get('cart_order'))) {
return $this
->redirect('uc_cart.cart');
}
$order = $this
->loadOrder();
if (empty($order)) {
// If order was lost, display customer message and log the occurrence.
$this
->messenger()
->addError($this
->t("We're sorry. An error occurred while processing your order that prevents us from completing it at this time. Please contact us and we will resolve the issue as soon as possible."));
$this
->getLogger('uc_cart')
->error('An empty order made it to checkout! Cart order ID: @cart_order', [
'@cart_order' => $this->session
->get('cart_order'),
]);
return $this
->redirect('uc_cart.cart');
}
$this->session
->remove('uc_checkout_complete_' . $this->session
->get('cart_order'));
$this->session
->remove('cart_order');
// Add a comment to let sales team know this came in through the site.
uc_order_comment_save($order
->id(), 0, $this
->t('Order created through website.'), 'admin');
return $this->cartManager
->completeSale($order);
}