FreeOrder.php in Ubercart 8.4
File
payment/uc_payment/src/Plugin/Ubercart/PaymentMethod/FreeOrder.php
View source
<?php
namespace Drupal\uc_payment\Plugin\Ubercart\PaymentMethod;
use Drupal\Core\Form\FormStateInterface;
use Drupal\uc_order\OrderInterface;
use Drupal\uc_payment\PaymentMethodPluginBase;
class FreeOrder extends PaymentMethodPluginBase {
public function cartDetails(OrderInterface $order, array $form, FormStateInterface $form_state) {
return [
'#markup' => $this
->t('Continue with checkout to complete your order.'),
];
}
public function orderSubmit(OrderInterface $order) {
if ($order
->getTotal() >= 0.01) {
return $this
->t('We cannot process your order without payment.');
}
uc_payment_enter($order
->id(), 'free_order', 0, 0, NULL, $this
->t('Checkout completed for a free order.'));
}
}