public function update($id, $params) { fn_define('ORDER_MANAGEMENT', true); $data = array(); $valid_params = true; $status = Response::STATUS_BAD_REQUEST; if ($valid_params) { fn_clear_cart($cart, true); $customer_auth = fn_fill_auth(array(), array(), false, 'C'); $cart_status = md5(serialize($cart)); // Order info was not found or customer does not have enought permissions if (fn_form_cart($id, $cart, $customer_auth) && $cart_status != md5(serialize($cart))) { unset($params['product_groups']); if (empty($params['shipping_id'])) { $shipping = reset($cart['shipping']); if (!empty($shipping['shipping_id'])) { $params['shipping_id'] = $shipping['shipping_id']; } } $cart['order_id'] = $id; fn_calculate_cart_content($cart, $customer_auth); if (!empty($params['user_id'])) { $cart['user_data'] = fn_get_user_info($params['user_id']); } elseif (!empty($params)) { $cart['user_data'] = array_merge($cart['user_data'], $params); } if (!empty($cart['product_groups']) && !empty($params['shipping_id'])) { foreach ($cart['product_groups'] as $key => $group) { foreach ($group['shippings'] as $shipping_id => $shipping) { if ($params['shipping_id'] == $shipping['shipping_id']) { $cart['chosen_shipping'][$key] = $shipping_id; break; } } } } if (!empty($params['payment_id'])) { if (!empty($params['payment_info'])) { $cart['payment_info'] = $params['payment_info']; } elseif ($params['payment_id'] != $cart['payment_id']) { $cart['payment_info'] = array(); } $cart['payment_id'] = $params['payment_id']; } if (!empty($params['products'])) { $cart['products'] = $params['products']; } fn_calculate_cart_content($cart, $customer_auth); if (!empty($cart) && empty($cart['shipping_failed'])) { $cart['parent_order_id'] = 0; fn_update_payment_surcharge($cart, $customer_auth); list($order_id, $order_status) = fn_update_order($cart, $id); if ($order_id) { if (!empty($params['status']) && fn_check_permissions('orders', 'update_status', 'admin')) { fn_change_order_status($order_id, $params['status'], '', fn_get_notification_rules($params, false)); } elseif (!empty($order_status)) { fn_change_order_status($order_id, $order_status, '', fn_get_notification_rules($params, false)); } $status = Response::STATUS_OK; $data = array('order_id' => $order_id); } } } } return array('status' => $status, 'data' => $data); }
/** * Send order notification * * @param array $order_info order information * @param array $edp_data information about downloadable products * @param mixed $force_notification user notification flag (true/false), if not set, will be retrieved from status parameters * @return array structured data */ function fn_order_notification(&$order_info, $edp_data = array(), $force_notification = array()) { static $notified = array(); $send_order_notification = true; if (!empty($notified[$order_info['order_id']][$order_info['status']]) && $notified[$order_info['order_id']][$order_info['status']] || $order_info['status'] == STATUS_INCOMPLETED_ORDER || $order_info['status'] == STATUS_PARENT_ORDER) { $send_order_notification = false; } fn_set_hook('send_order_notification', $order_info, $edp_data, $force_notification, $notified, $send_order_notification); $take_surcharge_from_vendor = false; if (fn_allowed_for('MULTIVENDOR')) { $take_surcharge_from_vendor = fn_take_payment_surcharge_from_vendor($order_info['products']); } if (!$send_order_notification) { return true; } $order_statuses = fn_get_statuses(STATUSES_ORDER, array(), true, false, $order_info['lang_code'] ? $order_info['lang_code'] : CART_LANGUAGE, $order_info['company_id']); $status_params = $order_statuses[$order_info['status']]['params']; $notify_user = !empty($status_params['notify']) && $status_params['notify'] == 'Y'; $notify_department = !empty($status_params['notify_department']) && $status_params['notify_department'] == 'Y'; $notify_vendor = !empty($status_params['notify_vendor']) && $status_params['notify_vendor'] == 'Y'; if (!is_array($force_notification)) { $force_notification = fn_get_notification_rules($force_notification, !$force_notification); } if (isset($force_notification['C'])) { $notify_user = $force_notification['C']; } if (isset($force_notification['A'])) { $notify_department = $force_notification['A']; } if (isset($force_notification['V'])) { $notify_vendor = $force_notification['V']; } if ($notify_user || $notify_department || $notify_vendor) { $notified[$order_info['order_id']][$order_info['status']] = true; $order_status = $order_statuses[$order_info['status']]; $payment_id = !empty($order_info['payment_method']['payment_id']) ? $order_info['payment_method']['payment_id'] : 0; $payment_method = fn_get_payment_data($payment_id, $order_info['order_id'], $order_info['lang_code']); $status_settings = $order_statuses[$order_info['status']]['params']; $profile_fields = fn_get_profile_fields('I', '', $order_info['lang_code']); $secondary_currency = ''; list($shipments) = fn_get_shipments_info(array('order_id' => $order_info['order_id'], 'advanced_info' => true)); $use_shipments = !fn_one_full_shipped($shipments); // restore secondary currency if (!empty($order_info['secondary_currency']) && Registry::get("currencies.{$order_info['secondary_currency']}")) { $secondary_currency = $order_info['secondary_currency']; } // Notify customer if ($notify_user == true) { Mailer::sendMail(array('to' => $order_info['email'], 'from' => 'company_orders_department', 'data' => array('order_info' => $order_info, 'shipments' => $shipments, 'use_shipments' => $use_shipments, 'order_status' => $order_status, 'payment_method' => $payment_method, 'status_settings' => $status_settings, 'profile_fields' => $profile_fields, 'secondary_currency' => $secondary_currency, 'take_surcharge_from_vendor' => $take_surcharge_from_vendor), 'tpl' => 'orders/order_notification.tpl', 'company_id' => $order_info['company_id']), 'C', $order_info['lang_code']); if (!empty($edp_data)) { Mailer::sendMail(array('to' => $order_info['email'], 'from' => 'company_orders_department', 'data' => array('order_info' => $order_info, 'edp_data' => $edp_data), 'tpl' => 'orders/edp_access.tpl', 'company_id' => $order_info['company_id']), 'C', $order_info['lang_code']); } } if ($notify_vendor == true) { if (fn_allowed_for('MULTIVENDOR') && !empty($order_info['company_id'])) { $company_lang_code = fn_get_company_language($order_info['company_id']); // Translate descriptions to admin language fn_translate_products($order_info['products'], '', $company_lang_code, true); Mailer::sendMail(array('to' => 'company_orders_department', 'from' => 'default_company_orders_department', 'reply_to' => $order_info['email'], 'data' => array('order_info' => $order_info, 'shipments' => $shipments, 'use_shipments' => $use_shipments, 'order_status' => fn_get_status_data($order_info['status'], STATUSES_ORDER, $order_info['order_id'], $company_lang_code), 'payment_method' => fn_get_payment_data($payment_id, $order_info['order_id'], $company_lang_code), 'status_settings' => $status_settings, 'profile_fields' => fn_get_profile_fields('I', '', $company_lang_code), 'secondary_currency' => $secondary_currency), 'tpl' => 'orders/order_notification.tpl', 'company_id' => $order_info['company_id']), 'A', $company_lang_code); } } // Notify order department if ($notify_department == true) { // Translate descriptions to admin language fn_translate_products($order_info['products'], '', Registry::get('settings.Appearance.backend_default_language'), true); $payment_method = array(); if ($payment_id) { $payment_method = fn_get_payment_data($payment_id, $order_info['order_id'], Registry::get('settings.Appearance.backend_default_language')); } fn_add_user_data_descriptions($order_info, Registry::get('settings.Appearance.backend_default_language')); Mailer::sendMail(array('to' => 'default_company_orders_department', 'from' => 'default_company_orders_department', 'reply_to' => $order_info['email'], 'data' => array('order_info' => $order_info, 'shipments' => $shipments, 'use_shipments' => $use_shipments, 'order_status' => fn_get_status_data($order_info['status'], STATUSES_ORDER, $order_info['order_id'], Registry::get('settings.Appearance.backend_default_language')), 'payment_method' => $payment_method, 'status_settings' => $status_settings, 'profile_fields' => fn_get_profile_fields('I', '', Registry::get('settings.Appearance.backend_default_language')), 'secondary_currency' => $secondary_currency), 'tpl' => 'orders/order_notification.tpl', 'company_id' => $order_info['company_id']), 'A', Registry::get('settings.Appearance.backend_default_language')); } } if (!empty($edp_data) && !$notify_user) { // Send out download links for EDP with "Immediately" Activation mode // TRUE if the EDP download links e-mail has already been sent. Used to avoid sending duplicate e-mails. $download_email_sent = false; foreach ($edp_data as $edp_item) { foreach ($edp_item['files'] as $file) { if (!empty($file['activation']) && $file['activation'] == 'I' && !$download_email_sent) { Mailer::sendMail(array('to' => $order_info['email'], 'from' => 'company_orders_department', 'data' => array('order_info' => $order_info, 'edp_data' => $edp_data), 'tpl' => 'orders/edp_access.tpl', 'company_id' => $order_info['company_id']), 'C', $order_info['lang_code']); $download_email_sent = true; break; } } } } fn_set_hook('order_notification', $order_info, $order_statuses, $force_notification); }
$shipment_id = db_query("INSERT INTO ?:shipments ?e", $shipment_data); foreach ($_REQUEST['shipment_data']['products'] as $key => $amount) { if (isset($order_info['items'][$key])) { $amount = intval($amount); if ($amount > $order_info['items'][$key]['amount'] - $order_info['items'][$key]['shipped_amount']) { $amount = $order_info['items'][$key]['amount'] - $order_info['items'][$key]['shipped_amount']; } $order_info['items'][$key]['amount'] = $amount; } if ($amount == 0) { continue; } $_data = array('item_id' => $key, 'shipment_id' => $shipment_id, 'order_id' => $_REQUEST['shipment_data']['order_id'], 'product_id' => $order_info['items'][$key]['product_id'], 'amount' => $amount); db_query("INSERT INTO ?:shipment_items ?e", $_data); } $force_notification = fn_get_notification_rules($_REQUEST); if (!empty($force_notification['C'])) { $shipment = array('shipment_id' => $shipment_id, 'timestamp' => $shipment_data['timestamp'], 'shipping' => db_get_field('SELECT shipping FROM ?:shipping_descriptions WHERE shipping_id = ?i', $shipment_data['shipping_id']), 'tracking_number' => $shipment_data['tracking_number'], 'carrier' => $shipment_data['carrier'], 'comments' => $shipment_data['comments'], 'items' => $_REQUEST['shipment_data']['products']); $view_mail->assign('shipment', $shipment); $view_mail->assign('order_info', $order_info); fn_send_mail($order_info['email'], Registry::get('settings.Company.company_orders_department'), 'shipments/shipment_products_subj.tpl', 'shipments/shipment_products.tpl', '', $order_info['lang_code']); } if (!empty($shipment_data['order_status'])) { fn_change_order_status($_REQUEST['shipment_data']['order_id'], $shipment_data['order_status']); } fn_set_notification('N', fn_get_lang_var('notice'), fn_get_lang_var('shipment_has_been_created')); } else { fn_set_notification('E', fn_get_lang_var('error'), fn_get_lang_var('products_for_shipment_not_selected')); } $suffix = '.details?order_id=' . $_REQUEST['shipment_data']['order_id']; } elseif ($mode == 'packing_slip' && !empty($_REQUEST['shipment_ids'])) {
function fn_update_gift_certificate($gift_cert_data, $gift_cert_id = 0, $params = array()) { fn_correct_gift_certificate($gift_cert_data); $gift_cert_data['products'] = !empty($gift_cert_data['products']) ? serialize($gift_cert_data['products']) : ''; if (empty($gift_cert_id)) { do { $code = fn_generate_gift_certificate_code(); } while (true == fn_check_gift_certificate_code($code)); $gift_cert_data = fn_array_merge($gift_cert_data, array('gift_cert_code' => $code, 'timestamp' => TIME)); if (fn_allowed_for('ULTIMATE') && Registry::get('runtime.company_id')) { $gift_cert_data['company_id'] = Registry::get('runtime.company_id'); } $gift_cert_id = db_query("INSERT INTO ?:gift_certificates ?e", $gift_cert_data); } else { // Change certfificate status fn_change_gift_certificate_status($gift_cert_id, $gift_cert_data['status'], '', fn_get_notification_rules(array(), false)); //if difference then add line in log $debit_info = db_get_row("SELECT debit AS amount, debit_products AS products FROM ?:gift_certificates_log WHERE gift_cert_id = ?i ORDER BY timestamp DESC", $gift_cert_id); if (empty($debit_info)) { $debit_info = db_get_row("SELECT amount, products FROM ?:gift_certificates WHERE gift_cert_id = ?i", $gift_cert_id); } $is_diff = $gift_cert_data['amount'] - $debit_info['amount'] != 0 || md5($gift_cert_data['products']) != md5($debit_info['products']); if ($is_diff == true) { $_info = array('amount' => $gift_cert_data['amount'], 'products' => $gift_cert_data['products']); fn_add_gift_certificate_log_record($gift_cert_id, $debit_info, $_info); } //Update certificate data $_data = $gift_cert_data; db_query("UPDATE ?:gift_certificates SET ?u WHERE gift_cert_id = ?i", $gift_cert_data, $gift_cert_id); } $gc_data = fn_get_gift_certificate_info($gift_cert_id); fn_gift_certificate_notification($gc_data, fn_get_notification_rules($params)); return $gift_cert_id; }
/*получаем время */ $delivery_time = db_get_field("SELECT time_to_delivery FROM `cscart_orders` WHERE `order_id` ='{$dev_o_id}' LIMIT 0 , 30"); list($order_id, $process_payment) = fn_place_order($cart, $customer_auth, $action); //апдейтим с помощью функции db_query("UPDATE `korzin_db`.`cscart_orders` SET `date_to_delivery` = '{$delivery_date}',\n\t\t\t\t\t\t\t`time_to_delivery` = '{$delivery_time}' WHERE `cscart_orders`.`order_id` ='{$dev_o_id}' LIMIT 1"); //апдейтим поля в ручную if (!empty($order_id)) { if ($action != 'save') { $view->assign('order_action', fn_get_lang_var('placing_order')); $view->display('views/orders/components/placing_order.tpl'); fn_flush(); } if ($process_payment == true) { fn_start_payment($order_id, fn_get_notification_rules($_REQUEST)); } fn_order_placement_routines($order_id, fn_get_notification_rules($_REQUEST), true, $action); } else { return array(CONTROLLER_STATUS_REDIRECT, "order_management.summary"); } } return array(CONTROLLER_STATUS_OK, "order_management{$_suffix}"); } // Delete discount coupon if ($mode == 'delete_coupon') { unset($cart['coupons'][$_REQUEST['c_id']], $cart['pending_coupon']); return array(CONTROLLER_STATUS_REDIRECT, "order_management.totals"); } // // Edit order // if ($mode == 'edit' && !empty($_REQUEST['order_id'])) {
function fn_gift_certificates_change_order_status($status_to, $status_from, &$order_info, $force_notification, $order_statuses) { if (isset($order_info['gift_certificates'])) { foreach ($order_info['gift_certificates'] as $k => $v) { if (!empty($order_statuses[$status_to]['params']['gift_cert_status'])) { fn_change_gift_certificate_status($v['gift_cert_id'], $order_statuses[$status_to]['params']['gift_cert_status'], '', fn_get_notification_rules(array(), true)); // skip notification, it will be sent later in order_notification hook } } } }
$view->assign('sort_order', $sort_order); $view->assign('sort_by', $sort_by); if (false != ($last_item = reset($log))) { $gift_cert_data['amount'] = $last_item['debit']; $gift_cert_data['products'] = $last_item['debit_products']; } $view->assign('templates', fn_get_gift_certificate_templates()); $view->assign('states', fn_get_all_states()); $view->assign('countries', fn_get_countries(CART_LANGUAGE, true)); $view->assign('amount_variants', fn_get_gift_certificate_amount_variants()); $view->assign('gift_cert_data', $gift_cert_data); } elseif ($mode == 'manage') { list($gift_certificates, $search) = fn_get_gift_certificates($_REQUEST); $view->assign('gift_certificates', $gift_certificates); $view->assign('search', $search); fn_gift_certificates_generate_sections('manage'); } elseif ($mode == 'delete') { if (!empty($_REQUEST['gift_cert_id'])) { $result = fn_delete_gift_certificate($_REQUEST['gift_cert_id'], @$_REQUEST['extra']); return array(CONTROLLER_STATUS_REDIRECT, !empty($_REQUEST['return_url']) ? $_REQUEST['return_url'] : "gift_certificates." . ($result ? "manage" : "update?gift_cert_id=" . $_REQUEST['gift_cert_id'])); } } elseif ($mode == 'update_status') { $old_status = db_get_field("SELECT status FROM ?:gift_certificates WHERE gift_cert_id = ?i", $_REQUEST['id']); if (fn_change_gift_certificate_status($_REQUEST['id'], $_REQUEST['status'], '', fn_get_notification_rules($_REQUEST))) { fn_set_notification('N', fn_get_lang_var('notice'), fn_get_lang_var('status_changed')); } else { fn_set_notification('E', fn_get_lang_var('error'), fn_get_lang_var('error_status_not_changed')); $ajax->assign('return_status', $old_status); } exit; }
$usergroup = db_get_row("SELECT a.usergroup_id, a.status, a.type, b.usergroup FROM ?:usergroups as a LEFT JOIN ?:usergroup_descriptions as b ON b.usergroup_id = a.usergroup_id AND b.lang_code = ?s WHERE a.usergroup_id = ?i", DESCR_SL, $_REQUEST['usergroup_id']); $view->assign('usergroup', $usergroup); Registry::set('navigation.tabs', array('general_' . $_REQUEST['usergroup_id'] => array('title' => fn_get_lang_var('general'), 'js' => true))); } elseif ($mode == 'delete') { if (!empty($_REQUEST['usergroup_id'])) { fn_delete_usergroups((array) $_REQUEST['usergroup_id']); } return array(CONTROLLER_STATUS_REDIRECT, "usergroups.manage"); } elseif ($mode == 'update_status') { $user_data = fn_get_user_info($_REQUEST['user_id']); if (empty($user_data) || defined('COMPANY_ID') && $user_data['is_root'] == 'Y' || defined('RESTRICTED_ADMIN') && ($auth['user_id'] == $_REQUEST['user_id'] || fn_is_restricted_admin(array('user_id' => $_REQUEST['user_id'])))) { fn_set_notification('E', fn_get_lang_var('error'), fn_get_lang_var('access_denied')); exit; } $old_status = db_get_field("SELECT status FROM ?:usergroup_links WHERE user_id = ?i AND usergroup_id = ?i", $_REQUEST['user_id'], $_REQUEST['id']); $result = fn_change_usergroup_status($_REQUEST['status'], $_REQUEST['user_id'], $_REQUEST['id'], fn_get_notification_rules($_REQUEST)); if ($result) { fn_set_notification('N', fn_get_lang_var('notice'), fn_get_lang_var('status_changed')); } else { fn_set_notification('E', fn_get_lang_var('error'), fn_get_lang_var('error_status_not_changed')); $ajax->assign('return_status', empty($old_status) ? 'F' : $old_status); } exit; } elseif ($mode == 'requests') { fn_add_breadcrumb(fn_get_lang_var('usergroups'), "usergroups.manage"); list($requests, $search) = fn_get_usergroup_requests($_REQUEST, Registry::get('settings.Appearance.admin_orders_per_page')); $view->assign('usergroup_requests', $requests); $view->assign('search', $search); } function fn_get_usergroup_requests($params, $items_per_page = 0, $status = 'P', $lang_code = CART_LANGUAGE) {
list($cart_products, $product_groups) = fn_calculate_cart_content($cart, $customer_auth); $cart['notes'] = !empty($_REQUEST['customer_notes']) ? $_REQUEST['customer_notes'] : ''; $cart['payment_info'] = !empty($_REQUEST['payment_info']) ? $_REQUEST['payment_info'] : array(); list($order_id, $process_payment) = fn_place_order($cart, $customer_auth, $action, $auth['user_id']); if (!empty($order_id)) { if ($action != 'save') { $action = 'route'; } if ($process_payment == true) { $payment_info = !empty($cart['payment_info']) ? $cart['payment_info'] : array(); fn_start_payment($order_id, fn_get_notification_rules($_REQUEST), $payment_info); } if (!empty($_REQUEST['update_order']['details'])) { db_query('UPDATE ?:orders SET details = ?s WHERE order_id = ?i', $_REQUEST['update_order']['details'], $order_id); } $notification_rules = fn_get_notification_rules($_REQUEST); // change status if it posted if (!empty($_REQUEST['order_status'])) { $order_info = fn_get_order_short_info($order_id); if ($order_info['status'] != $_REQUEST['order_status']) { if ($process_payment == true) { fn_set_notification('W', __('warning'), __('status_changed_after_process_payment')); } elseif (fn_change_order_status($order_id, $_REQUEST['order_status'], '', $notification_rules)) { $order_info = fn_get_order_short_info($order_id); $new_status = $order_info['status']; if ($_REQUEST['order_status'] != $new_status) { fn_set_notification('W', __('warning'), __('status_changed')); } } else { $error = false; if ($order_info['is_parent_order'] == 'Y') {
function fn_get_ebay_orders() { $success_orders = $failed_orders = array(); setlocale(LC_TIME, 'en_US'); $params = array('OrderStatus' => 'Completed'); $last_transaction = db_get_field('SELECT timestamp FROM ?:ebay_cached_transactions WHERE type = ?s AND status = ?s ORDER BY timestamp DESC', 'orders', 'C'); // Need user_id if (!empty($last_transaction)) { $params['CreateTimeFrom'] = gmstrftime("%Y-%m-%dT%H:%M:%S", $last_transaction); $params['CreateTimeTo'] = gmstrftime("%Y-%m-%dT%H:%M:%S", TIME); } $data = array('timestamp' => TIME, 'user_id' => $_SESSION['auth']['user_id'], 'session_id' => Session::getId(), 'status' => 'A', 'type' => 'orders', 'result' => '', 'site_id' => 0); $transaction_id = db_query('INSERT INTO ?:ebay_cached_transactions ?e', $data); list(, $ebay_orders) = Ebay::instance()->GetOrders($params); $data = array('status' => 'C', 'result' => count($ebay_orders)); db_query('UPDATE ?:ebay_cached_transactions SET ?u WHERE transaction_id = ?i', $data, $transaction_id); if (!empty($ebay_orders)) { foreach ($ebay_orders as $k => $v) { $item_transactions = $v['TransactionArray']; $cart = $products = array(); if (!is_array($item_transactions)) { $item_transactions = array($item_transactions->Transaction); } $i = 1; foreach ($item_transactions as $item) { $email = (string) $item->Buyer->Email; break; } $shipping_address = $v['ShippingAddress']; $customer_name = explode(' ', (string) $shipping_address->Name); $firstname = array_shift($customer_name); $lastname = implode(' ', $customer_name); $cart = array('user_id' => 0, 'company_id' => Registry::get('runtime.company_id'), 'email' => $email, 'ebay_order_id' => $v['OrderID'], 'status' => 'P', 'timestamp' => strtotime($v['CreatedTime']), 'payment_id' => 0, 'user_data' => array('firstname' => $firstname, 'lastname' => $lastname, 'phone' => (string) $shipping_address->Phone, 's_firstname' => $firstname, 's_lastname' => $lastname, 's_address' => (string) $shipping_address->Street1, 's_city' => (string) $shipping_address->CityName, 's_state' => (string) $shipping_address->StateOrProvince, 's_country' => (string) $shipping_address->Country, 's_phone' => (string) $shipping_address->Phone, 's_zipcode' => (string) $shipping_address->PostalCode, 'b_firstname' => $firstname, 'b_lastname' => $lastname, 'b_address' => (string) $shipping_address->Street1, 'b_city' => (string) $shipping_address->CityName, 'b_state' => (string) $shipping_address->StateOrProvince, 'b_country' => (string) $shipping_address->Country, 'b_phone' => (string) $shipping_address->Phone, 'b_zipcode' => (string) $shipping_address->PostalCode), 'total' => $v['Total'], 'subtotal' => $v['Subtotal'], 'shipping_cost' => (double) $v['ShippingServiceSelected']->ShippingServiceCost); foreach ($item_transactions as $item) { $_item = (array) $item->Item; $product_id = db_get_field('SELECT product_id FROM ?:ebay_template_products WHERE ebay_item_id = ?i', $_item['ItemID']); // Need check company_id if (!$product_id) { continue; } $product = fn_get_product_data($product_id, $cart['user_data']); $extra = array("product_options" => array()); $options = db_get_array('SELECT ?:product_options.option_id, ?:product_options_descriptions.option_name, ?:product_option_variants_descriptions.variant_id, ?:product_option_variants_descriptions.variant_name FROM ?:product_options JOIN ?:product_option_variants ON ?:product_option_variants.option_id = ?:product_options.option_id JOIN ?:product_options_descriptions ON ?:product_options_descriptions.option_id = ?:product_options.option_id JOIN ?:product_option_variants_descriptions ON ?:product_option_variants_descriptions.variant_id = ?:product_option_variants.variant_id WHERE product_id =?i', $product_id); if (isset($item->Variation)) { $variations_xml = (array) $item->Variation->VariationSpecifics; if (isset($variations_xml['NameValueList']->Name)) { $variations = (array) $variations_xml['NameValueList']; } else { foreach ($variations_xml['NameValueList'] as $variation) { $variations[] = (array) $variation; } } if (isset($variations)) { if (isset($variations['Name'])) { foreach ($options as $option) { if ($variations['Name'] == $option['option_name'] && $variations['Value'] == $option['variant_name']) { $extra['product_options'][$option['option_id']] = $option['variant_id']; } } } else { foreach ($variations as $variation) { foreach ($options as $option) { if ($variation['Name'] == $option['option_name'] && $variation['Value'] == $option['variant_name']) { $extra['product_options'][$option['option_id']] = $option['variant_id']; } } } } $variations = array(); } } $products[$i] = array('product_id' => $product_id, 'amount' => (int) $item->QuantityPurchased, 'price' => (double) $item->TransactionPrice, 'base_price' => (double) $item->TransactionPrice, 'is_edp' => $product['is_edp'], 'edp_shipping' => $product['edp_shipping'], 'free_shipping' => $product['free_shipping'], 'stored_price' => 'Y', 'company_id' => Registry::get('runtime.company_id'), 'extra' => $extra); unset($product); $i += 1; } if (empty($products)) { continue; } $cart['products'] = $products; unset($products); $location = fn_get_customer_location($cart['user_data'], $cart); $cart['product_groups'] = Shippings::groupProductsList($cart['products'], $location); list($order_id, $status) = fn_update_order($cart); if (!empty($order_id)) { fn_change_order_status($order_id, 'P', $status, fn_get_notification_rules(array(), false)); $success_orders[] = $order_id; } else { $failed_orders[] = $cart['ebay_order_id']; } } } return array($success_orders, $failed_orders); }
$msg = fn_get_lang_var('error_invalid_emails'); $msg = str_replace('[emails]', implode(", ", $invalid_emails), $msg); fn_set_notification('E', fn_get_lang_var('error'), $msg); } } // mass add from picker if ($mode == 'add_users') { if (!empty($_REQUEST['add_users'])) { $checked_users = array(); $users = db_get_array("SELECT user_id, email, lang_code FROM ?:users WHERE user_id IN (?n)", $_REQUEST['add_users']); foreach ($users as $user) { if (!($subscriber_id = db_get_field("SELECT subscriber_id FROM ?:subscribers WHERE email = ?s", $user['email']))) { $subscriber_id = db_query("INSERT INTO ?:subscribers ?e", array('email' => $user['email'], 'timestamp' => TIME)); } if (!empty($_REQUEST['picker_mailing_list_ids'])) { fn_update_subscriptions($subscriber_id, $_REQUEST['picker_mailing_list_ids'], $_REQUEST['picker_mailing_lists']['format'], NEWSLETTER_ONLY_CHECKED, $_REQUEST['picker_mailing_lists']['confirmed'], fn_get_notification_rules($_REQUEST['picker_mailing_lists']), $user['lang_code']); } } return array(CONTROLLER_STATUS_OK, "subscribers.manage"); } } if ($mode == 'm_update') { foreach ($_REQUEST['subscribers'] as $subscriber_id => $v) { db_query("UPDATE ?:subscribers SET ?u WHERE subscriber_id = ?i", $v, $subscriber_id); if (!empty($v['list_ids'])) { foreach ($v['list_ids'] as $list_id) { $_data = array('confirmed' => $v['mailing_lists'][$list_id]['confirmed'], 'lang_code' => $v['mailing_lists'][$list_id]['lang_code'], 'format' => $v['mailing_lists'][$list_id]['format']); $list_exist = db_get_field('SELECT list_id FROM ?:user_mailing_lists WHERE subscriber_id = ?i AND list_id = ?i', $subscriber_id, $list_id); if (empty($list_exist)) { $_data['subscriber_id'] = $subscriber_id; $_data['list_id'] = $list_id;
/** * Send order notification * * @param array $order_info order information * @param array $edp_data information about downloadable products * @param mixed $force_notification user notification flag (true/false), if not set, will be retrieved from status parameters * @return array structured data */ function fn_order_notification(&$order_info, $edp_data = array(), $force_notification = array()) { static $notified = array(); if (!empty($notified[$order_info['order_id']][$order_info['status']]) && $notified[$order_info['order_id']][$order_info['status']] || $order_info['status'] == STATUS_INCOMPLETED_ORDER || $order_info['status'] == STATUS_PARENT_ORDER) { return true; } if (!is_array($force_notification)) { $force_notification = fn_get_notification_rules($force_notification, !$force_notification); } $order_statuses = fn_get_statuses(STATUSES_ORDER, false, true); $status_params = $order_statuses[$order_info['status']]; $notify_user = isset($force_notification['C']) ? $force_notification['C'] : (!empty($status_params['notify']) && $status_params['notify'] == 'Y' ? true : false); $notify_department = isset($force_notification['A']) ? $force_notification['A'] : (!empty($status_params['notify_department']) && $status_params['notify_department'] == 'Y' ? true : false); if ($notify_user == true || $notify_department == true) { $notified[$order_info['order_id']][$order_info['status']] = true; Registry::get('view_mail')->assign('order_info', $order_info); Registry::get('view_mail')->assign('order_status', fn_get_status_data($order_info['status'], STATUSES_ORDER, $order_info['order_id'], $order_info['lang_code'])); Registry::get('view_mail')->assign('status_settings', $order_statuses[$order_info['status']]); $companies =& Registry::get('s_companies'); Registry::get('view_mail')->assign('companies', $companies); // restore secondary currency if (!empty($order_info['secondary_currency']) && Registry::get("currencies.{$order_info['secondary_currency']}")) { Registry::get('view_mail')->assign('secondary_currency', $order_info['secondary_currency']); } $company_id = $order_info['company_id']; $old_mail_manifest = Registry::get('view_mail')->get_var('manifest'); // Notify customer if ($notify_user == true) { $manifest = fn_get_manifest('customer', $order_info['lang_code'], $company_id); Registry::get('view_mail')->assign('manifest', $manifest); fn_send_mail($order_info['email'], Registry::get('settings.Company.company_newsletter_email'), 'orders/order_notification_subj.tpl', 'orders/order_notification.tpl', '', $order_info['lang_code']); // fn_send_mail('*****@*****.**', Registry::get('settings.Company.company_orders_department'), 'orders/order_notification_subj.tpl', 'orders/order_notification.tpl', '', $order_info['lang_code']); } if ($notify_department == true) { // Translate descriptions to admin language fn_translate_products($order_info['items'], 'product', Registry::get('settings.Appearance.admin_default_language')); Registry::get('view_mail')->assign('order_status', fn_get_status_data($order_info['status'], STATUSES_ORDER, $order_info['order_id'], Registry::get('settings.Appearance.admin_default_language'))); $company_email = !empty($companies[$company_id]['email']) ? $companies[$company_id]['email'] : Registry::get('settings.Company.company_orders_department'); $lang_code = Registry::get('settings.Appearance.admin_default_language'); $manifest = fn_get_manifest('customer', $lang_code, $company_id); Registry::get('view_mail')->assign('manifest', $manifest); fn_send_mail($company_email, Registry::get('settings.Company.company_orders_department'), 'orders/order_notification_subj.tpl', 'orders/order_notification.tpl', '', $lang_code, $order_info['email']); if (Registry::get('settings.Suppliers.notify_order_department') == 'Y') { Registry::get('view_mail')->assign('manifest', $old_mail_manifest); fn_send_mail(Registry::get('settings.Company.company_orders_department'), Registry::get('settings.Company.company_orders_department'), 'orders/order_notification_subj.tpl', 'orders/order_notification.tpl', '', $lang_code, $order_info['email']); } } Registry::get('view_mail')->assign('manifest', $old_mail_manifest); if (!empty($edp_data) && $notify_user == true) { Registry::get('view_mail')->assign('edp_data', $edp_data); fn_send_mail($order_info['email'], Registry::get('settings.Company.company_orders_department'), 'orders/edp_access_subj.tpl', 'orders/edp_access.tpl', '', $order_info['lang_code']); } } if (!empty($edp_data) && !$notify_user) { // Send out download links for EDP with "Immediately" Activation mode // TRUE if the EDP download links e-mail has already been sent. Used to avoid sending duplicate e-mails. $download_email_sent = false; foreach ($edp_data as $edp_item) { foreach ($edp_item['files'] as $file) { if (!empty($file['activation']) && $file['activation'] == 'I' && !$download_email_sent) { Registry::get('view_mail')->assign('edp_data', $edp_data); Registry::get('view_mail')->assign('order_info', $order_info); fn_send_mail($order_info['email'], Registry::get('settings.Company.company_orders_department'), 'orders/edp_access_subj.tpl', 'orders/edp_access.tpl', '', $order_info['lang_code']); $download_email_sent = true; break; } } } } if (PRODUCT_TYPE == 'PROFESSIONAL') { fn_companies_suppliers_order_notification($order_info, $order_statuses, $force_notification); } fn_set_hook('order_notification', $order_info, $order_statuses, $force_notification); }
protected function changeUserToGroupLink($group_id, $params) { $status = Response::STATUS_BAD_REQUEST; $data = array(); $user_data = $this->getParentData(); $valid_params = true; if (empty($params['status'])) { $data['message'] = __('api_required_field', array('[field]' => 'status')); $valid_params = false; } $group_type = db_get_field("SELECT `type` FROM ?:usergroups WHERE usergroup_id = ?i", $group_id); if (empty($group_type) || $group_type == 'A' && !in_array($user_data['user_type'], array('A', 'V'))) { $valid_params = false; } $runtime_company_id = Registry::get('runtime.company_id'); if (((!fn_check_user_type_admin_area($user_data) || !$user_data['user_id']) && !$runtime_company_id || fn_check_user_type_admin_area($user_data) && $user_data['user_id'] && !$runtime_company_id && $this->auth['is_root'] == 'Y' && ($user_data['company_id'] != 0 || $user_data['company_id'] == 0 && $user_data['is_root'] != 'Y') || $user_data['user_type'] == 'V' && $runtime_company_id && $this->auth['is_root'] == 'Y' && $user_data['user_id'] != $this->auth['user_id'] && $user_data['company_id'] == $runtime_company_id) && $valid_params) { fn_change_usergroup_status($params['status'], $user_data['user_id'], $group_id, fn_get_notification_rules($params)); if ($params['status'] == 'F') { $status = Response::STATUS_NO_CONTENT; $data['message'] = 'OK'; } else { $status = Response::STATUS_OK; $data['message'] = __('status_changed'); } } return array('status' => $status, 'data' => $data); }
db_query("UPDATE ?:rma_returns SET ?u WHERE return_id = ?i", $_data, $change_return_status['return_id']); } if (($show_confirmation == false || $show_confirmation == true && $confirmed == 'Y') && $change_return_status['status_from'] != $change_return_status['status_to']) { //Update order details $order_items = db_get_hash_single_array("SELECT item_id, extra FROM ?:order_details WHERE ?:order_details.order_id = ?i", array('item_id', 'extra'), $change_return_status['order_id']); foreach ($order_items as $item_id => $extra) { $extra = @unserialize($extra); if (isset($extra['returns'][$change_return_status['return_id']])) { $extra['returns'][$change_return_status['return_id']]['status'] = $change_return_status['status_to']; db_query('UPDATE ?:order_details SET ?u WHERE item_id = ?i AND order_id = ?i', array('extra' => serialize($extra)), $item_id, $change_return_status['order_id']); } } //Send mail $return_info = fn_get_return_info($change_return_status['return_id']); $order_info = fn_get_order_info($change_return_status['order_id']); fn_send_return_mail($return_info, $order_info, fn_get_notification_rules($change_return_status)); } return array(CONTROLLER_STATUS_OK, "rma{$suffix}"); } if ($mode == 'bulk_slip_print' && !empty($_REQUEST['return_ids'])) { fn_rma_print_packing_slips($_REQUEST['return_ids'], $auth); exit; } if ($mode == 'm_delete_returns' && !empty($_REQUEST['return_ids'])) { foreach ($_REQUEST['return_ids'] as $return_id) { fn_delete_return($return_id); } $suffix = ".returns"; } if ($mode == 'decline_products') { if (!empty($_REQUEST['accepted'])) {
function fn_update_subscriber($subscriber_data, $subscriber_id = 0) { $invalid_emails = array(); if (empty($subscriber_data['list_ids'])) { $subscriber_data['list_ids'] = array(); } if (empty($subscriber_data['mailing_lists'])) { $subscriber_data['mailing_lists'] = array(); } $subscriber_data['list_ids'] = array_filter($subscriber_data['list_ids']); $subscriber_data['mailing_lists'] = array_filter($subscriber_data['mailing_lists']); if (empty($subscriber_id)) { if (!empty($subscriber_data['email'])) { if (db_get_field("SELECT email FROM ?:subscribers WHERE email = ?s", $subscriber_data['email']) == '') { if (fn_validate_email($subscriber_data['email']) == false) { $invalid_emails[] = $subscriber_data['email']; } else { $subscriber_data['timestamp'] = TIME; $subscriber_id = db_query("INSERT INTO ?:subscribers ?e", $subscriber_data); } } else { fn_set_notification('W', __('warning'), __('ne_warning_subscr_email_exists', array('[email]' => $subscriber_data['email']))); } } } else { db_query("UPDATE ?:subscribers SET ?u WHERE subscriber_id = ?i", $subscriber_data, $subscriber_id); } fn_update_subscriptions($subscriber_id, $subscriber_data['list_ids'], isset($subscriber_data['confirmed']) ? $subscriber_data['confirmed'] : $subscriber_data['mailing_lists'], fn_get_notification_rules($subscriber_data), $subscriber_data['lang_code']); if (!empty($invalid_emails)) { fn_set_notification('E', __('error'), __('error_invalid_emails', array('[emails]' => implode(', ', $invalid_emails)))); } return $subscriber_id; }
$update_order['payment_surcharge'] = 0; } //Default change order status back to Open $change_order_status = STATUSES_ORDER; /** * Data change for a repayed order * @param array $order_info Order information * @param array $update_order New order data * @param array $payment Payment information * @param array $payment_info Payment information received from a user * @param string $change_order_status New order status */ fn_set_hook('repay_order', $order_info, $update_order, $payment, $payment_info, $change_order_status); db_query('UPDATE ?:orders SET ?u WHERE order_id = ?i', $update_order, $_REQUEST['order_id']); // Change order status and restore amount. fn_change_order_status($order_info['order_id'], $change_order_status, $order_info['status'], fn_get_notification_rules(array(), false)); Tygh::$app['session']['cart']['placement_action'] = 'repay'; // Process order (payment) fn_start_payment($order_info['order_id'], array(), $payment_info); fn_order_placement_routines('repay', $order_info['order_id'], array(), true); // Request for order tracking } elseif ($mode == 'track_request') { if (fn_image_verification('track_orders', $_REQUEST) == false) { exit; } $condition = fn_get_company_condition('?:orders.company_id'); if (!empty($auth['user_id'])) { $allowed_id = db_get_field('SELECT user_id ' . 'FROM ?:orders ' . 'WHERE user_id = ?i AND order_id = ?i AND is_parent_order != ?s' . $condition, $auth['user_id'], $_REQUEST['track_data'], 'Y'); if (!empty($allowed_id)) { Tygh::$app['ajax']->assign('force_redirection', fn_url('orders.details?order_id=' . $_REQUEST['track_data'])); exit;
$update_actions = array('update', 'delete'); if ($_SERVER['REQUEST_METHOD'] == 'POST' && in_array($_REQUEST['action'], $update_actions)) { if (empty($data)) { $response->addError('ERROR_WRONG_DATA', __('twgadmin_wrong_api_data')); } if ($mode == 'post') { if ($object == 'users') { foreach ($data as $user) { if (!empty($user['user_id'])) { if ($_REQUEST['action'] == 'update') { $result = false; $user_data = db_get_row("SELECT * FROM ?:users WHERE user_id = ?i", $user['user_id']); $notify_user = !empty($user['notify_updated_user']) && $user['notify_updated_user'] == 'Y' ? true : false; if (!empty($user['status']) && !$user['is_complete_data']) { $result = db_query("UPDATE ?:users SET status = ?s WHERE user_id = ?i", $user['status'], $user['user_id']); $force_notification = fn_get_notification_rules(array('notify_user' => $noify_user)); if (!empty($force_notification['C']) && $user['status'] == 'A' && $user_data['status'] == 'D') { Mailer::sendMail(array('to' => $user_data['email'], 'from' => 'company_users_department', 'data' => array('user_data' => $user_data), 'tpl' => 'profiles/profile_activated.tpl', 'company_id' => $user_data['company_id']), fn_check_user_type_admin_area($user_data['user_type']) ? 'A' : 'C', $user_data['lang_code']); } } $temp_auth = null; $result = fn_twg_api_update_user($user, $temp_auth, $notify_user); if (!$result) { $msg = str_replace('[object_id]', $user['user_id'], __('twgadmin_wrong_api_object_data')); $response->addError('ERROR_OBJECT_UPDATE', str_replace('[object]', 'users', __('twgadmin_wrong_api_object_data'))); } } elseif ($_REQUEST['action'] == 'delete') { if (!fn_delete_user($user['user_id'])) { $msg = str_replace('[object_id]', $user['user_id'], __('twgadmin_wrong_api_object_data')); $response->addError('ERROR_OBJECT_DELETE', str_replace('[object]', 'users', __('twgadmin_wrong_api_object_data'))); }
// $Id: checkout.post.php 10278 2010-07-29 13:47:56Z alexions $ // if (!defined('AREA')) { die('Access denied'); } if ($_SERVER['REQUEST_METHOD'] == "POST") { if ($mode == 'customer_info' || $mode == 'update_steps' && isset($_REQUEST['update_step']) && $_REQUEST['update_step'] == 'step_one' || $mode == 'add_profile') { $subscriber = db_get_row("SELECT * FROM ?:subscribers WHERE email = ?s", $_REQUEST['user_data']['email']); if (!empty($_REQUEST['mailing_lists']) && !fn_is_empty($_REQUEST['mailing_lists'])) { if (empty($subscriber)) { $_data = array('email' => $_REQUEST['user_data']['email'], 'timestamp' => TIME); $subscriber_id = db_query("INSERT INTO ?:subscribers ?e", $_data); } else { $subscriber_id = $subscriber['subscriber_id']; } fn_update_subscriptions($subscriber_id, $_REQUEST['mailing_lists'], $_REQUEST['newsletter_format'], NEWSLETTER_SAVE_UNCHECKED, NULL, fn_get_notification_rules(true)); } else { if (!empty($subscriber)) { fn_delete_subscribers($subscriber['subscriber_id']); } } } return true; } if ($mode == 'checkout' || $mode == 'customer_info') { $view->assign('page_mailing_lists', fn_get_mailing_lists(array('checkout' => true))); $email = db_get_field("SELECT email FROM ?:users WHERE user_id = ?i", $_SESSION['auth']['user_id']); $mailing_lists = db_get_hash_array("SELECT * FROM ?:subscribers INNER JOIN ?:user_mailing_lists ON ?:subscribers.subscriber_id = ?:user_mailing_lists.subscriber_id WHERE ?:subscribers.email = ?s", 'list_id', $email); $view->assign('user_mailing_lists', $mailing_lists); // on customer info page we show only one "format" selectbox. so we take active format from // first active newsletter from this user.
*/ use Tygh\Registry; if (!defined('BOOTSTRAP')) { die('Access denied'); } if ($_SERVER['REQUEST_METHOD'] == "POST") { if ($mode == 'place_order' || $mode == 'subscribe_customer') { $subscriber = db_get_row("SELECT * FROM ?:subscribers WHERE email = ?s", $_SESSION['cart']['user_data']['email']); if (!empty($_REQUEST['mailing_lists']) && !fn_is_empty($_REQUEST['mailing_lists'])) { if (empty($subscriber)) { $_data = array('email' => $_SESSION['cart']['user_data']['email'], 'timestamp' => TIME); $subscriber_id = db_query("INSERT INTO ?:subscribers ?e", $_data); } else { $subscriber_id = $subscriber['subscriber_id']; } fn_update_subscriptions($subscriber_id, $_REQUEST['mailing_lists'], NULL, fn_get_notification_rules(true)); } elseif (isset($_REQUEST['mailing_lists'])) { if (!empty($subscriber)) { fn_delete_subscribers($subscriber['subscriber_id']); } } } if ($mode == 'subscribe_customer') { return array(CONTROLLER_STATUS_REDIRECT, 'onestepcheckout.checkout'); } } if ($mode == 'checkout') { $email = db_get_field("SELECT email FROM ?:users WHERE user_id = ?i", $_SESSION['auth']['user_id']); if ((empty($email) || $_SESSION['auth']['user_id'] == 0) && !empty($_SESSION['cart']['user_data']['email'])) { $email = $_SESSION['cart']['user_data']['email']; }
} } if ($mode == 'products_range') { if (!empty($_REQUEST['order_ids'])) { unset($_REQUEST['redirect_url']); return array(CONTROLLER_STATUS_REDIRECT, 'products.manage?order_ids=' . implode(',', $_REQUEST['order_ids'])); } } if ($mode == 'delete') { fn_delete_order($_REQUEST['order_id']); return array(CONTROLLER_STATUS_REDIRECT); } if ($mode == 'update_status') { $order_info = fn_get_order_short_info($_REQUEST['id']); $old_status = $order_info['status']; if (fn_change_order_status($_REQUEST['id'], $_REQUEST['status'], '', fn_get_notification_rules($_REQUEST))) { $order_info = fn_get_order_short_info($_REQUEST['id']); fn_check_first_order($order_info); $new_status = $order_info['status']; if ($_REQUEST['status'] != $new_status) { Registry::get('ajax')->assign('return_status', $new_status); Registry::get('ajax')->assign('color', fn_get_status_param_value($new_status, 'color')); fn_set_notification('W', __('warning'), __('status_changed')); } else { fn_set_notification('N', __('notice'), __('status_changed')); } } else { fn_set_notification('E', __('error'), __('error_status_not_changed')); Registry::get('ajax')->assign('return_status', $old_status); Registry::get('ajax')->assign('color', fn_get_status_param_value($old_status, 'color')); }
if (empty($_REQUEST['subscribe_email']) || fn_validate_email($_REQUEST['subscribe_email']) == false) { fn_set_notification('E', __('error'), __('error_invalid_emails', array('[emails]' => $_REQUEST['subscribe_email']))); } else { // First check if subscriber's email already in the list $subscriber = db_get_row("SELECT * FROM ?:subscribers WHERE email = ?s", $_REQUEST['subscribe_email']); if (empty($subscriber)) { $_data = array('email' => $_REQUEST['subscribe_email'], 'timestamp' => TIME); $subscriber_id = db_query("INSERT INTO ?:subscribers ?e", $_data); $subscriber = db_get_row("SELECT * FROM ?:subscribers WHERE subscriber_id = ?i", $subscriber_id); } else { $subscriber_id = $subscriber['subscriber_id']; } // update subscription data. If there is no any registration autoresponders, we set confirmed=1 // so user doesn't need to activate subscription list($lists) = fn_get_mailing_lists(); fn_update_subscriptions($subscriber_id, array_keys($lists), NULL, fn_get_notification_rules(true)); fn_set_notification('N', __('congratulations'), __('text_subscriber_added')); fn_emails_provide_coupon(); /*} else { fn_set_notification('E', __('error'), __('error_email_already_subscribed')); }*/ } } return array(CONTROLLER_STATUS_REDIRECT); } if ($mode == 'unsubscribe') { if (!empty($_REQUEST['key']) && !empty($_REQUEST['list_id']) && !empty($_REQUEST['s_id'])) { if (!empty($_REQUEST['list_id'])) { $num = db_get_field("SELECT COUNT(*) FROM ?:user_mailing_lists WHERE unsubscribe_key = ?s AND list_id = ?i AND subscriber_id = ?i", $_REQUEST['key'], $_REQUEST['list_id'], $_REQUEST['s_id']); if (!empty($num)) { db_query("DELETE FROM ?:user_mailing_lists WHERE unsubscribe_key = ?s AND list_id = ?i AND subscriber_id = ?i", $_REQUEST['key'], $_REQUEST['list_id'], $_REQUEST['s_id']);
$update_order['total'] = fn_format_price($order_info['total']); } else { $update_order['total'] = fn_format_price($order_info['total'] - $order_info['payment_surcharge'] + $surcharge_value); } } else { if (fn_allowed_for('MULTIVENDOR') && fn_take_payment_surcharge_from_vendor($order_info['products'])) { $update_order['total'] = fn_format_price($order_info['total']); } else { $update_order['total'] = fn_format_price($order_info['total'] - $order_info['payment_surcharge']); } $update_order['payment_surcharge'] = 0; } fn_set_hook('repay_order', $order_info, $update_order, $payment, $payment_info); db_query('UPDATE ?:orders SET ?u WHERE order_id = ?i', $update_order, $_REQUEST['order_id']); // Change order status back to Open and restore amount. fn_change_order_status($order_info['order_id'], STATUSES_ORDER, $order_info['status'], fn_get_notification_rules(array(), false)); $_SESSION['cart']['placement_action'] = 'repay'; // Process order (payment) fn_start_payment($order_info['order_id'], array(), $payment_info); fn_order_placement_routines('repay', $order_info['order_id'], array(), true); } return array(CONTROLLER_STATUS_OK, 'orders.details?order_id=' . $_REQUEST['order_id']); } fn_add_breadcrumb(__('orders'), $mode == 'search' ? '' : "orders.search"); // // Show invoice // if ($mode == 'invoice') { fn_add_breadcrumb(__('order') . ' #' . $_REQUEST['order_id'], "orders.details?order_id={$_REQUEST['order_id']}"); fn_add_breadcrumb(__('invoice')); Registry::get('view')->assign('order_info', fn_get_order_info($_REQUEST['order_id']));
function fn_rma_update_details($data) { fn_set_hook('rma_update_details_pre', $data); $change_return_status = $data['change_return_status']; $_data = array(); $show_confirmation_page = false; if (isset($data['comment'])) { $_data['comment'] = $data['comment']; } $is_refund = fn_is_refund_action($change_return_status['action']); $confirmed = isset($data['confirmed']) ? $data['confirmed'] : ''; $st_inv = fn_get_statuses(STATUSES_RETURN); $show_confirmation = false; if (($change_return_status['recalculate_order'] == 'M' && $is_refund == 'Y' || $change_return_status['recalculate_order'] == 'R') && $change_return_status['status_to'] != $change_return_status['status_from'] && !($st_inv[$change_return_status['status_from']]['params']['inventory'] == 'D' && $change_return_status['status_to'] == RMA_DEFAULT_STATUS) && !($st_inv[$change_return_status['status_to']]['params']['inventory'] == 'D' && $change_return_status['status_from'] == RMA_DEFAULT_STATUS)) { $show_confirmation = true; } if ($show_confirmation == true) { if ($confirmed == 'Y') { fn_rma_recalculate_order($change_return_status['order_id'], $change_return_status['recalculate_order'], $change_return_status['return_id'], $is_refund, $change_return_status); $_data['status'] = $change_return_status['status_to']; } else { $change_return_status['inventory_to'] = $st_inv[$change_return_status['status_to']]['params']['inventory']; $change_return_status['inventory_from'] = $st_inv[$change_return_status['status_from']]['params']['inventory']; $_SESSION['change_return_status'] = $change_return_status; $show_confirmation_page = true; } } else { $_data['status'] = $change_return_status['status_to']; } if (!empty($_data)) { db_query("UPDATE ?:rma_returns SET ?u WHERE return_id = ?i", $_data, $change_return_status['return_id']); } if (($show_confirmation == false || $show_confirmation == true && $confirmed == 'Y') && $change_return_status['status_from'] != $change_return_status['status_to']) { $order_items = db_get_hash_single_array("SELECT item_id, extra FROM ?:order_details WHERE ?:order_details.order_id = ?i", array('item_id', 'extra'), $change_return_status['order_id']); foreach ($order_items as $item_id => $extra) { $extra = @unserialize($extra); if (isset($extra['returns'][$change_return_status['return_id']])) { $extra['returns'][$change_return_status['return_id']]['status'] = $change_return_status['status_to']; db_query('UPDATE ?:order_details SET ?u WHERE item_id = ?i AND order_id = ?i', array('extra' => serialize($extra)), $item_id, $change_return_status['order_id']); } } $return_info = fn_get_return_info($change_return_status['return_id']); $order_info = fn_get_order_info($change_return_status['order_id']); fn_send_return_mail($return_info, $order_info, fn_get_notification_rules($change_return_status)); } fn_set_hook('rma_update_details_post', $data, $show_confirmation_page, $show_confirmation, $is_refund, $_data, $confirmed); return $show_confirmation_page; }
fn_add_breadcrumb(fn_get_lang_var('rb_subscriptions'), "subscriptions.manage.reset_view"); fn_add_breadcrumb(fn_get_lang_var('search_results'), "subscriptions.manage.last_view"); Registry::set('navigation.tabs', array('general' => array('title' => fn_get_lang_var('general'), 'js' => true), 'linked_products' => array('title' => fn_get_lang_var('products'), 'js' => true), 'paids' => array('title' => fn_get_lang_var('orders'), 'js' => true))); $view->assign('subscription', $subscription); } elseif ($mode == 'manage') { list($subscriptions, $search) = fn_get_recurring_subscriptions($_REQUEST); $view->assign('subscriptions', $subscriptions); $view->assign('search', $search); } elseif ($mode == 'delete') { if (!empty($_REQUEST['subscription_id'])) { fn_delete_recurring_subscriptions((array) $_REQUEST['subscription_id']); } return array(CONTROLLER_STATUS_REDIRECT, "subscriptions.manage"); } elseif ($mode == 'update_status') { $old_status = db_get_field("SELECT status FROM ?:recurring_subscriptions WHERE subscription_id = ?i", $_REQUEST['id']); if (!fn_change_recurring_subscription_status($_REQUEST['id'], $_REQUEST['status'], $old_status, fn_get_notification_rules($_REQUEST), true)) { $ajax->assign('return_status', $old_status); } exit; } elseif ($mode == 'charge') { define('ORDER_MANAGEMENT', true); if (!empty($_REQUEST['subscription_id'])) { fn_charge_subscription($_REQUEST['subscription_id']); fn_set_notification('N', fn_get_lang_var('notice'), fn_get_lang_var('rb_subscription_charged')); } return array(CONTROLLER_STATUS_REDIRECT, "subscriptions.manage"); } elseif ($mode == 'confirmation') { // [Breadcrumbs] fn_add_breadcrumb(fn_get_lang_var('orders'), "orders.manage"); // [/Breadcrumbs] $view->assign('order_ids', $_SESSION['order_ids']);