Other.php in Ubercart 8.4
File
payment/uc_payment_pack/src/Plugin/Ubercart/PaymentMethod/Other.php
View source
<?php
namespace Drupal\uc_payment_pack\Plugin\Ubercart\PaymentMethod;
use Drupal\uc_order\OrderInterface;
use Drupal\uc_payment\PaymentMethodPluginBase;
class Other extends PaymentMethodPluginBase {
public function orderView(OrderInterface $order) {
$build = [];
if ($description = $this->database
->query('SELECT description FROM {uc_payment_other} WHERE order_id = :id', [
':id' => $order
->id(),
])
->fetchField()) {
$build = [
'#markup' => $this
->t('Description: @desc', [
'@desc' => $description,
]),
];
}
return $build;
}
public function orderEditDetails(OrderInterface $order) {
$build = [];
$build['description'] = [
'#type' => 'textfield',
'#title' => $this
->t('Description'),
'#default_value' => isset($order->payment_details['description']) ? $order->payment_details['description'] : '',
'#size' => 32,
'#maxlength' => 64,
];
return $build;
}
public function orderLoad(OrderInterface $order) {
$description = $this->database
->query('SELECT description FROM {uc_payment_other} WHERE order_id = :id', [
':id' => $order
->id(),
])
->fetchField();
if (isset($description)) {
$order->payment_details['description'] = $description;
}
}
public function orderSave(OrderInterface $order) {
if (empty($order->payment_details['description'])) {
$this->database
->delete('uc_payment_other')
->condition('order_id', $order
->id())
->execute();
}
else {
$this->database
->merge('uc_payment_other')
->key([
'order_id' => $order
->id(),
])
->fields([
'description' => $order->payment_details['description'],
])
->execute();
}
}
}
Classes
Name |
Description |
Other |
Defines a generic payment method. |