if (!empty($payment_info['processor_params']['iframe_mode']) && $payment_info['processor_params']['iframe_mode'] == 'Y') { Tygh::$app['view']->assign('iframe_mode', true); } } Tygh::$app['view']->assign('payment_methods', $payment_methods); $cart['payment_surcharge'] = 0; if (!empty($cart['payment_id']) && !empty($payment_info)) { fn_update_payment_surcharge($cart, $auth); } if (fn_allowed_for('MULTIVENDOR')) { Tygh::$app['view']->assign('take_surcharge_from_vendor', fn_take_payment_surcharge_from_vendor($cart['products'])); } Tygh::$app['view']->assign('usergroups', fn_get_usergroups(array('type' => 'C', 'status' => 'A'), CART_LANGUAGE)); Tygh::$app['view']->assign('countries', fn_get_simple_countries(true, CART_LANGUAGE)); Tygh::$app['view']->assign('states', fn_get_all_states()); $cart['ship_to_another'] = fn_check_shipping_billing($cart['user_data'], $profile_fields); Tygh::$app['view']->assign('profile_fields', $profile_fields); if (Registry::get('settings.General.user_multiple_profiles') == 'Y') { $user_profiles = fn_get_user_profiles($auth['user_id']); Tygh::$app['view']->assign('user_profiles', $user_profiles); } fn_checkout_summary($cart); Tygh::$app['view']->assign('use_ajax', 'true'); Tygh::$app['view']->assign('completed_steps', $completed_steps); Tygh::$app['view']->assign('location', 'checkout'); Tygh::$app['view']->assign('cart', $cart); Tygh::$app['view']->assign('cart_products', array_reverse($cart_products, true)); Tygh::$app['view']->assign('product_groups', $cart['product_groups']); if (!empty($cart['failed_order_id']) || !empty($cart['processed_order_id'])) { $_ids = !empty($cart['failed_order_id']) ? $cart['failed_order_id'] : $cart['processed_order_id']; $_order_id = reset($_ids);
/** * Get user info */ function fn_twg_get_user_info($user_id) { $profile = array(); if (!$user_id) { $profile['user_id'] = 0; } else { $profile = fn_get_user_info($user_id); if (empty($profile)) { return false; } } if (AREA == 'C' && !empty($_SESSION['cart']['user_data'])) { $profile = array_merge($profile, $_SESSION['cart']['user_data']); } // Clear empty profile fields if (!empty($profile['fields'])) { $profile['fields'] = array_filter($profile['fields']); } $profile['ship_to_another']['profile'] = fn_check_shipping_billing($profile, fn_get_profile_fields()); $checkout_pfields = fn_get_profile_fields('O'); $profile['ship_to_another']['cart'] = fn_check_shipping_billing($profile, $checkout_pfields) || !fn_compare_shipping_billing($checkout_pfields); if ($user_id) { $profile['b_email'] = !empty($profile['b_email']) ? $profile['b_email'] : $profile['email']; $profile['s_email'] = !empty($profile['s_email']) ? $profile['s_email'] : $profile['email']; } return $profile; }
// echo 'profile fields:'; var_dump($profile_fields); //check if the user has uploaded a image $target_dir = "/images/user_profile/"; //insert user id here $base_url = $_SERVER['DOCUMENT_ROOT']; $ls_image_name = $auth['user_id'] . '.jpg'; //replace with user id $target_file = $base_url . $target_dir . $ls_image_name; if (file_exists($target_file)) { $ls_user_image = 'file exists'; // $view->assign('ls_user_image', $ls_user_image); Registry::get('view')->assign('ls_user_profile_image', $ls_user_image); } Registry::get('view')->assign('profile_fields', $profile_fields); Registry::get('view')->assign('user_data', $user_data); Registry::get('view')->assign('ship_to_another', fn_check_shipping_billing($user_data, $profile_fields)); Registry::get('view')->assign('countries', fn_get_simple_countries(true, CART_LANGUAGE)); Registry::get('view')->assign('states', fn_get_all_states()); // profile info $orders = db_get_array("SELECT * FROM ?:orders WHERE user_id=?i ORDER BY timestamp DESC", $auth['user_id']); $orders_number = count($orders); $recent_order_status = $orders[0]['status']; if ($recent_order_status == "A") { $recent_order_status_text = "order_fraud_checking"; } elseif ($recent_order_status == "B") { $recent_order_status_text = "order_backordered"; } elseif ($recent_order_status == "C") { $recent_order_status_text = "order_completed"; } elseif ($recent_order_status == "D") { $recent_order_status_text = "order_declined"; } elseif ($recent_order_status == "F") {
} else { $usergroups = array(); } } if (empty($user_data['api_key'])) { Tygh::$app['view']->assign('new_api_key', Api::generateKey()); } /** * Only admin can set the api key. */ if (fn_check_user_type_admin_area($user_data) && !empty($user_data['user_id']) && ($auth['user_type'] == 'A' || $user_data['api_key'])) { $navigation['api'] = array('title' => __('api_access'), 'js' => true); Tygh::$app['view']->assign('show_api_tab', true); if ($auth['user_type'] != 'A') { Tygh::$app['view']->assign('hide_api_checkbox', true); } } Registry::set('navigation.tabs', $navigation); Tygh::$app['view']->assign('usergroups', $usergroups); Tygh::$app['view']->assign('hide_inputs', !fn_check_editable_permissions($auth, $user_data)); $profile_fields = fn_get_profile_fields($user_type); Tygh::$app['view']->assign('user_type', $user_type); Tygh::$app['view']->assign('profile_fields', $profile_fields); Tygh::$app['view']->assign('user_data', $user_data); Tygh::$app['view']->assign('ship_to_another', fn_check_shipping_billing($user_data, $profile_fields)); if (Registry::get('settings.General.user_multiple_profiles') == 'Y' && !empty($user_id)) { Tygh::$app['view']->assign('user_profiles', fn_get_user_profiles($user_id)); } Tygh::$app['view']->assign('countries', fn_get_simple_countries(true, CART_LANGUAGE)); Tygh::$app['view']->assign('states', fn_get_all_states()); }
function fn_check_profile_fields_population($user_data, $section, $profile_fields) { // If this section does not have fields, assume it's filled // or if we're checking shipping/billing section and shipping/billing address does not differ from billing/shipping, assume that fields filled correctly if ($section == 'B') { $check_section = 'S'; } else { $check_section = 'B'; } if (empty($profile_fields[$section]) || $section == $check_section && fn_check_shipping_billing($user_data, $profile_fields) == false) { return true; } foreach ($profile_fields[$section] as $field) { if ($field['required'] == 'Y' && (!empty($field['field_name']) && empty($user_data[$field['field_name']]) || empty($field['field_name']) && empty($user_data['fields'][$field['field_id']]))) { return false; } } return true; }
function fn_charge_subscription($subscription_id) { $_SESSION['cart'] = isset($_SESSION['cart']) ? $_SESSION['cart'] : array(); $cart =& $_SESSION['cart']; $_SESSION['customer_auth'] = isset($_SESSION['customer_auth']) ? $_SESSION['customer_auth'] : array(); $customer_auth =& $_SESSION['customer_auth']; fn_clear_cart($cart, true); $customer_auth = fn_fill_auth(); $subscription = fn_get_recurring_subscription_info($subscription_id); if ($subscription['status'] != 'A') { fn_set_notification('E', fn_get_lang_var('error'), fn_get_lang_var('rb_subscription_inactive')); } else { $product_data = array(); foreach ($subscription['order_info']['items'] as $k => $item) { if (!empty($subscription['order_info']['items'][$k]['extra']['recurring_plan_id']) && $subscription['order_info']['items'][$k]['extra']['recurring_plan_id'] == $subscription['plan_id'] && $subscription['order_info']['items'][$k]['extra']['recurring_duration'] == $subscription['orig_duration']) { $product_data[$subscription['order_info']['items'][$k]['product_id']] = array('amount' => $subscription['order_info']['items'][$k]['amount'], 'extra' => array('recurring_plan_id' => $subscription['plan_id'], 'recurring_force_calculate' => true, 'recurring_subscription_id' => $subscription['subscription_id'], 'recurring_plan' => $subscription['order_info']['items'][$k]['extra']['recurring_plan'], 'recurring_duration' => $subscription['order_info']['items'][$k]['extra']['recurring_duration'])); if (!empty($subscription['order_info']['items'][$k]['extra']['product_options'])) { $product_data[$subscription['order_info']['items'][$k]['product_id']]['product_options'] = $subscription['order_info']['items'][$k]['extra']['product_options']; } } } $cart['user_id'] = $subscription['user_id']; $u_data = db_get_row("SELECT user_id, user_type, tax_exempt FROM ?:users WHERE user_id = ?i", $cart['user_id']); $customer_auth = fn_fill_auth($u_data); $cart['user_data'] = array(); fn_add_product_to_cart($product_data, $cart, $customer_auth); $cart['profile_id'] = 0; $cart['user_data'] = fn_get_user_info($customer_auth['user_id'], true, $cart['profile_id']); if (!empty($cart['user_data'])) { $profile_fields = fn_get_profile_fields('O', $customer_auth); $cart['ship_to_another'] = fn_check_shipping_billing($cart['user_data'], $profile_fields); } fn_calculate_cart_content($cart, $customer_auth, 'A', true, 'I'); $cart['payment_id'] = $subscription['order_info']['payment_id']; $cart['payment_info'] = $subscription['order_info']['payment_info']; $cart['recurring_subscription_id'] = $subscription_id; list($order_id, $process_payment) = fn_place_order($cart, $customer_auth); if (!empty($order_id)) { $order_info = fn_get_order_info($order_id, true); $evt_data = array('subscription_id' => $subscription_id, 'timestamp' => $order_info['timestamp'], 'event_type' => 'C'); db_query("INSERT INTO ?:recurring_events ?e", $evt_data); if ($process_payment == true) { fn_start_payment($order_id); } $edp_data = fn_generate_ekeys_for_edp(array(), $order_info); fn_order_notification($order_info, $edp_data); } } }