Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Implementation of hook_form_alter().
- */
- function internetdevels_form_alter(&$form, &$form_state, $form_id) {
- // drupal_set_message('<pre>' . print_r(unserialize($form_state['post']['cart_contents']), 1) . '</pre>');
- if ($form_id == 'uc_cart_checkout_form') {
- if (isset($_SESSION['mail_msg'])) {
- unset($_SESSION['mail_msg']);
- }
- // $sku = unserialize($form_state['post']['cart_contents']);
- // drupal_set_message('<pre>' . print_r($sku, 1) . '</pre>');
- // $email = $form['account']['mail']['#default_value'];
- $default = unserialize(variable_get('ID_ZONE_EDIT_RESULT', ''));
- $form['panes']['billing']['billing_address_select']['#access'] = FALSE;
- foreach($form['panes']['billing']['billing_zone']['#options'] as $key => $elements) {
- if (!in_array($key, $default) && is_numeric($key)) {
- unset($form['panes']['billing']['billing_zone']['#options'][$key]);
- }
- }
- if ($form_state['post']['op'] == t('Review order')) {
- if (isset($form_state['post']['cart_contents']) && !empty($form_state['post']['cart_contents'])) {
- $items = unserialize($form_state['post']['cart_contents']);
- if (!empty($items) && is_array($items)) {
- $price = 0;
- $products = '';
- foreach ($items as $item) {
- $products .= $item->title . ', ';
- $price += $item->price;
- }
- if (!empty($form_state['post']['panes']['billing'])) {
- $billing = $form_state['post']['panes']['billing'];
- if (!empty($billing['billing_first_name']) && !empty($billing['billing_last_name']) && !empty($billing['billing_phone'])) {
- $first_name = $billing['billing_first_name'];
- $last_name = $billing['billing_last_name'];
- $phone = $billing['billing_phone'];
- // drupal_set_message('<pre>' . print_r($email, 1) . '</pre>');
- // drupal_set_message('<pre>' . print_r($phone, 1) . '</pre>');
- $message = t('The customer !first_name !last_name buy products: !products worth !price grn, phone: !phone. email: !email, sku: !sku',
- array(
- '!first_name' => $first_name,
- '!last_name' => $last_name,
- '!phone' => $phone,
- '!email' => $email,
- '!sku' => $sku,
- '!products' => $products,
- '!price' => $price,
- )
- );
- $mail_message = array(
- 'to' => EDITOR_EMAIL,
- 'subject' => t('New order buyer !first_name !last_name',
- array(
- '!first_name' => $first_name,
- '!last_name' => $last_name,
- '!phone' => $phone,
- '!email' => $email,
- '!sku' => $sku,
- )
- ),
- 'body' => $message,
- 'headers' => array(),
- );
- $_SESSION['mail_msg'] = $mail_message;
- }
- }
- }
- }
- }
- }
- if ($form_id == 'uc_cart_checkout_review_form' && $form_state['post']['op'] == t('Submit order')) {
- $message = $_SESSION['mail_msg'];
- unset($_SESSION['mail_msg']);
- drupal_mail_send($message);
- }
- if (strstr($form_id, 'webform_client_form_')) {
- if (!empty($form['captcha']['#description'])) {
- $form['captcha']['#description'] = t($form['captcha']['#description']);
- }
- }
- if ($form_id == 'product_node_form') {
- $form['#validate'][] = 'internetdevels_validate_sku';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement