Пример #1
0
 if (fn_need_shipping_recalculation($cart) == false && (!empty($cart['product_groups']) && (Registry::get('settings.General.user_multiple_profiles') != "Y" || Registry::get('settings.General.user_multiple_profiles') == "Y" && (isset($user_data['profile_id']) && empty($user_data['profile_id']) || !empty($user_data['profile_id']) && $user_data['profile_id'] == $cart['profile_id'])) || empty($cart['product_groups']) && Registry::get('settings.General.user_multiple_profiles') == "Y" && isset($user_data['profile_id']) && empty($user_data['profile_id']))) {
     define('CACHED_SHIPPING_RATES', true);
 }
 if ($cart['edit_step'] == 'step_three' || $cart['edit_step'] == 'step_four' || $completed_steps['step_two']) {
     $cart['calculate_shipping'] = true;
 }
 if (!empty($_REQUEST['active_tab'])) {
     $active_tab = $_REQUEST['active_tab'];
     Tygh::$app['view']->assign('active_tab', $active_tab);
 }
 if (floatval($cart['total']) == 0 || !isset($cart['payment_id'])) {
     $cart['payment_id'] = 0;
 }
 $shipping_calculation_type = Registry::get('settings.General.estimate_shipping_cost') == 'Y' || $completed_steps['step_two'] ? 'A' : 'S';
 list($cart_products, $product_groups) = fn_calculate_cart_content($cart, $auth, $shipping_calculation_type, true, 'F');
 $payment_methods = fn_prepare_checkout_payment_methods($cart, $auth);
 if (!empty($payment_methods)) {
     $first_methods_group = reset($payment_methods);
     $first_method = reset($first_methods_group);
     $checkout_buttons = fn_get_checkout_payment_buttons($cart, $cart_products, $auth);
     if (!empty($checkout_buttons)) {
         Tygh::$app['view']->assign('checkout_buttons', $checkout_buttons, false);
     }
 } else {
     $first_method = false;
 }
 // Edit step postprocessing
 if ($recheck_edit_step) {
     if ($cart['edit_step'] == 'step_one' && $completed_steps['step_one']) {
         $cart['edit_step'] = 'step_two';
     }
Пример #2
0
function fn_prepare_repay_data($payment_id, $order_info, $auth)
{
    if (empty($payment_id)) {
        $payment_id = $order_info['payment_id'];
    }
    //Get payment methods
    $payment_methods = fn_get_payments(array('usergroup_ids' => $auth['usergroup_ids']));
    fn_set_hook('prepare_repay_data', $payment_id, $order_info, $auth, $payment_methods);
    if (!empty($payment_methods)) {
        // Get payment method info
        $payment_groups = fn_prepare_checkout_payment_methods($order_info, $auth);
        if (!empty($payment_id)) {
            $order_payment_id = $payment_id;
        } else {
            $first = reset($payment_methods);
            $order_payment_id = $first['payment_id'];
        }
        $payment_data = fn_get_payment_method_data($order_payment_id);
        $payment_data['surcharge_value'] = 0;
        if (floatval($payment_data['a_surcharge'])) {
            $payment_data['surcharge_value'] += $payment_data['a_surcharge'];
        }
        if (floatval($payment_data['p_surcharge'])) {
            if (fn_allowed_for('MULTIVENDOR') && fn_take_payment_surcharge_from_vendor($order_info['products'])) {
                $payment_data['surcharge_value'] += fn_format_price($order_info['total']);
            } else {
                $payment_data['surcharge_value'] += fn_format_price(($order_info['total'] - $order_info['payment_surcharge']) * $payment_data['p_surcharge'] / 100);
            }
        }
        Registry::get('view')->assign('payment_methods', $payment_groups);
        Registry::get('view')->assign('order_payment_id', $order_payment_id);
        Registry::get('view')->assign('payment_method', $payment_data);
    }
}
Пример #3
0
function fn_twg_get_payment_methods()
{
    $payment_groups = fn_prepare_checkout_payment_methods($_SESSION['cart'], $_SESSION['auth']);
    if (!$payment_groups) {
        $payment_groups = array();
    }
    $payment_methods = array();
    foreach ($payment_groups as $payment_group) {
        $payment_methods = array_merge_recursive($payment_methods, $payment_group);
    }
    // unset unsupported payments
    $unsupported_payment_methods = TwigmoSettings::get('unsupported_payment_methods');
    $unsupported_payment_methods = !empty($unsupported_payment_methods) ? $unsupported_payment_methods : array();
    foreach ($payment_methods as $key => $payment_method) {
        $is_payment_unsupported = (isset($payment_method['processor']) and in_array($payment_method['processor'], $unsupported_payment_methods)) or isset($payment_method['processor_script']) and in_array($payment_method['processor_script'], $unsupported_payment_methods);
        if ($is_payment_unsupported) {
            unset($payment_methods[$key]);
        }
    }
    return Api::getAsList('payments', $payment_methods);
}
Пример #4
0
     }
 }
 if (false != ($first_method = reset($payment_methods)) && empty($cart['payment_id']) && floatval($cart['total']) != 0) {
     $cart['payment_id'] = $first_method['payment_id'];
     $completed_steps['step_four'] = false;
 }
 if (floatval($cart['total']) == 0) {
     $cart['payment_id'] = 0;
 }
 if (!empty($cart['payment_id'])) {
     $payment_info = fn_get_payment_method_data($cart['payment_id']);
     $view->assign('payment_info', $payment_info);
     $view->assign('credit_cards', fn_get_static_data_section('C', true, 'credit_card'));
 }
 $view->assign('shipping_rates', $_SESSION['shipping_rates']);
 $view->assign('payment_methods', $payment_methods = fn_prepare_checkout_payment_methods($cart, $auth));
 $cart['payment_surcharge'] = 0;
 if (!empty($cart['payment_id']) && !empty($payment_methods[$cart['payment_id']])) {
     $cart['payment_surcharge'] = $payment_methods[$cart['payment_id']]['surcharge_value'];
 }
 $view->assign('titles', fn_get_static_data_section('T'));
 $view->assign('usergroups', fn_get_usergroups('C', CART_LANGUAGE));
 $view->assign('countries', fn_get_countries(CART_LANGUAGE, true));
 $view->assign('states', fn_get_all_states());
 $cart['ship_to_another'] = fn_check_shipping_billing($cart['user_data'], $profile_fields);
 $view->assign('profile_fields', $profile_fields);
 if (Registry::get('settings.General.user_multiple_profiles') == 'Y') {
     $user_profiles = fn_get_user_profiles($auth['user_id']);
     $view->assign('user_profiles', $user_profiles);
 }
 fn_checkout_summary($cart);