/** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state, OrderInterface $uc_order = NULL) { $balance = uc_payment_balance($uc_order); $form['balance'] = array('#prefix' => '<strong>' . $this->t('Order balance:') . '</strong> ', '#markup' => uc_currency_format($balance)); $form['order_id'] = array('#type' => 'hidden', '#value' => $uc_order->id()); $form['amount'] = array('#type' => 'uc_price', '#title' => $this->t('Amount'), '#default_value' => $balance); $form['comment'] = array('#type' => 'textfield', '#title' => $this->t('Comment'), '#description' => $this->t('Any notes about the check, like type or check number.'), '#size' => 64, '#maxlength' => 256); $form['clear'] = array('#type' => 'fieldset', '#title' => $this->t('Expected clear date'), '#attributes' => array('class' => array('uc-inline-form', 'clearfix'))); $form['clear']['clear_month'] = uc_select_month(NULL, \Drupal::service('date.formatter')->format(REQUEST_TIME, 'custom', 'n')); $form['clear']['clear_day'] = uc_select_day(NULL, \Drupal::service('date.formatter')->format(REQUEST_TIME, 'custom', 'j')); $form['clear']['clear_year'] = uc_select_year(NULL, \Drupal::service('date.formatter')->format(REQUEST_TIME, 'custom', 'Y'), \Drupal::service('date.formatter')->format(REQUEST_TIME, 'custom', 'Y'), \Drupal::service('date.formatter')->format(REQUEST_TIME, 'custom', 'Y') + 1); $form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Receive check')); return $form; }
/** * Collect additional information for the "Cash on Delivery" payment method. */ protected function deliveryDateForm($order) { $month = !empty($order->payment_details['delivery_month']) ? $order->payment_details['delivery_month'] : \Drupal::service('date.formatter')->format(REQUEST_TIME, 'custom', 'n'); $day = !empty($order->payment_details['delivery_day']) ? $order->payment_details['delivery_day'] : \Drupal::service('date.formatter')->format(REQUEST_TIME, 'custom', 'j'); $year = !empty($order->payment_details['delivery_year']) ? $order->payment_details['delivery_year'] : \Drupal::service('date.formatter')->format(REQUEST_TIME, 'custom', 'Y'); $form['description'] = array('#markup' => '<div>' . t('Enter a desired delivery date:') . '</div>'); $form['delivery_month'] = uc_select_month(NULL, $month); $form['delivery_day'] = uc_select_day(NULL, $day); $form['delivery_year'] = uc_select_year(NULL, $year, \Drupal::service('date.formatter')->format(REQUEST_TIME, 'custom', 'Y'), \Drupal::service('date.formatter')->format(REQUEST_TIME, 'custom', 'Y') + 1); return $form; }