/** * @file * Callbacks for the default Ubercart checkout panes and their corresponding helper functions. * * Checkout panes are defined using hook_checkout_pane() and use a callback to * handle the different processes involved in completing the checkout form. The * default checkout panes are defined in uc_cart_checkout_pane() in * uc_cart.module. */ /** * Displays the cart contents for review during checkout. */ function uc_checkout_pane_cart($op) { switch ($op) { case 'view': $contents['cart_review_table'] = array( '#value' => theme('cart_review_table'), '#weight' => variable_get('uc_pane_cart_field_cart_weight', 2), ); return array('contents' => $contents, 'next-button' => FALSE); case 'review': $items = uc_cart_get_contents(); $review[] = theme('uc_checkout_pane_cart_review', $items); return $review; } } /** * Gets the user's email address for login. */ function uc_checkout_pane_customer($op, &$arg1, $arg2) { global $user; switch ($op) { case 'view': if (!empty($arg1->primary_email)) { $email = $arg1->primary_email; } elseif (isset($user->mail)) { $email = $user->mail; } else { $email = ''; } if ($user->uid) { $description = t('Order information will be sent to your account e-mail listed below.');// .'
' $contents['primary_email'] = array('#type' => 'hidden', '#value' => check_plain($email)); $contents['email_text'] = array( '#value' => '
'. ($email ? ''. $email .' ' : '') . l('изменить', 'user/'. $user->uid .'/edit', array('query' => drupal_get_destination())) .'
', ); } else { $description = t('Enter a valid email address for this order or click here to login with an existing account and return to checkout.', array('!url' => url('user/login', array('query' => drupal_get_destination())))); $contents['primary_email'] = uc_textfield(t('E-mail address'), $email, TRUE, NULL, 64); } if (variable_get('uc_cart_email_validation', FALSE) && !$user->uid) { $contents['primary_email_confirm'] = uc_textfield(t('Confirm e-mail address'), $_SESSION['email_match'] === FALSE ? '' : $email, TRUE, NULL, 64); if ($_SESSION['email_match'] === FALSE) { $contents['primary_email_confirm']['#attributes'] = array('class' => 'error'); unset($_SESSION['email_match']); } } if ($user->uid == 0) { $contents['new_account'] = array(); if (variable_get('uc_cart_new_account_name', FALSE)) { $contents['new_account']['name'] = array( '#type' => 'textfield', '#title' => t('Username'), '#default_value' => isset($arg1->data['new_user']['name']) ? $arg1->data['new_user']['name'] : '', '#maxlength' => 128, '#size' => 128, ); } if (variable_get('uc_cart_new_account_password', FALSE)) { $contents['new_account']['pass'] = array( '#type' => 'password', '#title' => t('Password'), '#maxlength' => 32, '#size' => 32, ); $contents['new_account']['pass_confirm'] = array( '#type' => 'password', '#title' => t('Confirm password'), '#description' => t('Passwords must match to proceed.'), '#maxlength' => 32, '#size' => 32, ); } if (!empty($contents['new_account'])) { $array = array( '#type' => 'fieldset', '#title' => t('New account details'), '#description' => variable_get('uc_cart_new_account_details', t('Optional. New customers may supply custom account details.
We will create these for you if no values are entered.')), '#collapsible' => FALSE, ); $contents['new_account'] = array_merge($array, $contents['new_account']); } /* * This code adds profile fields required for registration to the * customer checkout pane. However, I don't have the time to fool with * validation/submission stuff, so I'm postponing this feature. -RS $null = NULL; $extra = _user_forms($null, NULL, NULL, 'register'); if (!empty($extra)) { $contents = array_merge($contents, $extra); }*/ } return array('description' => $description, 'contents' => $contents); case 'process': if (!empty($arg2['primary_email']) && !valid_email_address($arg2['primary_email'])) { form_set_error('panes][customer][primary_email', t('You must enter a valid e-mail address.')); } $arg1->primary_email = $arg2['primary_email']; if (variable_get('uc_cart_email_validation', FALSE) && !$user->uid && $arg2['primary_email'] !== $arg2['primary_email_confirm']) { form_set_error('panes][customer][primary_email_confirm', t('The e-mail address did not match.')); $_SESSION['email_match'] = FALSE; } unset($_SESSION['email_match']); // Invalidate if an account already exists for this e-mail address, and the user is not logged into that account if (!variable_get('uc_cart_mail_existing', TRUE) && $user->uid == 0 && !empty($arg2['primary_email'])) { if (db_result(db_query("SELECT uid FROM {users} WHERE LOWER(mail) = LOWER('%s')", $arg2['primary_email'])) > 0) { form_set_error('panes][customer][primary_email', t('An account already exists for your e-mail address. You will either need to login with this e-mail address or use a different e-mail address.')); } } // If new users can specify names or passwords then... if ((variable_get('uc_cart_new_account_name', FALSE) || variable_get('uc_cart_new_account_password', FALSE)) && $user->uid == 0) { // Skip if an account already exists for this e-mail address. if (variable_get('uc_cart_mail_existing', TRUE) && db_result(db_query("SELECT uid FROM {users} WHERE LOWER(mail) = LOWER('%s')", $arg2['primary_email'])) > 0) { drupal_set_message(t('An account already exists for your e-mail address. The new account details you entered will be disregarded.')); } else { // Validate the username. if (variable_get('uc_cart_new_account_name', FALSE) && !empty($arg2['new_account']['name'])) { $message = user_validate_name($arg2['new_account']['name']); if (!empty($message)) { form_set_error('panes][customer][new_account][name', $message); } if (db_fetch_object(db_query("SELECT uid FROM {users} WHERE LOWER(name) = LOWER('%s')", $arg2['new_account']['name'])) > 0) { form_set_error('panes][customer][new_account][name', t('The username %name is already taken. Please enter a different name or leave the field blank for your username to be your e-mail address.', array('%name' => $arg2['new_account']['name']))); } $arg1->data['new_user']['name'] = $arg2['new_account']['name']; } // Validate the password. if (variable_get('uc_cart_new_account_password', FALSE)) { if (strcmp($arg2['new_account']['pass'], $arg2['new_account']['pass_confirm'])) { form_set_error('panes][customer][new_account][pass_confirm', t('The passwords you entered did not match. Please try again.')); } if (!empty($arg2['new_account']['pass'])) { $arg1->data['new_user']['hash'] = md5(trim($arg2['new_account']['pass'])); } } } } if ($user->uid) { $arg1->uid = $user->uid; } return TRUE; case 'review': $review[] = array('title' => t('E-mail'), 'data' => check_plain($arg1->primary_email)); return $review; case 'settings': $form['uc_cart_mail_existing'] = array( '#type' => 'checkbox', '#title' => t("Allow anonymous customers to use an existing account's email address."), '#default_value' => variable_get('uc_cart_mail_existing', TRUE), '#description' => t('If enabled, orders will be attached to the account matching the email address. If disabled, anonymous users using a registered email address must log in or use a different email address.'), ); $form['uc_cart_email_validation'] = array( '#type' => 'checkbox', '#title' => t('Require e-mail confirmation in checkout for anonymous customers.'), '#default_value' => variable_get('uc_cart_email_validation', FALSE), ); $form['uc_cart_new_account_name'] = array( '#type' => 'checkbox', '#title' => t('Allow anonymous customers to specify a new user account name.'), '#default_value' => variable_get('uc_cart_new_account_name', FALSE), ); $form['uc_cart_new_account_password'] = array( '#type' => 'checkbox', '#title' => t('Allow anonymous customers to specify a new user account password.'), '#default_value' => variable_get('uc_cart_new_account_password', FALSE), ); $form['uc_cart_new_account_details'] = array( '#type' => 'textarea', '#title' => t('New account details help message'), '#description' => t('Enter the help message displayed in the new account details fieldset when shown.'), '#default_value' => variable_get('uc_cart_new_account_details', t('Optional. New customers may supply custom account details.
We will create these for you if no values are entered.')), ); return $form; } } /** * Gets the delivery information. */ function uc_checkout_pane_delivery($op, &$arg1, $arg2) { global $user; switch ($op) { case 'view': $description = t('Enter your delivery address and information here.'); if ((uc_cart_is_shippable() || !variable_get('uc_cart_delivery_not_shippable', TRUE)) && _checkout_pane_data('billing', 'weight') < _checkout_pane_data('delivery', 'weight') && _checkout_pane_data('billing', 'enabled')) { $contents['copy_address'] = array( '#type' => 'checkbox', '#title' => t('My delivery information is the same as my billing information.'), '#attributes' => array('onclick' => "uc_cart_copy_address(this.checked, 'billing', 'delivery');"), ); } if ($user->uid) { $addresses = uc_select_address($user->uid, 'delivery', 'apply_address(\'delivery\', this.value);', t('Saved addresses'), TRUE); if (!empty($addresses)) { $contents['delivery_address_select'] = $addresses; } } if (uc_address_field_enabled('first_name')) { $delivery_first_name = $arg1 ? $arg1->delivery_first_name : ''; $contents['delivery_first_name'] = uc_textfield(uc_get_field_name('first_name'), $delivery_first_name, uc_address_field_required('first_name')); } if (uc_address_field_enabled('last_name')) { $delivery_last_name = $arg1 ? $arg1->delivery_last_name : ''; $contents['delivery_last_name'] = uc_textfield(uc_get_field_name('last_name'), $delivery_last_name, uc_address_field_required('last_name')); } if (uc_address_field_enabled('company')) { $delivery_company = $arg1 ? $arg1->delivery_company : ''; $contents['delivery_company'] = uc_textfield(uc_get_field_name('company'), $delivery_company, uc_address_field_required('company'), NULL, 128); } if (uc_address_field_enabled('street1')) { $delivery_street1 = $arg1 ? $arg1->delivery_street1 : ''; $contents['delivery_street1'] = uc_textfield(uc_get_field_name('street1'), $delivery_street1, uc_address_field_required('street1'), 128, 128); } if (uc_address_field_enabled('street2')) { $delivery_street2 = $arg1 ? $arg1->delivery_street2 : ''; $contents['delivery_street2'] = uc_textfield(uc_get_field_name('street2'), $delivery_street2, uc_address_field_required('street2'), 128, 128); } if (uc_address_field_enabled('city')) { $delivery_city = $arg1 ? $arg1->delivery_city : ''; $contents['delivery_city'] = uc_textfield(uc_get_field_name('city'), $delivery_city, uc_address_field_required('city')); } if (uc_address_field_enabled('country')) { $delivery_country = $arg1 ? $arg1->delivery_country : NULL; $contents['delivery_country'] = uc_country_select(uc_get_field_name('country'), $delivery_country, NULL, 'name', uc_address_field_required('country')); } if (uc_address_field_enabled('zone')) { if (isset($_POST['panes']['delivery']['delivery_country'])) { $country_id = intval($_POST['panes']['delivery']['delivery_country']); } else { $country_id = $delivery_country; } $delivery_zone = $arg1 ? $arg1->delivery_zone : NULL; $contents['delivery_zone'] = uc_zone_select(uc_get_field_name('zone'), $delivery_zone, NULL, $country_id, 'name', uc_address_field_required('zone')); if (isset($_POST['panes']) && count($contents['delivery_zone']['#options']) == 1) { $contents['delivery_zone']['#required'] = FALSE; } } if (uc_address_field_enabled('postal_code')) { $delivery_postal_code = $arg1 ? $arg1->delivery_postal_code : ''; $contents['delivery_postal_code'] = uc_textfield(uc_get_field_name('postal_code'), $delivery_postal_code, uc_address_field_required('postal_code'), NULL, 10, 10); } if (uc_address_field_enabled('phone')) { $delivery_phone = $arg1 ? $arg1->delivery_phone : ''; $contents['delivery_phone'] = uc_textfield(uc_get_field_name('phone'), $delivery_phone, uc_address_field_required('phone'), NULL, 32, 16); } return array('description' => $description, 'contents' => $contents, 'theme' => 'address_pane'); case 'process': $arg1->delivery_first_name = $arg2['delivery_first_name']; $arg1->delivery_last_name = $arg2['delivery_last_name']; $arg1->delivery_company = $arg2['delivery_company']; $arg1->delivery_street1 = $arg2['delivery_street1']; $arg1->delivery_street2 = $arg2['delivery_street2']; $arg1->delivery_city = $arg2['delivery_city']; $arg1->delivery_zone = $arg2['delivery_zone']; $arg1->delivery_postal_code = $arg2['delivery_postal_code']; $arg1->delivery_country = $arg2['delivery_country']; $arg1->delivery_phone = $arg2['delivery_phone']; return TRUE; case 'review': $review[] = array('title' => t('Address'), 'data' => uc_order_address($arg1, 'delivery', FALSE)); if (uc_address_field_enabled('phone') && !empty($arg1->delivery_phone)) { $review[] = array('title' => t('Phone'), 'data' => check_plain($arg1->delivery_phone)); } return $review; } } /** * Gets the billing information. */ function uc_checkout_pane_billing($op, &$arg1, $arg2) { global $user; switch ($op) { case 'view': $description = t('Enter your billing address and information here.'); if ((uc_cart_is_shippable() || !variable_get('uc_cart_delivery_not_shippable', TRUE)) && _checkout_pane_data('delivery', 'weight') < _checkout_pane_data('billing', 'weight') && _checkout_pane_data('delivery', 'enabled')) { $contents['copy_address'] = array( '#type' => 'checkbox', '#title' => t('My billing information is the same as my delivery information.'), '#attributes' => array('onclick' => "uc_cart_copy_address(this.checked, 'delivery', 'billing');"), ); } if ($user->uid) { $addresses = uc_select_address($user->uid, 'billing', 'apply_address(\'billing\', this.value);', t('Saved addresses'), TRUE); if (!empty($addresses)) { $contents['billing_address_select'] = $addresses; } } if (uc_address_field_enabled('first_name')) { $billing_first_name = $arg1 ? $arg1->billing_first_name : ''; $contents['billing_first_name'] = uc_textfield(uc_get_field_name('first_name'), $billing_first_name, uc_address_field_required('first_name')); } if (uc_address_field_enabled('last_name')) { $billing_last_name = $arg1 ? $arg1->billing_last_name : ''; $contents['billing_last_name'] = uc_textfield(uc_get_field_name('last_name'), $billing_last_name, uc_address_field_required('last_name')); } if (uc_address_field_enabled('company')) { $billing_company = $arg1 ? $arg1->billing_company : ''; $contents['billing_company'] = uc_textfield(uc_get_field_name('company'), $billing_company, uc_address_field_required('company'), NULL, 128); } if (uc_address_field_enabled('street1')) { $billing_street1 = $arg1 ? $arg1->billing_street1 : ''; $contents['billing_street1'] = uc_textfield(uc_get_field_name('street1'), $billing_street1, uc_address_field_required('street1'), NULL, 128); } if (uc_address_field_enabled('street2')) { $billing_street2 = $arg1 ? $arg1->billing_street2 : ''; $contents['billing_street2'] = uc_textfield(uc_get_field_name('street2'), $billing_street2, uc_address_field_required('street2'), NULL, 128); } if (uc_address_field_enabled('city')) { $billing_city = $arg1 ? $arg1->billing_city : ''; $contents['billing_city'] = uc_textfield(uc_get_field_name('city'), $billing_city, uc_address_field_required('city')); } if (uc_address_field_enabled('country')) { $billing_country = $arg1 ? $arg1->billing_country : NULL; $contents['billing_country'] = uc_country_select(uc_get_field_name('country'), $billing_country, NULL, 'name', uc_address_field_required('country')); } if (uc_address_field_enabled('zone')) { if (isset($_POST['panes']['billing']['billing_country'])) { $country_id = intval($_POST['panes']['billing']['billing_country']); } else { $country_id = $billing_country; } $billing_zone = $arg1 ? $arg1->billing_zone : NULL; $contents['billing_zone'] = uc_zone_select(uc_get_field_name('zone'), $billing_zone, NULL, $country_id, 'name', uc_address_field_required('zone')); if (isset($_POST['panes']) && count($contents['billing_zone']['#options']) == 1) { $contents['billing_zone']['#required'] = FALSE; } } if (uc_address_field_enabled('postal_code')) { $billing_postal_code = $arg1 ? $arg1->billing_postal_code : ''; $contents['billing_postal_code'] = uc_textfield(uc_get_field_name('postal_code'), $billing_postal_code, uc_address_field_required('postal_code'), NULL, 10, 10); } if (uc_address_field_enabled('phone')) { $billing_phone = $arg1 ? $arg1->billing_phone : ''; $contents['billing_phone'] = uc_textfield(uc_get_field_name('phone'), $billing_phone, uc_address_field_required('phone'), NULL, 32, 16); } return array('description' => $description, 'contents' => $contents, 'theme' => 'address_pane'); case 'process': $arg1->billing_first_name = isset($arg2['billing_first_name']) ? $arg2['billing_first_name'] : NULL; $arg1->billing_last_name = isset($arg2['billing_last_name']) ? $arg2['billing_last_name'] : NULL; $arg1->billing_company = isset($arg2['billing_company']) ? $arg2['billing_company'] : NULL; $arg1->billing_street1 = isset($arg2['billing_street1']) ? $arg2['billing_street1'] : NULL; $arg1->billing_street2 = isset($arg2['billing_street2']) ? $arg2['billing_street2'] : NULL; $arg1->billing_city = isset($arg2['billing_city']) ? $arg2['billing_city'] : NULL; $arg1->billing_zone = isset($arg2['billing_zone']) ? $arg2['billing_zone'] : NULL; $arg1->billing_postal_code = isset($arg2['billing_postal_code']) ? $arg2['billing_postal_code'] : NULL; $arg1->billing_country = isset($arg2['billing_country']) ? $arg2['billing_country'] : NULL; $arg1->billing_phone = isset($arg2['billing_phone']) ? $arg2['billing_phone'] : NULL; return TRUE; case 'review': $review[] = array('title' => t('Address'), 'data' => uc_order_address($arg1, 'billing', FALSE)); if (uc_address_field_enabled('phone') && !empty($arg1->billing_phone)) { $review[] = array('title' => t('Phone'), 'data' => check_plain($arg1->billing_phone)); } return $review; } } /** * Allows a customer to make comments on the order. */ function uc_checkout_pane_comments($op, &$arg1, $arg2) { switch ($op) { case 'view': $description = t('Use this area for special instructions or questions regarding your order.'); if (!empty($arg1->order_id)) { $default = db_result(db_query("SELECT message FROM {uc_order_comments} WHERE order_id = %d", $arg1->order_id)); } else { $default = NULL; } $contents['comments'] = array( '#type' => 'textarea', '#title' => t('Order comments'), '#default_value' => $default, '#wysiwyg' => FALSE, '#resizable' => FALSE, ); return array('description' => $description, 'contents' => $contents); case 'process': db_query("DELETE FROM {uc_order_comments} WHERE order_id = %d", $arg1->order_id); if (strlen($arg2['comments']) > 0) { uc_order_comment_save($arg1->order_id, 0, $arg2['comments'], 'order', uc_order_state_default('post_checkout'), TRUE); } return TRUE; case 'review': $review = NULL; $result = db_query("SELECT message FROM {uc_order_comments} WHERE order_id = %d", $arg1->order_id); if ($comment = db_fetch_object($result)) { $review[] = array('title' => t('Comment'), 'data' => check_plain($comment->message)); } return $review; } } /** * Вывод блока суммарной информации по заказу (с js обновлениями при смене доставки и скидок) */ function uc_checkout_pane_summary($op, &$arg1, $arg2) { switch ($op) { case 'view': $subtotalPrice = $discountPrice = $deliveryPrice = 0; $subtotalPrice = _uc_cart_get_basket_price(); $discountPrice = _uc_cart_get_discount($arg1); $deliveryPrice = intval($arg1->quote['rate']); $contents['summary_review_table'] = array( '#value' => theme('summary_review_table', $subtotalPrice, $discountPrice, $deliveryPrice), ); $drupal_settings = array( 'summary' => array( 'subtotalPrice' => $subtotalPrice, 'discountPrice' => $discountPrice, 'deliveryPrice' => $deliveryPrice, ), ); drupal_add_js(array('indi_checkout' => $drupal_settings), 'setting'); drupal_add_js(drupal_get_path('module', 'indi_light') .'/js/checkout.js', 'module', 'header'); return array('contents' => $contents); case 'process': return TRUE; case 'review': $review = array(); $subtotalPrice = $discountPrice = $deliveryPrice = 0; $subtotalPrice = _uc_cart_get_basket_price(); $discountPrice = _uc_cart_get_discount($arg1); $deliveryPrice = intval($arg1->quote['rate']); $review[] = array('data'=>theme('summary_review_table', $subtotalPrice, $discountPrice, $deliveryPrice)); return $review; } } /** * Получить стоимость товаров (без скидок, доставки и прочего) */ function _uc_cart_get_basket_price() { $price = 0; $context = array(); $items = uc_cart_get_contents(); foreach ($items as $item) { $price_info = array( 'price' => $item->price, 'qty' => $item->qty, ); $context['revision'] = 'altered'; $price += uc_price($price_info, $context); } return $price; } /** * Получить сумму скидки */ function _uc_cart_get_discount($order) { global $user; if ( !$order ) { $order = new stdClass(); $order->uid = $user->uid; } if ( !$order->products ) { $order->products = uc_cart_get_contents(); } $errors = $warnings = $messages = array(); $discounts = get_discounts_for_order($order, $errors, $warnings, $messages); $discountPrice = 0; foreach ($discounts as $discount) { $discountPrice += abs(round($discount->amount)); } return $discountPrice; } /** * Темизация блока суммарной информации по заказу */ function theme_summary_review_table($subtotalPrice, $discountPrice, $deliveryPrice) { /* $header = array( array('data' => ''), array('data' => t('No Discount'), 'class' => 'price', 'id' => 'summaryNoDiscountHeader'), array('data' => t('Discount'), 'class' => 'price', 'id' => 'summaryDiscountHeader'), array('data' => t('Delivery'), 'class' => 'price', 'id' => 'summaryDeliveryHeader'), array('data' => t('Total'), 'class' => 'price', 'id' => 'summaryTotalHeader'), ); $rows[] = array( array('data' => uc_price($subtotalPrice), 'class' => 'price', 'id' => 'summaryNoDiscount'), array('data' => uc_price($discountPrice), 'class' => 'price', 'id' => 'summaryDiscount'), array('data' => uc_price($deliveryPrice), 'class' => 'price', 'id' => 'summaryDelivery'), ); */ $header = NULL; $rows[] = array( array('data' => 'Итого с доставкой:', 'class' => 'price-label'), array('data' => uc_price($subtotalPrice - $discountPrice + $deliveryPrice), 'class' => 'price-value', 'id' => 'summaryTotal'), ); return theme('table', $header, $rows, array('class' => 'cart-summary')); /* return '
' .'Итого с доставкой:' .''. uc_price($subtotalPrice - $discountPrice + $deliveryPrice) .'' .'
'; */ } /** * Вывод блока с важным флагом условия продолжения оформления заказа */ function uc_checkout_pane_importantCheck($op, &$arg1, $arg2) { global $user; switch ($op) { case 'view': $description = ''; $contents['check'] = array( '#type' => 'checkbox', '#title' => t(' '), //'#title' => t(' Я уведомлен, что мой заказ будет комплектоваться в течение 2-х недель и будет доставлен БЕСПЛАТНО'), //'#title' => t(' Я уведомлен, что мой заказ будет комплектоваться в течение 2-5 дней'), //'#title' => t(' Я согласен на получение скидки по заказу от 10% и уведомлен о том, что мой заказ будет обработан и доставлен после 17 августа'), //'#title' => t(' Я согласен с тем, что мой заказ будет обработан и доставлен после 11 января 2015 г.'), //'#title' => t(' Согласен на обработку, комплектацию и доставку моего заказа, начиная с 11 января 2016 года'), //'#title' => t(' Согласен на обработку, комплектацию и доставку моего заказа, начиная с 9 января 2017 года'), //'#title' => t(' Согласен на обработку, комплектацию и доставку моего заказа, начиная с 9 января 2018 года'), //'#title' => t(' Я согласен с тем, что мой заказ будет обработан и передан в доставку после 26 августа'), //'#title' => t(' Я согласен с тем, что заказ будет обработан и передан в доставку с 9 января 2019 года'), //'#title' => t(' Я согласен с тем, что заказ будет обработан и передан в доставку с 13 мая 2019 года'), //'#title' => t(' Я согласен с тем, что в случае закрытия выбранного ПВЗ мой заказ будет автоматически перемещен в ближайший работающий ПВЗ без предварительного согласования со мной'), '#title' => t(' Я согласен с тем, что заказ будет обработан и передан в доставку после 15 июня 2020 года'), '#element_validate' => array('_uc_checkout_pane_importantCheck_validate'), '#suffix' => '', ); return array('description' => $description, 'contents' => $contents); case 'process': return TRUE; case 'review': $review = array(); return $review; } } /** * Валидация поля importantCheck */ function _uc_checkout_pane_importantCheck_validate($element, &$form_state) { if ( $form_state['values']['panes']['importantCheck']['check']!=1 ){ form_error($element, t('!name field is required.',array('!name'=>$element['#title']))); } } /** * Вывод блока "Согласен на получение информационных смс о статусе моего заказа" (обязательно к нажатию) */ function uc_checkout_pane_smsinformingCheck($op, &$arg1, $arg2) { global $user; switch ($op) { case 'view': $description = ''; $contents['check'] = array( '#type' => 'checkbox', '#title' => t(' Согласен на получение информационных SMS о статусе моего заказа'), '#attributes' => array('checked' => 'checked'), '#element_validate' => array('_uc_checkout_pane_smsinformingCheck_validate'), ); return array('description' => $description, 'contents' => $contents); case 'process': return TRUE; case 'review': $review = array(); //$review[] = array('title' => t('Address'), 'data' => uc_order_address($arg1, 'billing', FALSE)); return $review; } } /** * Валидация поля smsinformingCheck */ function _uc_checkout_pane_smsinformingCheck_validate($element, &$form_state) { if (isset($_POST['op']) && $_POST['op'] == t('Back')){ }elseif ( $form_state['values']['panes']['smsinformingCheck']['check']!=1 ){ // su 2016.03.28 // Снимаем обязательность заполнения (и вообще прячем), после рекомендаций Антона Серикова //form_error($element, t('!name field is required.',array('!name'=>$element['#title']))); } } /** * Вывод блока "Ознакомлен и согласен с условиями политики конфиденциальности" (обязательно к нажатию) */ function uc_checkout_pane_privacyPolicyCheck($op, &$arg1, $arg2) { global $user; switch ($op) { case 'view': $description = ''; $contents['check'] = array( '#type' => 'checkbox', //'#title' => t('Настоящим подтверждаю, что я ознакомлен и согласен с условиями политики конфиденциальности'), //'#title' => t('Настоящим подтверждаю, что я согласен на сбор и обработку персональных данных'), '#title' => t('Подтверждаю, что я ознакомлен и согласен с условиями политики конфиденциальности'), '#attributes' => array('checked' => 'checked'), '#element_validate' => array('_uc_checkout_pane_privacyPolicyCheck_validate'), ); return array('description' => $description, 'contents' => $contents); case 'process': return TRUE; case 'review': $review = array(); return $review; } } /** * Валидация поля privacyPolicyCheck */ function _uc_checkout_pane_privacyPolicyCheck_validate($element, &$form_state) { if (isset($_POST['op']) && $_POST['op'] == t('Back')){ }elseif ( $form_state['values']['panes']['privacyPolicyCheck']['check']!=1 ){ form_error($element, t('!name field is required.',array('!name'=>$element['#title']))); } } /** * Вывод блока со способом оплаты и доставки */ function uc_checkout_pane_infoDelivery($op, &$arg1, $arg2) { global $user; switch ($op) { case 'view': $description = ''; if ($arg1) { if ($arg1->line_items) { foreach($arg1->line_items as $line_item) { if ($line_item['type'] == 'shipping') { $contents['delivery_type'] = array( '#title' => 'Тип доставки', '#value' => '
Тип доставки: '. $line_item['title'] .'
', ); break; } } } if ($arg1->payment_method) { $payment_methods = array('uc_payonline'=>'PayOnline', 'robokassa'=>'RoboKassa', 'paypal_wps'=>'PayPal', 'cod'=>'Наличные', 'cashless'=>'Безналичный
расчет', 'other'=>'Другой'); $contents['pay_type'] = array( '#title' => 'Способ оплаты', '#value' => '
Способ оплаты: '. $payment_methods[$arg1->payment_method] .'
', ); } } return array('description' => $description, 'contents' => $contents); case 'process': return TRUE; case 'review': $review = array(); return $review; } } /** * Вывод блока работы с ФИО (часть блока delivery) */ function uc_checkout_pane_fioDelivery($op, &$arg1, $arg2) { global $user; switch ($op) { case 'view': $description = t('Enter your last name and first name.'); $fio_last_name = $arg1 ? $arg1->delivery_last_name : ''; $fio_first_name = $arg1 ? $arg1->delivery_first_name : ''; $fio_name = trim($fio_last_name.' '.$fio_first_name); if ( !strlen($fio_name) && $user->uid ){ $_name = user_verification::getProfileField('profile_name', $user->uid); $_name2 = user_verification::getProfileField('profile_name2', $user->uid); if ( !strlen($_name.$_name2) ){ $_name = user_verification::getLastOrderField('delivery_first_name', $user->uid); $_name2 = user_verification::getLastOrderField('delivery_last_name', $user->uid); } if ( strlen($_name.$_name2) ){ $fio_name = trim(drupal_ucfirst($_name2).' '.drupal_ucfirst($_name)); } } $contents['fio_name'] = uc_textfield(t('Your last name and first name'), $fio_name, true, NULL, 128, 128); return array('description' => $description, 'contents' => $contents); case 'process': $arg_ex = explode(' ',$arg2['fio_name']); $arg1->delivery_last_name = $arg_ex[0]; $arg1->delivery_first_name = trim(str_replace($arg_ex[0], '',$arg2['fio_name'])); return TRUE; case 'review': $review = array(); return $review; } } /** * Вывод блока работы с телефоном (часть блока delivery) */ function uc_checkout_pane_phoneDelivery($op, &$arg1, $arg2) { global $user; switch ($op) { case 'view': $description = t('Enter your phone.'); $phone = $arg1 ? $arg1->delivery_phone : ''; if ( !strlen($phone) && $user->uid ){ $_phone = user_verification::getLastOrderField('delivery_phone', $user->uid); if ( strlen($_phone) ){ $phone = substr(preg_replace('/[^\d]/', '', $_phone), -10); } } $contents['phone'] = uc_textfield(uc_get_field_name('phone'), $phone, uc_address_field_required('phone'), NULL, 32, 16); $contents['phone']['#attributes']['class'] = "phone-mask"; $contents['phone']['#element_validate'] = array('_uc_checkout_pane_phoneDelivery_validate'); return array('description' => $description, 'contents' => $contents); case 'process': $arg1->delivery_phone = $arg2['phone']; return TRUE; case 'review': $review = array(); $review[] = array('title' => t('Phone'), 'data' => check_plain($arg1->delivery_phone)); return $review; } } /** * Валидация поля phone */ function _uc_checkout_pane_phoneDelivery_validate($element, &$form_state) { $_phone = trim($form_state['values']['panes']['phoneDelivery']['phone']); $_phone = preg_replace('/[^0-9]/', '', $_phone); if (isset($_POST['op']) && $_POST['op'] == t('Back')){ }elseif ( strlen($_phone) < 10 ){ form_error($element, t('Поле !name должно содержать не менее 10 цифр.',array('!name'=>$element['#title']))); } } /** * Вывод блока работы с адресом (часть блока delivery) */ function uc_checkout_pane_addressDelivery_old($op, &$arg1, $arg2) { global $user; switch ($op) { case 'view': $isExWorks = false; // признак Самовывоза $contents = array(); $nodes = array(); $result = db_query("SELECT n.nid FROM {node} n WHERE n.status <> 0 AND n.type = '%s'", 'address'); while ($node = db_fetch_object($result)) { $node = node_load($node->nid); if ( !isset($node->taxonomy) ) continue; $taxonomy = array_values($node->taxonomy); $otherCity = true; foreach ( $taxonomy as $city ){ if ( trim($city->name) == trim($arg1->delivery_city) ){ $otherCity = false; break; } } if ( !$otherCity && isset($node->field_order_delivery[0]['value']) ){ foreach ( $node->field_order_delivery as $field_order_delivery ){ if ( $field_order_delivery['value'] == $arg1->quote['method'] ){ $nodes[] = $node; if ( !$isExWorks && isset($node->field_address_type[0]['value']) && $node->field_address_type[0]['value'] == 'ex-works' ){ $isExWorks = true; } } } } } $description = ''; $shipping_method = uc_quote_shipping_method_options(); if ( !$isExWorks ){ $description .= t( 'You have chosen delivery "@method" in the city of @city.
'.'Please fill in the delivery address below', array('@method'=>$shipping_method[$arg1->quote['method']], '@city'=>$arg1->delivery_city) ); $street = $arg1 ? $arg1->delivery_street1 : ''; if ( in_array($arg1->quote['method'], array('rupost_1', 'ems')) ){ $postal_code = $arg1 ? $arg1->delivery_postal_code : ''; $contents['postal_code'] = uc_textfield(uc_get_field_name('postal_code'), $postal_code, uc_address_field_required('postal_code'), NULL, 10, 10); //watchdog('uccccc', '
'.print_r($contents['postal_code'],1).'
'); //watchdog('uccccc', '
'.print_r($arg1,1).'
'); } $contents['street'] = uc_textfield(uc_get_field_name('street1'), $street, uc_address_field_required('street1'), NULL, 128); }else{ $description .= t( 'You have chosen delivery "@method"', array('@method'=>$shipping_method[$arg1->quote['method']]) ); foreach ( $nodes as $node ){ if ( isset($node->field_address_scheme[0]['filepath']) && strlen($node->field_address_scheme[0]['filepath']) ){ $description .= ''.$node->title.''; } $description .= '
'.$node->teaser.'
'; } } return array('description' => $description, 'contents' => $contents); case 'process': $arg1->delivery_street1 = $arg2['street']; $arg1->delivery_postal_code = $arg2['postal_code']; return TRUE; case 'review': $review = array(); $review[] = array('title' => t('Address'), 'data' => uc_order_address($arg1, 'delivery', FALSE)); return $review; } } /** * Вывод блока работы с адресом (часть блока delivery) */ function uc_checkout_pane_addressDelivery($op, &$arg1, $arg2) { global $user; //watchdog('uc-'.$op, '
'.print_r(array('$op'=>$op, '$arg1'=>$arg1, '$arg2'=>$arg2),1).'
'); switch ($op) { case 'view': $contents = array(); $postal_code = $arg1 ? $arg1->delivery_postal_code : ''; $contents['postal_code'] = uc_textfield(uc_get_field_name('postal_code'), $postal_code, false, NULL, 10, 10); $contents['postal_code']['#element_validate'] = array('_uc_checkout_pane_addressDelivery_postal_code_validate'); $street = $arg1 ? $arg1->delivery_street1 : ''; $contents['street'] = uc_textfield(uc_get_field_name('street1'), $street, false, NULL, 128, 128); $contents['street']['#element_validate'] = array('_uc_checkout_pane_addressDelivery_street_validate'); $mids = _uc_checkout_pane_addressDelivery_getExWorks(); $drupal_settings = array( 'addressDelivery' => array( 'ex_works_mids' => $mids, ), ); drupal_add_js(array('indi_checkout' => $drupal_settings), 'setting'); drupal_add_js(drupal_get_path('module', 'indi_light') .'/js/checkout.js', 'module', 'header'); return array('description' => $description, 'contents' => $contents); case 'process': $arg1->delivery_street1 = $arg2['street']; $arg1->delivery_postal_code = $arg2['postal_code']; return TRUE; case 'review': $review = array(); $review[] = array('title' => t('Address'), 'data' => uc_order_address($arg1, 'delivery', FALSE)); return $review; } } /** * Формирование массива IDшников самовывоза */ function _uc_checkout_pane_addressDelivery_getExWorks() { static $cache; if ( !isset($cache) ){ $cache = array(); $result = db_query("SELECT field_order_delivery_value FROM content_type_address WHERE field_address_type_value = '%s' order by field_order_delivery_value", 'ex-works'); while ($item = db_fetch_object($result)) { $cache[] = (int)str_replace('flatrate_', '', $item->field_order_delivery_value); } } return isset($cache) ? $cache : array(); } /** * Валидация поля postal_code */ function _uc_checkout_pane_addressDelivery_postal_code_validate($element, &$form_state) { if ( uc_address_field_required('postal_code') && empty($element['#value']) ){ $quote_method = $element['#post']['quote-option']; $quote_method = str_replace('flatrate_', '', $quote_method); $quote_method = preg_replace('/---\d+/', '', $quote_method); if ( in_array($quote_method, array('rupost_1', 'ems')) ){ form_error($element, t('!name field is required.',array('!name'=>$element['#title']))); } } } /** * Валидация поля street */ function _uc_checkout_pane_addressDelivery_street_validate($element, &$form_state) { if ( uc_address_field_required('street1') && empty($element['#value']) ){ $quote_method = $element['#post']['quote-option']; $quote_method = str_replace('flatrate_', '', $quote_method); $quote_method = preg_replace('/---\d+/', '', $quote_method); $mids = _uc_checkout_pane_addressDelivery_getExWorks(); if ( !in_array($quote_method, $mids) ){ form_error($element, t('!name field is required.',array('!name'=>$element['#title']))); } } } /** * Вывод блока работы с городом (часть блока delivery) */ function uc_checkout_pane_cityDelivery($op, &$arg1, $arg2) { global $user; //watchdog('uc-'.$op, '
'.print_r(array('$op'=>$op, '$arg1'=>$arg1, '$arg2'=>$arg2),1).'
'); switch ($op) { case 'view': $description = t('Enter your country.'); // print_r($arg1); // $delivery_country = $arg1 ? $arg1->delivery_country : NULL; // $delivery_zone = $arg1 ? $arg1->delivery_zone : NULL; // $delivery_city_id = $arg1 ? $arg1->delivery_city_id : ''; // $delivery_city = $arg1 ? $arg1->delivery_city : ''; if ( empty($delivery_country) || empty($delivery_city) ){ $userLocation = user_location::getLocation(); if ( !empty($userLocation['country_code']) ) $delivery_country = $userLocation['country_code']; if ( !empty($userLocation['region_code']) ) $delivery_zone = $userLocation['region_code']; if ( !empty($userLocation['city_code']) ) $delivery_city_id = $userLocation['city_code']; if ( !empty($userLocation['city']) ) $delivery_city = $userLocation['city']; if ( !empty($delivery_city) && empty($delivery_city_id) ) $delivery_city_id = -1; } if ( empty($delivery_country) ) $delivery_country = 643; // Россия // if ( isset($_SESSION['ss_arg1']['country_id']) ) $delivery_country = $_SESSION['ss_arg1']['country_id']; // if ( isset($_SESSION['ss_arg1']['zone_id']) ) $delivery_zone = $_SESSION['ss_arg1']['zone_id']; // if ( isset($_SESSION['ss_arg1']['city_id']) ) $delivery_city_id = $_SESSION['ss_arg1']['city_id']; // $contents['delivery_country_id'] = _uc_checkout_pane_cityDelivery_country_select(t('Your country'), $delivery_country, NULL, 'country_name', true); // //$contents['delivery_city_id'] = _uc_checkout_pane_cityDelivery_city_select(t('Your city'), $delivery_city, NULL, 'name', true); $contents['delivery_city_id'] = array('#type' => 'hidden', '#default_value' => $delivery_city_id); $contents['delivery_city'] = array('#type' => 'hidden', '#default_value' => $delivery_city); $contents['delivery_zone'] = array('#type' => 'hidden', '#default_value' => $delivery_zone); $contents['delivery_country'] = array('#type' => 'hidden', '#default_value' => $delivery_country); $contents['delivery_city_link'] = array( '#value' => '
'. $delivery_city .' выбрать другой
', ); /* $city_other_selected = _uc_checkout_pane_cityDelivery_city_other_selected($delivery_city, 'name'); // подготовка полей для выбора города или его ввода с выбором региона $d_city_id = array('city_id'=>_uc_checkout_pane_cityDelivery_city_select(t('Your city'), $delivery_city, NULL, 'name', true)); $d_city = array('city'=>uc_textfield(uc_get_field_name('city'), $city_other_selected ? $delivery_city : '', false)); $d_city['city']['#element_validate'] = array('_uc_checkout_pane_cityDelivery_city_validate'); $d_zone = array('zone'=>_uc_checkout_pane_cityDelivery_zone_select(uc_get_field_name('zone'), $city_other_selected?$delivery_zone:'', '', 'zone_name', false)); $d_zone['zone']['#element_validate'] = array('_uc_checkout_pane_cityDelivery_zone_validate'); // формирование прятающегося блока с полями выбора города, или связкой полей ввода города и зоны (когда выбран Другой город) $cityBlockHide = intval($_POST['panes']['cityDelivery']['delivery_country_id']>0) ? false : true; $contents['cityBlock'] = array( '#type' => 'markup', '#prefix' => '' ) + array_merge($d_city_id, $d_zone, $d_city); // формирование js-массивов зон и городов по странам $zone_js_arr = $zone_country_js_arr = array(); $zones = _uc_checkout_pane_cityDelivery_getZones(); foreach ( $zones as $zone ) { if ( !isset($zone_country_js_arr[$zone->zone_country_id]) ) $zone_country_js_arr[$zone->zone_country_id] = array(); $zone_country_js_arr[$zone->zone_country_id][] = "['".intval($zone->zone_id)."','".$zone->zone_name."']"; } if ( count($zone_country_js_arr) ) { foreach ($zone_country_js_arr as $country=>$zones) { $zone_js_arr[] = "'".intval($country)."':"."[".implode(',',$zones)."]"; } } $cities = taxonomy_get_tree(11); $city_js_arr = array(); foreach ($cities as $city) { $term = taxonomy_get_term($city->tid); $fields = term_fields_get_fields($term); $city_js_arr[] = "['".intval($city->tid)."','".$city->name."','".intval($fields['zone'])."','".intval($fields['country'])."']"; } */ //drupal_add_js(drupal_get_path('module', 'uc_cart') .'/uc_city_delivery.js'); /* drupal_add_js('$(function() { cityDeliveryGetZones = function(country) { var zones = {'.implode(',',$zone_js_arr).'}; return zones[country] !== "undefined" ? zones[country] : false; } cityDeliveryGetCities = function() { return ['.implode(',',$city_js_arr).']; } cityDeliveryInit(); })', 'inline'); // (конец) формирование js-массивов зон и городов по странам */ //drupal_add_js('$(function() {cityDeliveryInit();})', 'inline'); //drupal_add_js('$(document).ready(function(){cityDeliveryInit();})', 'inline'); drupal_add_js(drupal_get_path('module', 'indi_light') .'/js/checkout.js', 'module', 'header'); return array('description' => $description, 'contents' => $contents); case 'process': /*if (intval($arg2['cityBlock']['city_id']) > 1){ $city = taxonomy_get_term($arg2['cityBlock']['city_id']); $fields = term_fields_get_fields($city); $arg1->delivery_city = $city->name; $arg1->delivery_zone = $fields['zone']; }else{ $arg1->delivery_city = $arg2['cityBlock']['city']; $arg1->delivery_zone = $arg2['cityBlock']['zone']; } $arg1->delivery_city = $arg2['delivery_city']; $arg1->delivery_zone = $arg2['delivery_zone']; $zone_object = db_fetch_object(db_query("SELECT * FROM {uc_zones} WHERE zone_id = %d", $arg1->delivery_zone)); $arg1->delivery_country = $zone_object->zone_country_id; $arg1->delivery_country_id = $arg2['delivery_country_id']; $arg1->delivery_city_id = $arg2['cityBlock']['city_id']; //watchdog('uc-ccc-'.$op, '
'.print_r(array('$op'=>$op, '$arg1'=>$arg1, '$zone_object'=>$zone_object),1).'
'); $_SESSION['ss_arg1']['country_id'] = $arg2['delivery_country_id']; $_SESSION['ss_arg1']['city_id'] = $arg2['cityBlock']['city_id']; $_SESSION['ss_arg1']['zone'] = $arg1->delivery_zone; */ $arg1->delivery_city = $arg2['delivery_city']; $arg1->delivery_zone = $arg2['delivery_zone']; $arg1->delivery_country = $arg2['delivery_country']; return TRUE; case 'review': $review = array(); return $review; } } /** * Creates a country list. */ function _uc_checkout_pane_cityDelivery_getCountries($display = 'country_name') { static $cache; if ( !isset($cache[$display]) ){ $cache[$display] = array(); $result = db_query("SELECT * FROM {uc_countries} WHERE version > 0 ORDER BY %s", $display); while ($item = db_fetch_object($result)) { $cache[$display][] = $item; } } return isset($cache[$display]) && !empty($cache[$display]) ? $cache[$display] : array(); } /** * Creates a zone list. */ function _uc_checkout_pane_cityDelivery_getZones($display = 'zone_name') { static $cache; if ( !isset($cache[$display]) ){ $cache[$display] = array(); $countries = array(); $countriesList = _uc_checkout_pane_cityDelivery_getCountries(); foreach ( $countriesList as $country ) { $countries[] = $country->country_id; } $result = db_query("SELECT * FROM {uc_zones} WHERE zone_country_id in (".implode(',', $countries).") ORDER BY %s", $display); while ($item = db_fetch_object($result)) { $cache[$display][] = $item; } } return isset($cache[$display]) && !empty($cache[$display]) ? $cache[$display] : array(); } /** * Creates a country select box for a form. */ function _uc_checkout_pane_cityDelivery_country_select($title, $default = NULL, $description = NULL, $display = 'country_name', $required = FALSE) { $options = $options_tmp = array(); $countriesList = _uc_checkout_pane_cityDelivery_getCountries($display); foreach ( $countriesList as $country ) { $options[$country->country_id] = t($country->$display); //if ($options[$country->country_id] === $default) $default = $country->country_id; } if (count($options) == 0) { $options_tmp[] = t('No country found'); }else{ $options_tmp[''] = t('Please select'); } if (isset($options[643])) { $options_tmp[643] = $options[643]; unset($options[643]); } $options_tmp += $options; $options = $options_tmp; //ksort($options); //natcasesort($options); $select = array( '#type' => 'select', '#title' => $title, '#description' => $description, '#options' => $options, '#default_value' => intval($default), '#required' => $required, ); return $select; } /** * Creates a zone select box for a form. */ function _uc_checkout_pane_cityDelivery_zone_select($title, $default = NULL, $description = NULL, $display = 'zone_name', $required = FALSE) { $zones = _uc_checkout_pane_cityDelivery_getZones($display); $options = array(); foreach ( $zones as $zone ) { $options[$zone->zone_id] = t($zone->$display); //if ($options[$zone->zone_id] === $default) $default = $zone->zone_id; } if (count($options) == 0) { $options[] = t('No zone found'); }else{ $options[''] = t('Please select'); } //ksort($options); //natcasesort($options); $select = array( '#type' => 'select', '#title' => $title, '#description' => $description, '#options' => $options, '#default_value' => intval($default), '#required' => $required, ); return $select; } /** * Creates a city select box for a form. */ function _uc_checkout_pane_cityDelivery_city_select($title, $default = NULL, $description = NULL, $display = 'name', $required = FALSE) { $result = taxonomy_get_tree(11); $options = array(); foreach ($result as $city) { $city = (array)$city; $options[$city['tid']] = $city[$display]; if ($options[$city['tid']] == $default) $default = $city['tid']; } if (count($options) == 0) { $options[] = t('No city found'); $options[-1] = t('Other city...'); }else{ natcasesort($options); $options = array(-1=>t('Other city...')) + $options; $options = array(''=>t('Select your city...')) + $options; //$options[''] = t('Select your city...'); } //natcasesort($options); //$options[-1] = t('Other city...'); //$default = db_result(db_query("SELECT country_id FROM {uc_countries} WHERE country_id = %d AND version > 0", empty($default) ? 0 : intval($default))); $select = array( '#type' => 'select', '#title' => $title, '#description' => $description, '#options' => $options, '#default_value' => intval($default), '#required' => $required, ); /*drupal_add_js(drupal_get_path('module', 'uc_store') .'/uc_country_select.js');*/ return $select; } /** * Проверка: выбран ли пункт Другой город? */ function _uc_checkout_pane_cityDelivery_city_other_selected($default, $display = 'name') { $result = taxonomy_get_tree(11); $options = array(); foreach ($result as $city) { $city = (array)$city; if ($city[$display] == $default) return false; } return true; } /** * Валидация поля cityDelivery[city] */ function _uc_checkout_pane_cityDelivery_city_validate($element, &$form_state) { if ( uc_address_field_required('city') && $form_state['values']['panes']['cityDelivery']['cityBlock']['city_id']==-1 && empty($element['#value']) ){ form_error($element, t('!name field is required.',array('!name'=>$element['#title']))); } } /** * Валидация поля cityDelivery[zone] */ function _uc_checkout_pane_cityDelivery_zone_validate($element, &$form_state) { if ( uc_address_field_required('zone') && $form_state['values']['panes']['cityDelivery']['cityBlock']['city_id']==-1 && empty($element['#value']) ){ form_error($element, t('!name field is required.',array('!name'=>$element['#title']))); } } /** * Implementation of hook_form_FORM_ID_alter(). */ function uc_cart_form_taxonomy_form_term_alter_OLD(&$form, &$form_state) { // We don't want our form to appear on the deletion confirmation screen. if (!(isset($_POST['op']) && $_POST['op'] == t('Delete')) || isset($_POST['confirm'])) { // Shortcuts $tid = $form['tid']['#value']; $term = taxonomy_get_term($tid); $default_values = term_fields_get_fields($term); // country select $options = array(); $result = db_query("SELECT * FROM {uc_countries} WHERE version > 0 ORDER BY %s", 'country_name'); while ($country = db_fetch_object($result)) { $options[$country->country_id] = $country->country_name; } if (count($options)<1) { $options = array(-1 => t('Not applicable')); } $default = $default_values['country']; $form['fields']['country']['#options'] = $options; $form['fields']['country']['#default_value'] = $default || $default === 0 ? $default : uc_store_default_country(); // city select $options = array(); $country_id = null; $country_id = empty($country_id) ? uc_store_default_country() : intval($country_id); $result = db_query("SELECT * FROM {uc_zones} WHERE zone_country_id = %d ORDER BY %s", $country_id, 'zone_name'); while ($zone = db_fetch_object($result)) { $options[$zone->zone_id] = $zone->zone_name; } if (count($options)<1) { $options = array(-1 => t('Not applicable')); } $default = $default_values['zone']; $form['fields']['zone']['#options'] = $options; $form['fields']['zone']['#default_value'] = $default || $default === 0 ? $default : NULL; } } /** * Implementation of hook_form_FORM_ID_alter(). */ function uc_cart_form_taxonomy_form_term_alter(&$form, &$form_state) { // We don't want our form to appear on the deletion confirmation screen. if (!(isset($_POST['op']) && $_POST['op'] == t('Delete')) || isset($_POST['confirm'])) { // Shortcuts $tid = $form['tid']['#value']; $term = taxonomy_get_term($tid); $default_values = term_fields_get_fields($term); // country select $options = array(); $countryList = _uc_checkout_pane_cityDelivery_getCountries('country_name'); foreach ( $countryList as $country ) { $options[$country->country_id] = t($country->country_name); } if (count($options)<1) { $options = array(-1 => t('Not applicable')); } $default = $default_values['country']; $form['fields']['country']['#options'] = $options; $form['fields']['country']['#default_value'] = $default || $default === 0 ? $default : uc_store_default_country(); // zone select $zones = $options = array(); $zoneList = _uc_checkout_pane_cityDelivery_getZones('zone_name'); foreach ( $zoneList as $zone ) { if ( !isset($zones[$zone->zone_country_id]) ) $zones[$zone->zone_country_id] = array(); $zones[$zone->zone_country_id][] = intval($zone->zone_id); $options[$zone->zone_id] = t($zone->zone_name); } if (count($options)<1) { $options = array(-1 => t('Not applicable')); } $default = $default_values['zone']; $form['fields']['zone']['#options'] = $options; $form['fields']['zone']['#default_value'] = $default || $default === 0 ? $default : NULL; $zone_js_arr = array(); if ( count($zones) ) { foreach ($zones as $country=>$items) { $zone_js_arr[] = "'".intval($country)."':"."[".implode(',',$items)."]"; } } drupal_add_js('$(function() { editCountrySelectTrigger = function() { var country = $(this).val(); var zones = {'.implode(',',$zone_js_arr).'}; var defaultZone = $("#edit-zone").val(); if ( zones[country] !== "undefined" ){ zones = zones[country]; $("#edit-zone").find("option[value!=0]").hide(); var selected = -1; $.each(zones, function(i, zone){ if ( selected == -1 ) selected = zone; if ( defaultZone == zone ) selected = defaultZone; $("#edit-zone [value="+zone+"]").show(); }); $("#edit-zone").find("option[value="+selected+"]").attr("selected", "selected");; } } $("#edit-country").change(editCountrySelectTrigger).trigger("change"); })', 'inline'); } } /** * Themes the delivery/billing address forms in tables. * * @see uc_checkout_pane_delivery() * @see uc_checkout_pane_billing() * @ingroup themeable */ function theme_address_pane($form) { $output = ''; $req = '*'; if (isset($form['copy_address'])) { $output .= drupal_render($form['copy_address']); } $output .= '
'; foreach (element_children($form) as $field) { if (substr($field, 0, 9) == 'delivery_' || substr($field, 0, 8) == 'billing_') { $title = $form[$field]['#title'] .':'; unset($form[$field]['#title']); if (substr($field, -7) == 'street1') { $title = uc_get_field_name('street') .':'; } elseif (substr($field, -7) == 'street2') { $title = ' '; } $output .= ''; $output .= ''; } } $output .= '
'; $output .= ''. drupal_render($form[$field]) .'
'; foreach (element_children($form) as $element) { $output .= drupal_render($form[$element]); } return $output; } /** * Finds the collapsible pane displayed above the pane with an ID of $pane_id. */ function _uc_cart_checkout_prev_pane($panes, $pane_id = NULL) { if (is_null($pane_id)) { return FALSE; } $prev = FALSE; foreach ($panes as $target) { if ($target['id'] == $pane_id) { return $prev; } if ($target['collapsible'] && $target['enabled']) { $prev = $target['id']; } } return FALSE; } /** * Finds the pane that displays below the pane with an ID of $pane_id. */ function _uc_cart_checkout_next_pane($panes, $pane_id = NULL) { if (is_null($pane_id)) { return FALSE; } $next = FALSE; foreach ($panes as $target) { if ($next) { if ($target['collapsible'] && $target['enabled']) { return $target['id']; } } if ($target['id'] == $pane_id) { $next = TRUE; } } return FALSE; } /** * Builds a list of checkout panes defined in the enabled modules. */ function _checkout_pane_list($action = NULL) { static $panes; if (count($panes) > 0 && $action !== 'rebuild') { return $panes; } $panes = module_invoke_all('checkout_pane', NULL); // Set the global default values first foreach ($panes as $i => $value) { $panes[$i]['enabled'] = variable_get('uc_pane_'. $panes[$i]['id'] .'_enabled', (!isset($panes[$i]['enabled']) ? TRUE : $panes[$i]['enabled'])); $panes[$i]['weight'] = variable_get('uc_pane_'. $panes[$i]['id'] .'_weight', (!isset($panes[$i]['weight']) ? 0 : $panes[$i]['weight'])); } // Allow other modules to alter the panes. drupal_alter('checkout_pane', $panes); // Make sure that all the required attributes are set foreach ($panes as $i => $value) { $panes[$i]['enabled'] = !isset($panes[$i]['enabled']) ? TRUE : $panes[$i]['enabled']; $panes[$i]['weight'] = !isset($panes[$i]['weight']) ? 0 : $panes[$i]['weight']; $panes[$i]['review'] = !isset($panes[$i]['review']) ? TRUE : $panes[$i]['review']; $panes[$i]['process'] = !isset($panes[$i]['process']) ? TRUE : $panes[$i]['process']; $panes[$i]['collapsible'] = !isset($panes[$i]['collapsible']) ? TRUE : $panes[$i]['collapsible']; } usort($panes, 'uc_weight_sort'); return $panes; } /** * Returns data from a checkout pane by pane ID and the array key. */ function _checkout_pane_data($pane_id, $key) { $panes = _checkout_pane_list(); foreach ($panes as $pane) { if ($pane['id'] == $pane_id) { return $pane[$key]; } } } /** * Formats the cart contents table on the checkout page. * * @param $show_subtotal * TRUE or FALSE indicating if you want a subtotal row displayed in the table. * * @return * The HTML output for the cart review table. * * @ingroup themeable */ function theme_cart_review_table($show_subtotal = TRUE) { $subtotal = 0; // Set up table header. $header = array( array('data' => t('Qty'), 'class' => 'qty'), array('data' => t('Products'), 'class' => 'products'), array('data' => t('Price'), 'class' => 'price'), ); $context = array(); // Set up table rows. $contents = uc_cart_get_contents(); foreach ($contents as $item) { $price_info = array( 'price' => $item->price, 'qty' => $item->qty, ); $context['revision'] = 'altered'; $context['type'] = 'cart_item'; $context['subject'] = array( 'cart' => $contents, 'cart_item' => $item, 'node' => node_load($item->nid), ); $total = uc_price($price_info, $context); $subtotal += $total; $description = check_plain($item->title) . uc_product_get_description($item); // Remove node from context to prevent the price from being altered. $context['revision'] = 'themed-original'; $context['type'] = 'amount'; unset($context['subject']); $rows[] = array( array('data' => t('@qty×', array('@qty' => $item->qty)), 'class' => 'qty'), array('data' => $description, 'class' => 'products'), array('data' => uc_price($total, $context), 'class' => 'price'), ); } // Add the subtotal as the final row. if ($show_subtotal) { $context = array( 'revision' => 'themed-original', 'type' => 'amount', ); $rows[] = array( 'data' => array(array('data' => '' . t('Subtotal:') . ' ' . uc_price($subtotal, $context), 'colspan' => 3, 'class' => 'subtotal')), 'class' => 'subtotal', ); } return theme('table', $header, $rows, array('class' => 'cart-review')); } /** * Themes cart items on the checkout review order page. * * @param $items * An associative array containing cart items, with keys: * - qty: Quantity in cart. * - title: Item title. * - price: Item price. * - desc: Item description. * * @return * A string of HTML for the page contents. * * @ingroup themeable */ function theme_uc_checkout_pane_cart_review($items) { $context = array( 'revision' => 'themed', 'type' => 'cart_item', 'subject' => array(), ); $rows = array(); foreach ($items as $item) { $price_info = array( 'price' => $item->price, 'qty' => $item->qty, ); $context['subject'] = array( 'cart' => $items, 'cart_item' => $item, 'node' => node_load($item->nid), ); $rows[] = array( array('data' => $item->qty . '×', 'class' => 'qty'), array('data' => check_plain($item->title) . uc_product_get_description($item), 'class' => 'products'), array('data' => uc_price($price_info, $context), 'class' => 'price'), ); } return theme('table', NULL, $rows, array('class' => 'cart-review')); } Купить скетчбуки, блокноты и записные книжки inTempo — магазин indinotes
Смотреть корзину.

Блокноты в точкуРучки  Cleo SkribentИндексные карточки

inTempo

Предлагаем вам широкий ассортимент товаров раздела inTempo магазина indinotes.com
В разделе inTempo вы можете купить inTempo с доставкой по Москве и России.

Мы — специализированный магазин записных книжек и блокнотов. У нас вы всегда сможете подобрать inTempo с необходимыми параметрами именно для вас из нашего большого ассортимента.

Любой товар из раздела может стать отличным корпоративным подарком. Мы можем предложить вам нанесение (брендирование) различных видов (тиснение фольгой и цветом, наклейка, тампопечать и др.). Для рекламных агентств, оптовых и корпоративных покупателей — специальные условия.

Каталог товаров раздела inTempo, цены на inTempo, обзоры inTempo, почитать отзывы о товарах из раздела inTempo.

inTempo

inTempo

inTempo — бренд компании Diarpell.

С 1973 Diarpell SRL, компания из Флоренции, имеет уникальный опыт в  производстве изделий из кожи и бумаги различного назначения: ежедневников, дневников, планнингов, записных книжек, органайзеров и адресных книг.

Получив большой опыт сотрудничества с самыми престижными брендами, Diarpell отличается своей гибкостью и  умением оставаться в тренде, каждый раз предлагая новые элементы, решения, которые никогда не выходят из моды.

Текущая  коллекция Diarpell включают в себя дневники, фотоальбомы, органайзеры, журналы, тетради, адресные книги, расширения файлов, визитницы и многое другое. Все продукты компании отличаются высочайшим качеством и интересными дизайнерскими находками.

Подбор по параметрам
р.
гр./кв.м.