Exemple #1
0
function fn_gift_certificates_reorder(&$order_info, &$cart, &$auth)
{
    // Check whether gift certificates exist
    if (isset($order_info['gift_certificates'])) {
        if (isset($order_info['products'])) {
            foreach ($order_info['products'] as $k => $item) {
                if (isset($order_info['products'][$k]['extra']['parent']['certificate'])) {
                    unset($order_info['products'][$k]);
                }
            }
        }
        // Gift certificates is empty, create it
        if (empty($cart['gift_certificates'])) {
            $cart['gift_certificates'] = array();
        }
        foreach ($order_info['gift_certificates'] as $v) {
            unset($v['gift_cert_id']);
            unset($v['gift_cert_code']);
            unset($v['subtotal']);
            unset($v['display_subtotal']);
            unset($v['tax_value']);
            list($gift_cert_id, $gift_cert) = fn_add_gift_certificate_to_cart($v, $auth);
            if (!empty($gift_cert_id)) {
                $cart['gift_certificates'][$gift_cert_id] = $gift_cert;
            }
        }
    }
    return true;
}
             $gift_cert['display_subtotal'] = $_SESSION['cart']['gift_certificates'][$gift_cert_id]['display_subtotal'];
             Tygh::$app['view']->assign('gift_cert', $gift_cert);
             $msg = Tygh::$app['view']->fetch('views/checkout/components/product_notification.tpl');
             fn_set_notification('I', __('gift_certificate_added_to_cart'), $msg, 'I');
         }
         fn_save_cart_content($_SESSION['cart'], $auth['user_id']);
         if (defined('AJAX_REQUEST')) {
             fn_calculate_cart_content($_SESSION['cart'], $auth, false, false, 'F', false);
         }
     }
 }
 if ($mode == 'update') {
     if (!empty($_REQUEST['gift_cert_data']) && !empty($_REQUEST['gift_cert_id']) && $_REQUEST['type'] == 'C') {
         fn_delete_cart_gift_certificate($_SESSION['cart'], $_REQUEST['gift_cert_id']);
         unset($_SESSION['cart']['product_groups']);
         list($gift_cert_id, $gift_cert) = fn_add_gift_certificate_to_cart($_REQUEST['gift_cert_data'], $auth);
         if (!empty($gift_cert_id)) {
             $_SESSION['cart']['gift_certificates'][$gift_cert_id] = $gift_cert;
         }
         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'])) {