$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; }
$cart['recalculate'] = true; if ($gift_certificates_are_active) { include_once Registry::get('config.dir.addons') . 'gift_certificates/controllers/frontend/checkout.post.php'; } fn_calculate_cart_content($cart, $_SESSION['auth'], 'E', true, 'F', true); $response->setData(fn_twg_api_get_session_cart($cart)); } elseif ($meta['action'] == 'delete_coupon') { $cart =& $_SESSION['cart']; unset($cart['coupons'][$_REQUEST['coupon_code']], $cart['pending_coupon']); $cart['recalculate'] = true; fn_calculate_cart_content($cart, $_SESSION['auth'], 'E', true, 'F', true); $response->setData(fn_twg_api_get_session_cart($cart)); } elseif ($meta['action'] == 'delete_use_certificate') { $cart =& $_SESSION['cart']; $gift_cert_code = empty($_REQUEST['gift_cert_code']) ? '' : strtoupper(trim($_REQUEST['gift_cert_code'])); fn_delete_gift_certificate_in_use($gift_cert_code, $cart); $cart['recalculate'] = true; fn_calculate_cart_content($cart, $_SESSION['auth'], 'E', true, 'F', true); $response->setData(fn_twg_api_get_session_cart($cart)); } elseif ($meta['action'] == 'apply_points' || $meta['action'] == 'delete_points') { $request = $_REQUEST; if (function_exists('fn_enable_checkout_mode')) { fn_enable_checkout_mode(); } else { Registry::set('runtime.checkout', true); } $cart =& $_SESSION['cart']; if ($meta['action'] == 'apply_points') { $points_to_use = empty($request['points_to_use']) ? 0 : intval($request['points_to_use']); if (!empty($points_to_use) && abs($points_to_use) == $points_to_use) { $cart['points_info']['in_use']['points'] = $points_to_use;
$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; }
**************************************************************************** * PLEASE READ THE FULL TEXT OF THE SOFTWARE LICENSE AGREEMENT IN THE * * "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE. * ****************************************************************************/ use Tygh\Registry; if (!defined('BOOTSTRAP')) { die('Access denied'); } $cart =& $_SESSION['cart']; $suffix = !empty($cart['order_id']) ? '.update' : '.add'; if ($_SERVER['REQUEST_METHOD'] == 'POST') { // // Delete attached certificate // if ($mode == 'delete_use_certificate') { fn_delete_gift_certificate_in_use($_REQUEST['gift_cert_code'], $cart); return array(CONTROLLER_STATUS_REDIRECT, 'order_management' . $suffix); } if ($mode == 'delete_certificate') { if (!empty($_REQUEST['gift_cert_cart_id'])) { fn_delete_cart_gift_certificate($cart, $_REQUEST['gift_cert_cart_id']); return array(CONTROLLER_STATUS_REDIRECT, 'order_management' . $suffix); } } return; } // // Display totals // if ($mode == 'update' || $mode == 'add') { $gift_certificate_condition = !empty($cart['use_gift_certificates']) ? db_quote(" AND gift_cert_code NOT IN (?a)", array_keys($cart['use_gift_certificates'])) : '';