示例#1
0
function ls_get_fav_data()
{
    //wishlist products footer carousel
    $_SESSION['wishlist'] = isset($_SESSION['wishlist']) ? $_SESSION['wishlist'] : array();
    $wishlist =& $_SESSION['wishlist'];
    $_SESSION['continue_url'] = fn_ls_get_base_url();
    $auth =& $_SESSION['auth'];
    //view products
    $products_footer = !empty($wishlist['products']) ? $wishlist['products'] : array();
    $extra_products = array();
    $wishlist_is_empty = fn_cart_is_empty($wishlist);
    if (!empty($products_footer)) {
        foreach ($products_footer as $k => $v) {
            $_options = array();
            $extra = $v['extra'];
            if (!empty($v['product_options'])) {
                $_options = $v['product_options'];
            }
            $products_footer[$k] = fn_get_product_data($v['product_id'], $auth, CART_LANGUAGE, '', true, true, true, false, false, true, false, true);
            if (empty($products_footer[$k])) {
                unset($products_footer[$k], $wishlist['products'][$k]);
                continue;
            }
            $products_footer[$k]['extra'] = empty($products_footer[$k]['extra']) ? array() : $products_footer[$k]['extra'];
            $products_footer[$k]['extra'] = array_merge($products_footer[$k]['extra'], $extra);
            if (isset($products_footer[$k]['extra']['product_options']) || $_options) {
                $products_footer[$k]['selected_options'] = empty($products_footer[$k]['extra']['product_options']) ? $_options : $products_footer[$k]['extra']['product_options'];
            }
            if (!empty($products_footer[$k]['selected_options'])) {
                $options = fn_get_selected_product_options($v['product_id'], $v['product_options'], CART_LANGUAGE);
                foreach ($products_footer[$k]['selected_options'] as $option_id => $variant_id) {
                    foreach ($options as $option) {
                        if ($option['option_id'] == $option_id && !in_array($option['option_type'], array('I', 'T', 'F')) && empty($variant_id)) {
                            $products_footer[$k]['changed_option'] = $option_id;
                            break 2;
                        }
                    }
                }
            }
            $products_footer[$k]['display_subtotal'] = $products_footer[$k]['price'] * $v['amount'];
            $products_footer[$k]['display_amount'] = $v['amount'];
            $products_footer[$k]['cart_id'] = $k;
            if (!empty($products_footer[$k]['extra']['parent'])) {
                $extra_products[$k] = $products_footer[$k];
                unset($products_footer[$k]);
                continue;
            }
        }
    }
    fn_gather_additional_products_data($products_footer, array('get_icon' => true, 'get_detailed' => true, 'get_options' => true, 'get_discounts' => true));
    return $products_footer;
}
示例#2
0
        $company_id = Registry::get('runtime.company_id');
        if (!empty($gift_cert_code)) {
            if (true == fn_check_gift_certificate_code($gift_cert_code, true, $company_id)) {
                $_SESSION['promotion_notices']['gift_certificates'] = array('applied' => true, 'messages' => array());
                if (!isset($_SESSION['cart']['use_gift_certificates'][$gift_cert_code])) {
                    $_SESSION['cart']['use_gift_certificates'][$gift_cert_code] = 'Y';
                    $_SESSION['cart']['pending_certificates'][] = $gift_cert_code;
                    $_SESSION['promotion_notices']['gift_certificates']['messages'][] = 'text_gift_cert_applied';
                    if (isset($cart['pending_coupon'])) {
                        unset($cart['pending_coupon']);
                    }
                } else {
                    $_SESSION['promotion_notices']['gift_certificates']['messages'][] = 'certificate_already_used';
                }
            } else {
                $_SESSION['promotion_notices']['gift_certificates'] = array('applied' => false, 'messages' => array());
                $status = db_get_field("SELECT status FROM ?:gift_certificates WHERE gift_cert_code = ?s ?p", $gift_cert_code, fn_get_gift_certificate_company_condition('?:gift_certificates.company_id'));
                $_SESSION['promotion_notices']['gift_certificates']['messages'][] = 'no_such_coupon';
            }
        }
        return array(CONTROLLER_STATUS_REDIRECT, 'checkout.' . (!empty($_REQUEST['redirect_mode']) ? $_REQUEST['redirect_mode'] : 'cart'));
    }
    if ($mode == 'delete_use_certificate' && !empty($gift_cert_code)) {
        fn_delete_gift_certificate_in_use($gift_cert_code, $_SESSION['cart']);
        if (fn_cart_is_empty($_SESSION['cart']) && defined('AJAX_REQUEST')) {
            Tygh::$app['ajax']->assign('force_redirection', fn_url('checkout.cart'));
        }
        return array(CONTROLLER_STATUS_REDIRECT, 'checkout.' . (!empty($_REQUEST['redirect_mode']) ? $_REQUEST['redirect_mode'] : 'checkout') . '.show_payment_options');
    }
    return;
}
示例#3
0
    fn_add_breadcrumb(__('landing_header'));
} elseif ($mode == 'process_payment') {
    if (fn_allow_place_order($cart, $auth) == true) {
        $order_info = $cart;
        $order_info['products'] = $cart['products'];
        $order_info = fn_array_merge($order_info, $cart['user_data']);
        $order_info['order_id'] = $order_id = TIME . "_" . (!empty($auth['user_id']) ? $auth['user_id'] : 0);
        unset($order_info['user_data']);
        list($is_processor_script, $processor_data) = fn_check_processor_script($order_info['payment_id']);
        if ($is_processor_script) {
            set_time_limit(300);
            fn_define('IFRAME_MODE', true);
            include Registry::get('config.dir.payments') . $processor_data['processor_script'];
            fn_finish_payment($order_id, $pp_response, array());
            fn_order_placement_routines('route', $order_id);
        }
    }
}
if (fn_cart_is_empty($cart) && !isset($force_redirection) && !in_array($mode, array('clear', 'delete', 'cart', 'update', 'apply_coupon', 'shipping_estimation', 'update_shipping', 'complete'))) {
    fn_set_notification('W', __('cart_is_empty'), __('cannot_proccess_checkout', 'K', 'cannot_proccess_checkout'));
    return array(CONTROLLER_STATUS_REDIRECT, 'checkout.cart');
}
if (!empty($profile_fields)) {
    Tygh::$app['view']->assign('profile_fields', $profile_fields);
}
Tygh::$app['view']->assign('cart', $cart);
Tygh::$app['view']->assign('continue_url', empty($_SESSION['continue_url']) ? '' : $_SESSION['continue_url']);
Tygh::$app['view']->assign('mode', $mode);
Tygh::$app['view']->assign('payment_methods', $payment_methods);
// Remember mode for the check shipping rates
$_SESSION['checkout_mode'] = $mode;
示例#4
0
        $company_id = Registry::get('runtime.company_id');
        if (!empty($gift_cert_code)) {
            if (true == fn_check_gift_certificate_code($gift_cert_code, true, $company_id)) {
                Tygh::$app['session']['promotion_notices']['gift_certificates'] = array('applied' => true, 'messages' => array());
                if (!isset(Tygh::$app['session']['cart']['use_gift_certificates'][$gift_cert_code])) {
                    Tygh::$app['session']['cart']['use_gift_certificates'][$gift_cert_code] = 'Y';
                    Tygh::$app['session']['cart']['pending_certificates'][] = $gift_cert_code;
                    Tygh::$app['session']['promotion_notices']['gift_certificates']['messages'][] = 'text_gift_cert_applied';
                    if (isset($cart['pending_coupon'])) {
                        unset($cart['pending_coupon']);
                    }
                } else {
                    Tygh::$app['session']['promotion_notices']['gift_certificates']['messages'][] = 'certificate_already_used';
                }
            } else {
                Tygh::$app['session']['promotion_notices']['gift_certificates'] = array('applied' => false, 'messages' => array());
                $status = db_get_field("SELECT status FROM ?:gift_certificates WHERE gift_cert_code = ?s ?p", $gift_cert_code, fn_get_gift_certificate_company_condition('?:gift_certificates.company_id'));
                Tygh::$app['session']['promotion_notices']['gift_certificates']['messages'][] = 'no_such_coupon';
            }
        }
        return array(CONTROLLER_STATUS_REDIRECT, 'checkout.' . (!empty($_REQUEST['redirect_mode']) ? $_REQUEST['redirect_mode'] : 'cart'));
    }
    if ($mode == 'delete_use_certificate' && !empty($gift_cert_code)) {
        fn_delete_gift_certificate_in_use($gift_cert_code, Tygh::$app['session']['cart']);
        if (fn_cart_is_empty(Tygh::$app['session']['cart']) && defined('AJAX_REQUEST')) {
            Tygh::$app['ajax']->assign('force_redirection', fn_url('checkout.cart'));
        }
        return array(CONTROLLER_STATUS_REDIRECT, 'checkout.' . (!empty($_REQUEST['redirect_mode']) ? $_REQUEST['redirect_mode'] : 'checkout') . '.show_payment_options');
    }
    return;
}
示例#5
0
            }
            fn_save_cart_content($_SESSION['cart'], $auth['user_id'], $_REQUEST['type']);
        }
    }
    if ($mode == 'preview') {
        if (!empty($_REQUEST['gift_cert_data'])) {
            fn_correct_gift_certificate($_REQUEST['gift_cert_data']);
            fn_show_postal_card($_REQUEST['gift_cert_data']);
            exit;
        }
    }
    if ($mode == 'delete') {
        if (isset($_REQUEST['gift_cert_id'])) {
            $cart =& $_SESSION['cart'];
            fn_delete_cart_gift_certificate($cart, $_REQUEST['gift_cert_id']);
            if (fn_cart_is_empty($cart) == true) {
                fn_clear_cart($cart);
            }
            fn_save_cart_content($cart, $auth['user_id']);
            $cart['recalculate'] = true;
            fn_calculate_cart_content($cart, $auth, 'A', true, 'F', true);
            return array(CONTROLLER_STATUS_REDIRECT);
        }
    }
    return array(CONTROLLER_STATUS_OK, 'checkout.cart');
}
if ($mode == 'verify') {
    fn_add_breadcrumb(__('gift_certificate_verification'));
    $verify_id = db_get_field("SELECT gift_cert_id FROM ?:gift_certificates WHERE gift_cert_code = ?s ?p", $_REQUEST['verify_code'], fn_get_gift_certificate_company_condition('?:gift_certificates.company_id'));
    if (!empty($verify_id)) {
        Registry::set('navigation.tabs', array('detailed' => array('title' => __('detailed_info'), 'js' => true), 'log' => array('title' => __('history'), 'js' => true)));
示例#6
0
    $view->assign('test_ses', $test_ses);
    $result = $_SESSION['wishlist'];
    $wishlistest = count($result['products']);
    $view->assign('wishlistest', $wishlistest);
} else {
    $view->assign('wishlistest', 0);
}
//wishlist products footer carousel
$_SESSION['wishlist'] = isset($_SESSION['wishlist']) ? $_SESSION['wishlist'] : array();
$wishlist =& $_SESSION['wishlist'];
$_SESSION['continue_url'] = isset($_SESSION['continue_url']) ? $_SESSION['continue_url'] : '';
$auth =& $_SESSION['auth'];
//view products
$products_footer = !empty($wishlist['products']) ? $wishlist['products'] : array();
$extra_products = array();
$wishlist_is_empty = fn_cart_is_empty($wishlist);
if (!empty($products_footer)) {
    foreach ($products_footer as $k => $v) {
        $_options = array();
        $extra = $v['extra'];
        if (!empty($v['product_options'])) {
            $_options = $v['product_options'];
        }
        $products_footer[$k] = fn_get_product_data($v['product_id'], $auth, CART_LANGUAGE, '', true, true, true, false, false, true, false, true);
        if (empty($products_footer[$k])) {
            unset($products_footer[$k], $wishlist['products'][$k]);
            continue;
        }
        $products_footer[$k]['extra'] = empty($products_footer[$k]['extra']) ? array() : $products_footer[$k]['extra'];
        $products_footer[$k]['extra'] = array_merge($products_footer[$k]['extra'], $extra);
        if (isset($products_footer[$k]['extra']['product_options']) || $_options) {
示例#7
0
use Tygh\BlockManager\Layout;
use Tygh\BlockManager\SchemesManager;
if (!defined('BOOTSTRAP')) {
    die('Access denied');
}
/**
 * Act on behalf functionality
 */
if (!empty($_REQUEST['skey'])) {
    $session_data = fn_get_storage_data('session_' . $_REQUEST['skey'] . '_data');
    fn_set_storage_data('session_' . $_REQUEST['skey'] . '_data', '');
    if (!empty($session_data)) {
        Tygh::$app['session']->start();
        Tygh::$app['session']->fromArray(unserialize($session_data));
        Tygh::$app['session']->save(Tygh::$app['session']->getID(), Tygh::$app['session']->toArray());
        if (!fn_cart_is_empty(Tygh::$app['session']['cart'])) {
            fn_calculate_cart_content(Tygh::$app['session']['cart'], Tygh::$app['session']['auth'], 'S', true, 'F', true);
            fn_save_cart_content(Tygh::$app['session']['cart'], Tygh::$app['session']['auth']['user_id']);
        }
    }
    return array(CONTROLLER_STATUS_REDIRECT, fn_query_remove(REAL_URL, 'skey'));
}
// UK Cookies Law
if (Registry::get('settings.Security.uk_cookies_law') == 'Y') {
    if (!empty($_REQUEST['cookies_accepted']) && $_REQUEST['cookies_accepted'] == 'Y') {
        Tygh::$app['session']['cookies_accepted'] = true;
    }
    if (!defined('AJAX_REQUEST') && empty(Tygh::$app['session']['cookies_accepted'])) {
        $url = fn_link_attach(Registry::get('config.current_url'), 'cookies_accepted=Y');
        $url = str_replace('&', '&', $url);
        $text = __('uk_cookies_law', array('[url]' => $url));
示例#8
0
            break;
        }
    }
    // If order was placed successfully, associate the order with this customer
    if (!empty($order_id)) {
        $auth['order_ids'][] = $order_id;
        $pp_response['order_status'] = 'P';
        fn_finish_payment($order_id, $pp_response);
    } else {
        $pp_response['order_status'] = 'F';
        $pp_response['reason_text'] = __('text_amazon_failed_order');
        fn_finish_payment($order_id, $pp_response);
    }
    fn_order_placement_routines('route', $order_id, false);
    exit;
} elseif (!empty($_payment_id) && !fn_cart_is_empty($cart)) {
    $base_domain = 'https://' . ($processor_data['processor_params']['test'] != 'Y' ? 'payments.amazon.com' : 'payments-sandbox.amazon.com');
    $merchant_id = $processor_data['processor_params']['merchant_id'];
    $_currency = $processor_data['processor_params']['currency'];
    $amazon_products = $cart['products'];
    fn_set_hook('amazon_products', $amazon_products, $cart);
    // Get cart items
    $amazon_order = array();
    foreach ($amazon_products as $key => $product) {
        // Get product options
        $item_options = ' ';
        if (!empty($product['product_options'])) {
            $_options = fn_get_selected_product_options_info($cart['products'][$key]['product_options']);
            foreach ($_options as $opt) {
                $item_options .= $opt['option_name'] . ': ' . $opt['variant_name'] . '; ';
            }
示例#9
0
     Registry::set('runtime.controller', 'twigmo');
     $result = fn_twg_api_get_session_cart($_SESSION['cart'], $lang_code);
     $response->setData($result);
     if (!empty($ids)) {
         $ids = array_keys($ids);
     }
     $response->setMeta(!empty($ids) ? array_pop($ids) : 0, 'added_id');
 } elseif ($meta['action'] == 'delete_from_cart') {
     // delete from cart
     $data = fn_twg_get_api_data($response, $format);
     $cart =& $_SESSION['cart'];
     $auth =& $_SESSION['auth'];
     foreach ($data as $cart_id) {
         fn_delete_cart_product($cart, $cart_id . '');
     }
     if (fn_cart_is_empty($cart)) {
         fn_clear_cart($cart);
     }
     fn_save_cart_content($cart, $auth['user_id']);
     $cart['recalculate'] = true;
     Registry::set('runtime.controller', 'checkout', true);
     fn_calculate_cart_content($cart, $auth, 'S', true, 'F', true);
     Registry::set('runtime.controller', 'twigmo');
     $result = fn_twg_api_get_session_cart($cart, $lang_code);
     $response->setData($result);
 } elseif ($meta['action'] == 'update_cart_amount') {
     $cart =& $_SESSION['cart'];
     $auth =& $_SESSION['auth'];
     $cart_id = $_REQUEST['cart_id'] . '';
     if (empty($cart['products'][$cart_id])) {
         return;
示例#10
0
function fn_checkout_summary(&$cart)
{
    if (fn_cart_is_empty($cart) == true) {
        return false;
    }
    fn_set_hook('checkout_summary', $cart);
    //Get payment methods
    $payment_data = fn_get_payment_method_data($cart['payment_id']);
    Registry::get('view')->assign('payment_method', $payment_data);
    // Downlodable files agreements
    $agreements = array();
    if (!empty($cart['products'])) {
        foreach ($cart['products'] as $item) {
            if ($item['is_edp'] == 'Y') {
                if ($_agreement = fn_get_edp_agreements($item['product_id'], true)) {
                    $agreements[$item['product_id']] = $_agreement;
                }
            }
        }
    }
    if (!empty($agreements)) {
        Registry::get('view')->assign('cart_agreements', $agreements);
    }
}
示例#11
0
****************************************************************************/
//
// $Id: google_checkout.php 10329 2010-08-03 14:46:04Z klerik $
//
if (!defined('AREA')) {
    die('Access denied');
}
$index_script = Registry::get('customer_index');
if (defined('PAYMENT_NOTIFICATION')) {
    if (!empty($_SESSION['order_id'])) {
        fn_order_placement_routines($_SESSION['order_id']);
    } else {
        fn_set_notification('E', fn_get_lang_var('error'), fn_get_lang_var('order_was_not_placed'));
        fn_redirect(Registry::get('config.http_location') . "/{$index_script}?dispatch=checkout.cart");
    }
} elseif (!empty($_payment_id) && !fn_cart_is_empty($cart) && $processor_data['params']['policy_agreement'] == 'Y') {
    $return_url = Registry::get('config.current_location') . "/{$index_script}?dispatch=payment_notification.notify&payment=google_checkout&" . SESS_NAME . '=' . Session::get_id();
    $edit_cart_url = Registry::get('config.current_location') . "/{$index_script}?dispatch=checkout.cart";
    $calculation_url = ($processor_data["params"]["test"] == 'N' ? Registry::get('config.https_location') : Registry::get('config.current_location')) . "/payments/google_calculations.php";
    $_currency = $processor_data['params']['currency'];
    $base_domain = 'https://' . ($processor_data['params']['test'] == 'N' ? 'checkout.google.com' : 'sandbox.google.com/checkout');
    $base_url = $base_domain . '/cws/v2/Merchant/' . $processor_data['params']['merchant_id'];
    $checkout_url = $base_url . '/checkout';
    $request_url = $base_url . '/request';
    // Form XML array with cart items
    $_items = '';
    $taxes = '';
    $google_products = $cart_products;
    fn_set_hook('google_products', $google_products, $cart);
    if (!empty($google_products) && is_array($google_products)) {
        foreach ($google_products as $k => $v) {
示例#12
0
/**
 * Order placing function
 *
 * @param array $cart
 * @param array $auth
 * @param string $action
 * @return int order_id or bool FALSE
 */
function fn_place_order(&$cart, &$auth, $action = '', $parent_order_id = 0)
{
    $allow = true;
    fn_set_hook('pre_place_order', $cart, $allow);
    if ($allow == true && !fn_cart_is_empty($cart)) {
        $ip = fn_get_ip();
        $__order_status = STATUS_INCOMPLETED_ORDER;
        $order = fn_check_table_fields($cart, 'orders');
        $order = fn_array_merge($order, fn_check_table_fields($cart['user_data'], 'orders'));
        // filter hidden fields, which were hidden to checkout
        fn_filter_hidden_profile_fields($order, 'O');
        // If the contact information fields were disabled, fill the information from the billing/shipping
        Registry::get('settings.General.address_position') == 'billing_first' ? $address_zone = 'b' : ($address_zone = 's');
        if (!empty($order['firstname']) || !empty($order[$address_zone . '_firstname'])) {
            $order['firstname'] = empty($order['firstname']) && !empty($order[$address_zone . '_firstname']) ? $order[$address_zone . '_firstname'] : $order['firstname'];
        }
        if (!empty($order['lastname']) || !empty($order[$address_zone . '_lastname'])) {
            $order['lastname'] = empty($order['lastname']) && !empty($order[$address_zone . '_lastname']) ? $order[$address_zone . '_lastname'] : $order['lastname'];
        }
        if (!empty($order['phone']) || !empty($order[$address_zone . '_phone'])) {
            $order['phone'] = empty($order['phone']) && !empty($order[$address_zone . '_phone']) ? $order[$address_zone . '_phone'] : $order['phone'];
        }
        $order['user_id'] = $auth['user_id'];
        $order['timestamp'] = TIME;
        $order['lang_code'] = CART_LANGUAGE;
        $order['tax_exempt'] = $auth['tax_exempt'];
        $order['status'] = STATUS_INCOMPLETED_ORDER;
        // incomplete by default to increase inventory
        $order['ip_address'] = $ip['host'];
        $cart['companies'] = fn_get_products_companies($cart['products']);
        $order['is_parent_order'] = 'N';
        if (PRODUCT_TYPE == 'MULTIVENDOR') {
            $order['parent_order_id'] = $parent_order_id;
            if (count($cart['companies']) > 1) {
                $order['is_parent_order'] = 'Y';
                $__order_status = $order['status'] = STATUS_PARENT_ORDER;
            } else {
                $order['company_id'] = key($cart['companies']);
            }
        }
        $order['promotions'] = serialize(!empty($cart['promotions']) ? $cart['promotions'] : array());
        if (!empty($cart['promotions'])) {
            $order['promotion_ids'] = implode(', ', array_keys($cart['promotions']));
        }
        $order['shipping_ids'] = !empty($cart['shipping']) ? fn_create_set(array_keys($cart['shipping'])) : '';
        if (!empty($cart['payment_surcharge'])) {
            $cart['total'] += $cart['payment_surcharge'];
            $order['total'] = $cart['total'];
        }
        if (!empty($cart['payment_info'])) {
            $ccards = fn_get_static_data_section('C', true);
            if (!empty($cart['payment_info']['card']) && !empty($ccards[$cart['payment_info']['card']])) {
                // Check if cvv2 number required and unset it if not
                if ($ccards[$cart['payment_info']['card']]['param_2'] != 'Y') {
                    unset($cart['payment_info']['cvv2']);
                }
                // Check if start date exists and required and convert it to string
                if ($ccards[$cart['payment_info']['card']]['param_3'] != 'Y') {
                    unset($cart['payment_info']['start_year'], $cart['payment_info']['start_month']);
                }
                // Check if issue number required
                if ($ccards[$cart['payment_info']['card']]['param_4'] != 'Y') {
                    unset($cart['payment_info']['issue_number']);
                }
            }
        }
        // We're editing existing order
        if (!empty($order['order_id']) && $order['is_parent_order'] != 'Y') {
            $_tmp = db_get_row("SELECT status, ip_address, details, timestamp, lang_code FROM ?:orders WHERE order_id = ?i", $order['order_id']);
            $order['ip_address'] = $_tmp['ip_address'];
            // Leave original customers IP address
            $order['details'] = $_tmp['details'];
            // Leave order details
            $order['timestamp'] = $_tmp['timestamp'];
            // Leave the original date
            $order['lang_code'] = $_tmp['lang_code'];
            // Leave the original language
            if ($action == 'save') {
                $__order_status = $_tmp['status'];
                // Get the original order status
            }
            fn_change_order_status($order['order_id'], STATUS_INCOMPLETED_ORDER, $_tmp['status'], fn_get_notification_rules(array(), false));
            // incomplete the order to increase inventory amount.
            db_query("DELETE FROM ?:orders WHERE order_id = ?i", $order['order_id']);
            db_query("DELETE FROM ?:order_details WHERE order_id = ?i", $order['order_id']);
            db_query("DELETE FROM ?:profile_fields_data WHERE object_id = ?i AND object_type = 'O'", $order['order_id']);
            db_query("DELETE FROM ?:order_data WHERE order_id = ?i AND type IN ('T', 'C', 'P')", $order['order_id']);
            fn_set_hook('edit_place_order', $order['order_id']);
        }
        if (!empty($cart['rewrite_order_id'])) {
            $order['order_id'] = array_shift($cart['rewrite_order_id']);
        }
        $order['referer'] = $_SESSION['referer'];
        $order_id = db_query("INSERT INTO ?:orders ?e", $order);
        // Log order creation
        fn_log_event('orders', 'create', array('order_id' => $order_id));
        fn_store_profile_fields($cart['user_data'], $order_id, 'O');
        $order['order_id'] = $order_id;
        // If customer is not logged in, store order ids in the session
        if (empty($auth['user_id'])) {
            $auth['order_ids'][] = $order_id;
        }
        // Add order details data
        if (!empty($order_id)) {
            if (!empty($cart['products'])) {
                foreach ((array) $cart['products'] as $k => $v) {
                    $product_code = '';
                    $extra = empty($v['extra']) ? array() : $v['extra'];
                    $v['discount'] = empty($v['discount']) ? 0 : $v['discount'];
                    $extra['product'] = empty($v['product']) ? fn_get_product_name($v['product_id']) : $v['product'];
                    $extra['company_id'] = $v['company_id'];
                    if (isset($v['is_edp'])) {
                        $extra['is_edp'] = $v['is_edp'];
                    }
                    if (isset($v['edp_shipping'])) {
                        $extra['edp_shipping'] = $v['edp_shipping'];
                    }
                    if (!empty($v['discount'])) {
                        $extra['discount'] = $v['discount'];
                    }
                    if (isset($v['base_price'])) {
                        $extra['base_price'] = floatval($v['base_price']);
                    }
                    if (!empty($v['promotions'])) {
                        $extra['promotions'] = $v['promotions'];
                    }
                    if (!empty($v['stored_price']) && $v['stored_price'] == 'Y') {
                        $extra['stored_price'] = 'Y';
                    }
                    if (!empty($v['product_options'])) {
                        $_options = fn_get_product_options($v['product_id']);
                        if (!empty($_options)) {
                            foreach ($_options as $option_id => $option) {
                                if (!isset($v['product_options'][$option_id])) {
                                    $v['product_options'][$option_id] = '';
                                }
                            }
                        }
                        $extra['product_options'] = $v['product_options'];
                        $cart_id = fn_generate_cart_id($v['product_id'], array('product_options' => $v['product_options']), true);
                        $tracking = db_get_field("SELECT tracking FROM ?:products WHERE product_id = ?i", $v['product_id']);
                        if ($tracking == 'O') {
                            $product_code = db_get_field("SELECT product_code FROM ?:product_options_inventory WHERE combination_hash = ?i", $cart_id);
                        }
                        $extra['product_options_value'] = fn_get_selected_product_options_info($v['product_options']);
                    } else {
                        $v['product_options'] = array();
                    }
                    if (empty($product_code)) {
                        $product_code = db_get_field("SELECT product_code FROM ?:products WHERE product_id = ?i", $v['product_id']);
                    }
                    // Check the cart custom files
                    if (isset($extra['custom_files'])) {
                        $dir_path = DIR_CUSTOM_FILES . 'order_data/' . $order_id;
                        $sess_dir_path = DIR_CUSTOM_FILES . 'sess_data';
                        if (!is_dir($dir_path)) {
                            fn_mkdir($dir_path);
                        }
                        foreach ($extra['custom_files'] as $option_id => $files) {
                            if (is_array($files)) {
                                foreach ($files as $file_id => $file) {
                                    $file['path'] = $sess_dir_path . '/' . basename($file['path']);
                                    fn_copy($file['path'], $dir_path . '/' . $file['file']);
                                    fn_rm($file['path']);
                                    fn_rm($file['path'] . '_thumb');
                                    $extra['custom_files'][$option_id][$file_id]['path'] = $dir_path . '/' . $file['file'];
                                }
                            }
                        }
                    }
                    $order_details = array('item_id' => $k, 'order_id' => $order_id, 'product_id' => $v['product_id'], 'product_code' => $product_code, 'price' => !empty($v['stored_price']) && $v['stored_price'] == 'Y' ? $v['price'] - $v['discount'] : $v['price'], 'amount' => $v['amount'], 'extra' => serialize($extra));
                    db_query("INSERT INTO ?:order_details ?e", $order_details);
                    // Increase product popularity
                    $_data = array('product_id' => $v['product_id'], 'bought' => 1, 'total' => POPULARITY_BUY);
                    db_query("INSERT INTO ?:product_popularity ?e ON DUPLICATE KEY UPDATE bought = bought + 1, total = total + ?i", $_data, POPULARITY_BUY);
                }
            }
            // Save shipping information
            if (!empty($cart['shipping'])) {
                if ($_SESSION['selfService']) {
                    foreach ($cart['shipping'] as $sh_id => $_d) {
                        $cart['shipping'][$sh_id]['selfService'] = $_SESSION['selfService'];
                    }
                }
                // Get carriers and tracking number
                $data = db_get_field("SELECT data FROM ?:order_data WHERE order_id = ?i AND type = 'L'", $order_id);
                if (!empty($data)) {
                    $data = unserialize($data);
                    foreach ($cart['shipping'] as $sh_id => $_d) {
                        if (!empty($data[$sh_id]['carrier'])) {
                            $cart['shipping'][$sh_id]['carrier'] = $data[$sh_id]['carrier'];
                        }
                        if (!empty($data[$sh_id]['tracking_number'])) {
                            $cart['shipping'][$sh_id]['tracking_number'] = $data[$sh_id]['tracking_number'];
                        }
                    }
                }
                $_data = array('order_id' => $order_id, 'type' => 'L', 'data' => serialize($cart['shipping']));
                db_query("REPLACE INTO ?:order_data ?e", $_data);
            }
            // Save taxes
            if (!empty($cart['taxes'])) {
                $_data = array('order_id' => $order_id, 'type' => 'T', 'data' => serialize($cart['taxes']));
                db_query("REPLACE INTO ?:order_data ?e", $_data);
            }
            // Save payment information
            if (!empty($cart['payment_info'])) {
                $_data = array('order_id' => $order_id, 'type' => 'P', 'data' => fn_encrypt_text(serialize($cart['payment_info'])));
                db_query("REPLACE INTO ?:order_data ?e", $_data);
            }
            // Save coupons information
            if (!empty($cart['coupons'])) {
                $_data = array('order_id' => $order_id, 'type' => 'C', 'data' => serialize($cart['coupons']));
                db_query("REPLACE INTO ?:order_data ?e", $_data);
            }
            // Save secondary currency (for order notifications from payments with feedback requests)
            $_data = array('order_id' => $order_id, 'type' => 'R', 'data' => serialize(CART_SECONDARY_CURRENCY));
            db_query("REPLACE INTO ?:order_data ?e", $_data);
            //
            // Place the order_id to new_orders table for all admin profiles
            //
            $admins = db_get_fields("SELECT user_id FROM ?:users WHERE user_type = 'A'");
            foreach ($admins as $k => $v) {
                db_query("REPLACE INTO ?:new_orders (order_id, user_id) VALUES (?i, ?i)", $order_id, $v);
            }
            fn_set_hook('place_order', $order_id, $action, $__order_status, $cart);
            // If order total is zero, just save the order without any processing procedures
            if (floatval($cart['total']) == 0) {
                $action = 'save';
                $__order_status = 'P';
            }
            list($is_processor_script, ) = fn_check_processor_script($cart['payment_id'], $action, true);
            if (!$is_processor_script && $__order_status == STATUS_INCOMPLETED_ORDER) {
                $__order_status = 'O';
            }
            // Set new order status
            fn_change_order_status($order_id, $__order_status, '', $is_processor_script || $__order_status == STATUS_PARENT_ORDER ? fn_get_notification_rules(array(), true) : fn_get_notification_rules(array()), true);
            $cart['processed_order_id'] = array();
            $cart['processed_order_id'][] = $order_id;
            if (!$parent_order_id && count($cart['companies']) > 1 && PRODUCT_TYPE == 'MULTIVENDOR') {
                fn_companies_place_suborders($order_id, $cart, $auth, $action);
                $child_orders = db_get_fields("SELECT order_id FROM ?:orders WHERE parent_order_id = ?i", $order_id);
                array_unshift($child_orders, $order_id);
                $cart['processed_order_id'] = $child_orders;
            }
            return array($order_id, $action != 'save');
        }
    }
    return array(false, false);
}
    function content_55d31213b82193_32213162($_smarty_tpl)
    {
        if (!is_callable('smarty_function_script')) {
            include '/home/coriolan/public_html/lead/app/functions/smarty_plugins/function.script.php';
        }
        if (!is_callable('smarty_function_set_id')) {
            include '/home/coriolan/public_html/lead/app/functions/smarty_plugins/function.set_id.php';
        }
        fn_preload_lang_vars(array('text_cart_empty', 'text_cart_empty'));
        if ($_smarty_tpl->tpl_vars['runtime']->value['customization_mode']['design'] == "Y" && @constant('AREA') == "C") {
            $_smarty_tpl->_capture_stack[0][] = array("template_content", null, null);
            ob_start();
            echo smarty_function_script(array('src' => "js/tygh/exceptions.js"), $_smarty_tpl);
            ?>

<script type="text/javascript">
$(document).ready(function(){
    ls_checkout_estimation();
});
</script>
<?php 
            if (!fn_cart_is_empty($_smarty_tpl->tpl_vars['cart']->value)) {
                ?>
    <?php 
                echo $_smarty_tpl->getSubTemplate("views/checkout/components/cart_content.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0);
                ?>

<?php 
            } else {
                ?>
    <p class="ty-no-items"><?php 
                echo $_smarty_tpl->__("text_cart_empty");
                ?>
</p>

    <div class="buttons-container wrap">
        <?php 
                echo $_smarty_tpl->getSubTemplate("buttons/continue_shopping.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('but_href' => fn_url($_smarty_tpl->tpl_vars['continue_url']->value), 'but_role' => "submit"), 0);
                ?>

    </div>
<?php 
            }
            list($_capture_buffer, $_capture_assign, $_capture_append) = array_pop($_smarty_tpl->_capture_stack[0]);
            if (!empty($_capture_buffer)) {
                if (isset($_capture_assign)) {
                    $_smarty_tpl->assign($_capture_assign, ob_get_contents());
                }
                if (isset($_capture_append)) {
                    $_smarty_tpl->append($_capture_append, ob_get_contents());
                }
                Smarty::$_smarty_vars['capture'][$_capture_buffer] = ob_get_clean();
            } else {
                $_smarty_tpl->capture_error();
            }
            if (trim(Smarty::$_smarty_vars['capture']['template_content'])) {
                if ($_smarty_tpl->tpl_vars['auth']->value['area'] == "A") {
                    ?>
<span class="cm-template-box template-box" data-ca-te-template="views/checkout/cart.tpl" id="<?php 
                    echo smarty_function_set_id(array('name' => "views/checkout/cart.tpl"), $_smarty_tpl);
                    ?>
"><div class="cm-template-icon icon-edit ty-icon-edit hidden"></div><?php 
                    echo Smarty::$_smarty_vars['capture']['template_content'];
                    ?>
<!--[/tpl_id]--></span><?php 
                } else {
                    echo Smarty::$_smarty_vars['capture']['template_content'];
                }
            }
        } else {
            echo smarty_function_script(array('src' => "js/tygh/exceptions.js"), $_smarty_tpl);
            ?>

<script type="text/javascript">
$(document).ready(function(){
    ls_checkout_estimation();
});
</script>
<?php 
            if (!fn_cart_is_empty($_smarty_tpl->tpl_vars['cart']->value)) {
                ?>
    <?php 
                echo $_smarty_tpl->getSubTemplate("views/checkout/components/cart_content.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0);
                ?>

<?php 
            } else {
                ?>
    <p class="ty-no-items"><?php 
                echo $_smarty_tpl->__("text_cart_empty");
                ?>
</p>

    <div class="buttons-container wrap">
        <?php 
                echo $_smarty_tpl->getSubTemplate("buttons/continue_shopping.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('but_href' => fn_url($_smarty_tpl->tpl_vars['continue_url']->value), 'but_role' => "submit"), 0);
                ?>

    </div>
<?php 
            }
        }
    }
示例#14
0
文件: init.php 项目: askzap/ultimate
use Tygh\Development;
use Tygh\Registry;
use Tygh\Session;
use Tygh\BlockManager\Location;
use Tygh\BlockManager\Layout;
use Tygh\BlockManager\SchemesManager;
if (!defined('BOOTSTRAP')) {
    die('Access denied');
}
if (!empty($_REQUEST['skey'])) {
    $session_data = fn_get_storage_data('session_' . $_REQUEST['skey'] . '_data');
    fn_set_storage_data('session_' . $_REQUEST['skey'] . '_data', '');
    if (!empty($session_data)) {
        $_SESSION = unserialize($session_data);
        Session::save(Session::getId(), $_SESSION);
        if (!fn_cart_is_empty($_SESSION['cart'])) {
            fn_calculate_cart_content($_SESSION['cart'], $_SESSION['auth'], 'S', true, 'F', true);
            fn_save_cart_content($_SESSION['cart'], $_SESSION['auth']['user_id']);
        }
    }
    return array(CONTROLLER_STATUS_REDIRECT, fn_query_remove(REAL_URL, 'skey'));
}
// UK Cookies Law
if (Registry::get('settings.Security.uk_cookies_law') == 'Y') {
    if (!empty($_REQUEST['cookies_accepted']) && $_REQUEST['cookies_accepted'] == 'Y') {
        $_SESSION['cookies_accepted'] = true;
    }
    if (!defined('AJAX_REQUEST') && empty($_SESSION['cookies_accepted'])) {
        $url = fn_link_attach(Registry::get('config.current_url'), 'cookies_accepted=Y');
        $url = str_replace('&', '&amp;', $url);
        $text = __('uk_cookies_law', array('[url]' => $url));
示例#15
0
            Registry::get('view')->assign('order_action', __('placing_order'));
            Registry::get('view')->display('views/orders/components/placing_order.tpl');
            fn_flush();
            if (empty($_REQUEST['skip_payment']) && $process_payment == true || !empty($_REQUEST['skip_payment']) && empty($auth['act_as_user'])) {
                $payment_info = !empty($cart['payment_info']) ? $cart['payment_info'] : array();
                fn_start_payment($order_id, array(), $payment_info);
            }
            fn_order_placement_routines('route', $order_id);
        } else {
            return array(CONTROLLER_STATUS_REDIRECT, "checkout.cart");
        }
    }
    return array(CONTROLLER_STATUS_OK, "onestepcheckout{$_suffix}");
}
$payment_methods = fn_prepare_checkout_payment_methods($cart, $auth);
if ((true == fn_cart_is_empty($cart) && !isset($force_redirection) || empty($payment_methods)) && !in_array($mode, array('clear', 'delete', 'cart', 'update', 'apply_coupon', 'shipping_estimation', 'update_shipping', 'complete'))) {
    if (empty($payment_methods)) {
        fn_set_notification('W', __('notice'), __('cannot_proccess_checkout_without_payment_methods'), 'K', 'no_payment_notification');
    } else {
        fn_set_notification('W', __('cart_is_empty'), __('cannot_proccess_checkout'));
    }
    $force_redirection = "checkout.cart";
    if (defined('AJAX_REQUEST')) {
        Registry::get('ajax')->assign('force_redirection', fn_url($force_redirection));
        exit;
    } else {
        return array(CONTROLLER_STATUS_REDIRECT, $force_redirection);
    }
}
if ($mode == 'checkout') {
    fn_add_breadcrumb(__('checkout'));