Пример #1
0
 /**
  * Overrides InOperator::getValueOptions().
  */
 public function getValueOptions()
 {
     if (!isset($this->valueOptions)) {
         $this->valueOptions = array();
         foreach (uc_payment_method_list() as $id => $method) {
             $this->valueOptions[$id] = $method['name'];
         }
     }
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function view(OrderInterface $order, array $form, FormStateInterface $form_state)
 {
     $contents['#attached']['library'][] = 'uc_payment/uc_payment.styles';
     if ($this->configuration['show_preview']) {
         $contents['line_items'] = array('#theme' => 'uc_payment_totals', '#order' => $order, '#weight' => -20);
     }
     // Ensure that the form builder uses #default_value to determine which
     // button should be selected after an ajax submission. This is
     // necessary because the previously selected value may have become
     // unavailable, which would result in an invalid selection.
     $input = $form_state->getUserInput();
     unset($input['panes']['payment']['payment_method']);
     $form_state->setUserInput($input);
     $options = array();
     foreach (uc_payment_method_list() as $id => $method) {
         // $set = rules_config_load('uc_payment_method_' . $method['id']);
         // if ($set && !$set->execute($order)) {
         //   continue;
         // }
         if ($method['checkout'] && !isset($method['express'])) {
             $options[$id] = $method['title'];
         }
     }
     \Drupal::moduleHandler()->alter('uc_payment_method_checkout', $options, $order);
     if (!$options) {
         $contents['#description'] = t('Checkout cannot be completed without any payment methods enabled. Please contact an administrator to resolve the issue.');
         $options[''] = t('No payment methods available');
     } elseif (count($options) > 1) {
         $contents['#description'] = t('Select a payment method from the following options.');
     }
     if (!$order->getPaymentMethodId() || !isset($options[$order->getPaymentMethodId()])) {
         $order->setPaymentMethodId(key($options));
     }
     $contents['payment_method'] = array('#type' => 'radios', '#title' => t('Payment method'), '#title_display' => 'invisible', '#options' => $options, '#default_value' => $order->getPaymentMethodId(), '#disabled' => count($options) == 1, '#required' => TRUE, '#ajax' => array('callback' => array($this, 'ajaxRender'), 'wrapper' => 'payment-details', 'progress' => array('type' => 'throbber')));
     $contents['details'] = array('#prefix' => '<div id="payment-details" class="clearfix payment-details-' . $order->getPaymentMethodId() . '">', '#markup' => t('Continue with checkout to complete payment.'), '#suffix' => '</div>');
     try {
         $details = $this->paymentMethodManager->createFromOrder($order)->cartDetails($order, $form, $form_state);
         if ($details) {
             unset($contents['details']['#markup']);
             $contents['details'] += $details;
         }
     } catch (PluginException $e) {
     }
     return $contents;
 }
Пример #3
0
 /**
  * Overrides FieldPluginBase::render().
  */
 public function render(ResultRow $values)
 {
     $value = $this->getValue($values);
     $methods = uc_payment_method_list();
     return $this->sanitizeValue($methods[$value]['name']);
 }