public function testStockThresholdMail() { $prefix = 'stock[' . $this->product->model->value . ']'; $edit = array('uc_stock_threshold_notification' => 1); $this->drupalPostForm('admin/store/config/stock', $edit, 'Save configuration'); $qty = rand(10, 100); $edit = array($prefix . '[active]' => 1, $prefix . '[stock]' => $qty + 1, $prefix . '[threshold]' => $qty); $this->drupalPostForm('node/' . $this->product->id() . '/edit/stock', $edit, 'Save changes'); $this->addToCart($this->product); $this->checkout(); $mail = $this->drupalGetMails(array('id' => 'uc_stock_threshold')); $mail = array_pop($mail); $this->assertEqual($mail['to'], uc_store_email(), 'Threshold mail recipient is correct.'); $this->assertTrue(strpos($mail['subject'], 'Stock threshold limit reached') !== FALSE, 'Threshold mail subject is correct.'); $this->assertTrue(strpos($mail['body'], $this->product->label()) !== FALSE, 'Mail body contains product title.'); $this->assertTrue(strpos($mail['body'], $this->product->model->value) !== FALSE, 'Mail body contains SKU.'); $this->assertTrue(strpos($mail['body'], 'has reached ' . $qty) !== FALSE, 'Mail body contains quantity.'); }
/** * {@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 buildForm(array $form, FormStateInterface $form_state) { $config = $this->config('uc_store.settings'); $form['store'] = array('#type' => 'vertical_tabs'); $form['basic'] = array('#type' => 'details', '#title' => $this->t('Basic information'), '#group' => 'store'); $form['basic']['uc_store_name'] = array('#type' => 'textfield', '#title' => $this->t('Store name'), '#default_value' => uc_store_name()); $form['basic']['uc_store_email'] = array('#type' => 'email', '#title' => $this->t('E-mail address'), '#size' => 32, '#required' => TRUE, '#default_value' => uc_store_email()); $form['basic']['uc_store_email_include_name'] = array('#type' => 'checkbox', '#title' => $this->t('Include the store name in the "From" line of store e-mails.'), '#description' => $this->t('May not be available on all server configurations. Turn off if this causes problems.'), '#default_value' => $config->get('mail_include_name')); $form['basic']['uc_store_phone'] = array('#type' => 'tel', '#title' => $this->t('Phone number'), '#default_value' => $config->get('phone')); $form['basic']['uc_store_fax'] = array('#type' => 'tel', '#title' => $this->t('Fax number'), '#default_value' => $config->get('fax')); $form['basic']['uc_store_help_page'] = array('#type' => 'textfield', '#title' => $this->t('Store help page'), '#description' => $this->t('The Drupal page for the store help link.'), '#default_value' => $config->get('help_page'), '#size' => 32, '#field_prefix' => $this->url('<front>', [], ['absolute' => TRUE])); $form['address'] = array('#type' => 'details', '#title' => $this->t('Store address'), '#group' => 'store'); $form['address']['address'] = array('#type' => 'uc_address', '#default_value' => array('uc_store_street1' => $config->get('address.street1'), 'uc_store_street2' => $config->get('address.street2'), 'uc_store_city' => $config->get('address.city'), 'uc_store_zone' => $config->get('address.zone'), 'uc_store_country' => $form_state->hasValue('uc_store_country') ? $form_state->getValue('uc_store_country') : $config->get('address.country'), 'uc_store_postal_code' => $config->get('address.postal_code')), '#required' => FALSE, '#key_prefix' => 'uc_store'); $form['currency'] = array('#type' => 'details', '#title' => $this->t('Currency format'), '#group' => 'store'); $form['currency']['uc_currency_code'] = array('#type' => 'textfield', '#title' => $this->t('Currency code'), '#description' => $this->t('While not used directly in formatting, the currency code is used by other modules as the primary currency for your site. Enter here your three character <a href=":url">ISO 4217</a> currency code.', [':url' => Url::fromUri('http://en.wikipedia.org/wiki/ISO_4217#Active_codes')->toString()]), '#default_value' => $config->get('currency.code'), '#maxlength' => 3, '#size' => 5); $form['currency']['example'] = array('#type' => 'textfield', '#title' => $this->t('Current format'), '#value' => uc_currency_format(1000.1234), '#disabled' => TRUE, '#size' => 10); $form['currency']['uc_currency_sign'] = array('#type' => 'textfield', '#title' => $this->t('Currency sign'), '#default_value' => $config->get('currency.symbol'), '#size' => 10, '#maxlength' => 10); $form['currency']['uc_sign_after_amount'] = array('#type' => 'checkbox', '#title' => $this->t('Display currency sign after amount.'), '#default_value' => $config->get('currency.symbol_after')); $form['currency']['uc_currency_thou'] = array('#type' => 'textfield', '#title' => $this->t('Thousands marker'), '#default_value' => $config->get('currency.thousands_marker'), '#size' => 10, '#maxlength' => 10); $form['currency']['uc_currency_dec'] = array('#type' => 'textfield', '#title' => $this->t('Decimal marker'), '#default_value' => $config->get('currency.decimal_marker'), '#size' => 10, '#maxlength' => 10); $form['currency']['uc_currency_prec'] = array('#type' => 'select', '#title' => $this->t('Number of decimal places'), '#options' => array(0 => 0, 1 => 1, 2 => 2), '#default_value' => $config->get('currency.precision')); $form['weight'] = array('#type' => 'details', '#title' => $this->t('Weight format'), '#group' => 'store'); $form['weight']['uc_weight_unit'] = array('#type' => 'select', '#title' => $this->t('Default weight units'), '#default_value' => $config->get('weight.units'), '#options' => array('lb' => $this->t('Pounds'), 'oz' => $this->t('Ounces'), 'kg' => $this->t('Kilograms'), 'g' => $this->t('Grams'))); $form['weight']['uc_weight_thou'] = array('#type' => 'textfield', '#title' => $this->t('Thousands marker'), '#default_value' => $config->get('weight.thousands_marker'), '#size' => 10, '#maxlength' => 10); $form['weight']['uc_weight_dec'] = array('#type' => 'textfield', '#title' => $this->t('Decimal marker'), '#default_value' => $config->get('weight.decimal_marker'), '#size' => 10, '#maxlength' => 10); $form['weight']['uc_weight_prec'] = array('#type' => 'select', '#title' => $this->t('Number of decimal places'), '#options' => array(0 => 0, 1 => 1, 2 => 2), '#default_value' => $config->get('weight.precision')); $form['length'] = array('#type' => 'details', '#title' => $this->t('Length format'), '#group' => 'store'); $form['length']['uc_length_unit'] = array('#type' => 'select', '#title' => $this->t('Default length units'), '#default_value' => $config->get('length.units'), '#options' => array('in' => $this->t('Inches'), 'ft' => $this->t('Feet'), 'cm' => $this->t('Centimeters'), 'mm' => $this->t('Millimeters'))); $form['length']['uc_length_thou'] = array('#type' => 'textfield', '#title' => $this->t('Thousands marker'), '#default_value' => $config->get('length.thousands_marker'), '#size' => 10, '#maxlength' => 10); $form['length']['uc_length_dec'] = array('#type' => 'textfield', '#title' => $this->t('Decimal marker'), '#default_value' => $config->get('length.decimal_marker'), '#size' => 10, '#maxlength' => 10); $form['length']['uc_length_prec'] = array('#type' => 'select', '#title' => $this->t('Number of decimal places'), '#options' => array(0 => 0, 1 => 1, 2 => 2), '#default_value' => $config->get('length.precision')); $form['display'] = array('#type' => 'details', '#title' => $this->t('Display settings'), '#group' => 'store'); $form['display']['uc_customer_list_address'] = array('#type' => 'radios', '#title' => $this->t('Primary customer address'), '#description' => $this->t('Select the address to be used on customer lists and summaries.'), '#options' => array('billing' => $this->t('Billing address'), 'shipping' => $this->t('Shipping address')), '#default_value' => $config->get('customer_address')); $form['display']['uc_order_capitalize_addresses'] = array('#type' => 'checkbox', '#title' => $this->t('Capitalize address on order screens'), '#default_value' => $config->get('capitalize_address')); return parent::buildForm($form, $form_state); }