/** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state, OrderInterface $uc_order = NULL) { $this->order = $uc_order; $form['email'] = array('#type' => 'email', '#title' => t('Recipient e-mail address'), '#default_value' => $uc_order->getEmail(), '#required' => TRUE); $form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Mail invoice')); return $form; }
/** * {@inheritdoc} */ public function buildForm(OrderInterface $order, array $form, FormStateInterface $form_state) { $form['order-view-image'] = array('#theme' => 'image', '#uri' => base_path() . drupal_get_path('module', 'uc_store') . '/images/order_view.gif', '#title' => $this->t('Search for an existing customer.'), '#alt' => $this->t('Search for an existing customer.'), '#attributes' => array('id' => 'load-customer-search'), '#prefix' => '<div class="order-pane-icons">'); $form['menu-customers-image'] = array('#theme' => 'image', '#uri' => base_path() . drupal_get_path('module', 'uc_store') . '/images/menu_customers_small.gif', '#title' => $this->t('Create a new customer.'), '#alt' => $this->t('Create a new customer.'), '#attributes' => array('id' => 'load-new-customer-form'), '#suffix' => '</div>'); $form['icons'] = array('#type' => 'markup', '#markup' => '<div id="customer-select"></div>'); $form['uid'] = array('#type' => 'hidden', '#default_value' => $order->getOwnerId()); $form['uid_text'] = array('#type' => 'textfield', '#title' => $this->t('Customer number'), '#default_value' => $order->getOwnerId(), '#maxlength' => 10, '#size' => 10, '#disabled' => TRUE); $form['primary_email'] = array('#type' => 'email', '#title' => $this->t('E-mail address'), '#default_value' => $order->getEmail(), '#maxlength' => 64, '#size' => 32); return $form; }
/** * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state, array $addresses = [], OrderInterface $uc_order = NULL) { $form['#attached']['library'][] = 'uc_fulfillment/uc_fulfillment.scripts'; $form['origin'] = array('#type' => 'fieldset', '#title' => t('Origin address'), '#weight' => -2); $form['origin']['pickup_address_select'] = $this->selectAddress($addresses); $form['origin']['pickup_address_select']['#weight'] = -2; $form['origin']['pickup_email'] = array('#type' => 'email', '#title' => t('E-mail'), '#default_value' => uc_store_email(), '#weight' => -1); $form['origin']['pickup_email']['#weight'] = -1; $form['origin']['pickup_address']['#tree'] = TRUE; $form['origin']['pickup_address']['pickup_address'] = array('#type' => 'uc_address', '#default_value' => reset($addresses), '#required' => FALSE); $form['destination'] = array('#type' => 'fieldset', '#title' => t('Destination address'), '#weight' => -1); if ($form_state->hasValue('delivery_country')) { $uc_order->delivery_country = $form_state->getValue('delivery_country'); } $form['destination']['delivery_email'] = array('#type' => 'email', '#title' => t('E-mail'), '#default_value' => $uc_order->getEmail(), '#weight' => -1); $form['destination']['delivery_email']['#weight'] = -1; $form['destination']['delivery_address'] = array('#type' => 'uc_address', '#default_value' => $uc_order->getAddress('delivery'), '#required' => FALSE, '#key_prefix' => 'delivery'); return $form; }
/** * {@inheritdoc} */ public function review(OrderInterface $order) { $review[] = array('title' => $this->t('E-mail'), 'data' => array('#plain_text' => $order->getEmail())); return $review; }
/** * {@inheritdoc} */ public function buildRedirectForm(array $form, FormStateInterface $form_state, OrderInterface $order = NULL) { $country = \Drupal::service('country_manager')->getCountry($order->getAddress('billing')->country); $data = array('sid' => $this->configuration['sid'], 'mode' => '2CO', 'card_holder_name' => Unicode::substr($order->getAddress('billing')->first_name . ' ' . $order->getAddress('billing')->last_name, 0, 128), 'street_address' => Unicode::substr($order->getAddress('billing')->street1, 0, 64), 'street_address2' => Unicode::substr($order->getAddress('billing')->street2, 0, 64), 'city' => Unicode::substr($order->getAddress('billing')->city, 0, 64), 'state' => $order->getAddress('billing')->zone, 'zip' => Unicode::substr($order->getAddress('billing')->postal_code, 0, 16), 'country' => $country ? $country->getAlpha3() : 'USA', 'email' => Unicode::substr($order->getEmail(), 0, 64), 'phone' => Unicode::substr($order->getAddress('billing')->phone, 0, 16), 'purchase_step' => 'payment-method', 'demo' => $this->configuration['demo'] ? 'Y' : 'N', 'lang' => $this->configuration['language'], 'merchant_order_id' => $order->id(), 'pay_method' => 'CC', 'x_receipt_link_url' => Url::fromRoute('uc_2checkout.complete', ['cart_id' => \Drupal::service('uc_cart.manager')->get()->getId()], ['absolute' => TRUE])->toString(), 'total' => uc_currency_format($order->getTotal(), FALSE, FALSE, '.'), 'currency_code' => $order->getCurrency(), 'cart_order_id' => $order->id()); $i = 0; foreach ($order->products as $product) { $i++; $data['li_' . $i . '_type'] = 'product'; $data['li_' . $i . '_name'] = $product->title->value; // @todo: HTML escape and limit to 128 chars $data['li_' . $i . '_quantity'] = $product->qty->value; $data['li_' . $i . '_product_id'] = $product->model->value; $data['li_' . $i . '_price'] = uc_currency_format($product->price->value, FALSE, FALSE, '.'); } if ('direct' == $this->configuration['checkout_type']) { $form['#attached']['library'][] = 'uc_2checkout/2checkout.direct'; } $form['#action'] = $this->configuration['server_url']; foreach ($data as $name => $value) { $form[$name] = array('#type' => 'hidden', '#value' => $value); } $form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Submit order')); return $form; }
/** * {@inheritdoc} */ public function review(OrderInterface $order) { $review[] = array('title' => t('E-mail'), 'data' => SafeMarkup::checkPlain($order->getEmail())); return $review; }