function cw_checkout_userinfo($user_account) { global $customer_id, $config; $userinfo = $user_account; if ($customer_id) { $userinfo = array_merge(cw_user_get_info($customer_id, 65535), $userinfo); } $userinfo['main_address'] = cw_user_get_address_by_type('main'); $userinfo['current_address'] = cw_user_get_address_by_type('current'); return $userinfo; }
function cw_check_condition_Z($offer_id) { global $user_address, $tables; $zones = cw_call('cw_cart_get_zones', array('address' => cw_user_get_address_by_type('current'), 'is_shipping' => 1)); $conditions = cw_query_column("SELECT object_id FROM {$tables['ps_cond_details']} WHERE offer_id='{$offer_id}' AND object_type='" . PS_OBJ_TYPE_ZONES . "'"); if (!empty($conditions) && is_array($conditions)) { foreach ($conditions as $k => $v) { if (isset($zones[$v])) { return true; } } # one match found - conndition is met return false; # there are PS_SHIP_ADDRESS conditions, but they don't match customer's zones } return true; // there are no PS_SHIP_ADDRESS conditions at all \ }
<?php global $smarty, $user_account, $customer_id, $user_address; $user_address =& cw_session_register('user_address', array()); $user_account['membership_id'] = 0; if ($customer_id) { $user_account = cw_user_get_user_account($customer_id, "status='Y' and usertype in ('" . (AREA_TYPE == 'C' ? "C', 'R" : AREA_TYPE) . "')"); $user_address['current_address'] = cw_user_get_address_by_type('current'); $user_address['main_address'] = cw_user_get_address_by_type('main'); $user_account = array_merge($user_account, (array) $user_address['current_address']); if (!$user_account['customer_id']) { cw_unset($identifiers, AREA_TYPE); $customer_id = 0; $user_account = array(); } // Force redirect to change password page if ($user_account["change_password"] && !in_array($target, array('change_password', 'ajax', 'acc_manager', 'user'), true) && !defined('IS_AJAX')) { cw_header_location('index.php?target=change_password&redirect=Y'); } } $user_address['current_address'] = cw_user_get_address_by_type('current'); $user_address['main_address'] = cw_user_get_address_by_type('main'); $smarty->assign('user_address', $user_address); $smarty->assign('customer_id', $customer_id); $smarty->assign('usertype', $current_area); $smarty->assign('current_area', $current_area);
$address = cw_user_get_address($user, $address_id); } $smarty->assign('address', $address); $smarty->assign('address_id', $address_id); // $smarty->assign('is_main', $is_main); $smarty->assign('name_prefix', 'update_fields[address][' . (in_array($address_type, array('main', 'current'), true) ? $address_type : $address_id) . ']'); cw_add_ajax_block(array('id' => in_array($address_type, array('main', 'current'), true) ? $address_type . '_address' : 'address', 'action' => 'update', 'template' => 'main/users/sections/address_modify.tpl'), $address_type . '_address'); } if ($action == 'set_main' || $action == 'set_current') { $field = $action == 'set_main' ? 'main' : 'current'; Customer\Address\setAddressType($user, $field, $address_id); cw_user_check_addresses($user); // For correct shipping cost calculate after address changing cw_load('user'); $user_address =& cw_session_register('user_address'); $user_address = array(); global $userinfo; $userinfo['current_address'] = cw_user_get_address_by_type('current'); cw_add_top_message('Address has been updated'); } $smarty->assign('address_type', $address_type); $smarty->assign('user', $user); if (defined('IS_AJAX')) { if ($user) { $addresses = cw_user_get_addresses(intval($user)); } $smarty->assign('addresses', $addresses); cw_add_ajax_block(array('id' => 'address_book', 'action' => 'replace', 'template' => 'main/users/address_book.tpl'), 'address_book'); } else { cw_header_location("index.php?target={$target}&user={$user}"); }