コード例 #1
0
* "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE.            *
****************************************************************************/
//
// $Id: gift_certificates.php 10229 2010-07-27 14:21:39Z 2tl $
//
if (!defined('AREA')) {
    die('Access denied');
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    // Define trusted variables that shouldn't be stripped
    fn_trusted_vars('gift_cert_data');
    if ($mode == 'add') {
        if (!empty($_REQUEST['gift_cert_data'])) {
            do {
                $code = fn_generate_gift_certificate_code();
            } while (true == fn_check_gift_certificate_code($code));
            $gift_cert_data = $_REQUEST['gift_cert_data'];
            fn_correct_gift_certificate($gift_cert_data);
            $_data = fn_check_table_fields($gift_cert_data, 'gift_certificates');
            $_data = fn_array_merge($_data, array('gift_cert_code' => $code, 'timestamp' => TIME));
            if (!empty($_data['products'])) {
                $_data['products'] = serialize($_data['products']);
            }
            $gift_cert_id = db_query("INSERT INTO ?:gift_certificates ?e", $_data);
            $gift_cert_data = fn_get_gift_certificate_info($gift_cert_id);
            fn_gift_certificate_notification($gift_cert_data, fn_get_notification_rules($_REQUEST));
            $suffix = ".update?gift_cert_id={$gift_cert_id}";
        }
    }
    if ($mode == 'update') {
        if (!empty($_REQUEST['gift_cert_data'])) {
コード例 #2
0
ファイル: gift_certificates.php プロジェクト: askzap/ultimate
function fn_update_gift_certificate($gift_cert_data, $gift_cert_id = 0, $params = array())
{
    fn_correct_gift_certificate($gift_cert_data);
    $gift_cert_data['products'] = !empty($gift_cert_data['products']) ? serialize($gift_cert_data['products']) : '';
    if (empty($gift_cert_id)) {
        do {
            $code = fn_generate_gift_certificate_code();
        } while (true == fn_check_gift_certificate_code($code));
        $gift_cert_data = fn_array_merge($gift_cert_data, array('gift_cert_code' => $code, 'timestamp' => TIME));
        if (fn_allowed_for('ULTIMATE') && Registry::get('runtime.company_id')) {
            $gift_cert_data['company_id'] = Registry::get('runtime.company_id');
        }
        $gift_cert_id = db_query("INSERT INTO ?:gift_certificates ?e", $gift_cert_data);
    } else {
        // Change certfificate status
        fn_change_gift_certificate_status($gift_cert_id, $gift_cert_data['status'], '', fn_get_notification_rules(array(), false));
        //if difference then add line in log
        $debit_info = db_get_row("SELECT debit AS amount, debit_products AS products FROM ?:gift_certificates_log WHERE gift_cert_id = ?i ORDER BY timestamp DESC", $gift_cert_id);
        if (empty($debit_info)) {
            $debit_info = db_get_row("SELECT amount, products FROM ?:gift_certificates WHERE gift_cert_id = ?i", $gift_cert_id);
        }
        $is_diff = $gift_cert_data['amount'] - $debit_info['amount'] != 0 || md5($gift_cert_data['products']) != md5($debit_info['products']);
        if ($is_diff == true) {
            $_info = array('amount' => $gift_cert_data['amount'], 'products' => $gift_cert_data['products']);
            fn_add_gift_certificate_log_record($gift_cert_id, $debit_info, $_info);
        }
        //Update certificate data
        $_data = $gift_cert_data;
        db_query("UPDATE ?:gift_certificates SET ?u WHERE gift_cert_id = ?i", $gift_cert_data, $gift_cert_id);
    }
    $gc_data = fn_get_gift_certificate_info($gift_cert_id);
    fn_gift_certificate_notification($gc_data, fn_get_notification_rules($params));
    return $gift_cert_id;
}
コード例 #3
0
ファイル: func.php プロジェクト: arpad9/bygmarket
/**
 * Apply gift certificates from cart data
 *
 * @param array $cart Array of cart content and user information necessary for purchase
 * @param array $new_cart_data Array of new data for products, totals, discounts and etc. update
 * @param array $auth Array of user authentication data (e.g. uid, usergroup_ids, etc.)
 * @return boolean Always true
 */
function fn_gift_certificates_update_cart_by_data_post(&$cart, &$new_cart_data, &$auth)
{
    if (!empty($new_cart_data['gift_cert_code'])) {
        $company_id = Registry::get('runtime.company_id');
        if (fn_check_gift_certificate_code($new_cart_data['gift_cert_code'], true, $company_id) == true) {
            if (!isset($cart['use_gift_certificates'][$new_cart_data['gift_cert_code']])) {
                $cart['use_gift_certificates'][$new_cart_data['gift_cert_code']] = 'Y';
            }
        }
    }
    return true;
}
コード例 #4
0
ファイル: checkout.post.php プロジェクト: askzap/ultimate
*                                                                          *
****************************************************************************
* 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');
}
$gift_cert_code = empty($_REQUEST['gift_cert_code']) ? '' : strtoupper(trim($_REQUEST['gift_cert_code']));
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if ($mode == 'apply_coupon') {
        $gift_cert_code = empty($_REQUEST['coupon_code']) ? '' : strtoupper(trim($_REQUEST['coupon_code']));
        $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';
コード例 #5
0
ファイル: checkout.pre.php プロジェクト: ambient-lounge/site
*                                                                          *
* This  is  commercial  software,  only  users  who have purchased a valid *
* license  and  accept  to the terms of the  License Agreement can install *
* and use this program.                                                    *
*                                                                          *
****************************************************************************
* 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');
}
if (in_array($mode, array('cart', 'checkout', 'place_order')) && isset(Tygh::$app['session']['cart']['use_gift_certificates'])) {
    $company_id = Registry::get('runtime.company_id');
    $codes = fn_check_gift_certificate_code(array_keys(Tygh::$app['session']['cart']['use_gift_certificates']), true, $company_id);
    $remove_codes = array_diff_key(Tygh::$app['session']['cart']['use_gift_certificates'], !empty($codes) ? $codes : array());
    $removed_codes = false;
    if (!empty($remove_codes)) {
        foreach ($remove_codes as $code => $value) {
            unset(Tygh::$app['session']['cart']['use_gift_certificates'][$code]);
        }
        $removed_codes = true;
    }
    if ($removed_codes) {
        fn_set_notification('W', __('warning'), __('warning_gift_cert_deny', array('[codes]' => implode(', ', array_keys($remove_codes)))), 'K');
    }
    if ($mode == 'place_order') {
        fn_calculate_cart_content(Tygh::$app['session']['cart'], $auth, 'A', true, 'F');
    }
    return;
コード例 #6
0
ファイル: checkout.pre.php プロジェクト: askzap/ultimate
*                                                                          *
* This  is  commercial  software,  only  users  who have purchased a valid *
* license  and  accept  to the terms of the  License Agreement can install *
* and use this program.                                                    *
*                                                                          *
****************************************************************************
* 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');
}
if (in_array($mode, array('cart', 'checkout', 'place_order')) && isset($_SESSION['cart']['use_gift_certificates'])) {
    $company_id = Registry::get('runtime.company_id');
    $codes = fn_check_gift_certificate_code(array_keys($_SESSION['cart']['use_gift_certificates']), true, $company_id);
    $remove_codes = array_diff_key($_SESSION['cart']['use_gift_certificates'], !empty($codes) ? $codes : array());
    $removed_codes = false;
    if (!empty($remove_codes)) {
        foreach ($remove_codes as $code => $value) {
            unset($_SESSION['cart']['use_gift_certificates'][$code]);
        }
        $removed_codes = true;
    }
    if ($removed_codes) {
        fn_set_notification('W', __('warning'), __('warning_gift_cert_deny', array('[codes]' => implode(', ', array_keys($remove_codes)))), 'K');
    }
    if ($mode == 'place_order') {
        fn_calculate_cart_content($_SESSION['cart'], $auth, 'A', true, 'F');
    }
    return;
コード例 #7
0
                    $gift_certificates[$v['extra']['parent']['certificate']]['products'][$cart_id] = array('product_id' => $v['product_id'], 'product_options' => empty($v['extra']['product_options']) ? array() : $v['extra']['product_options'], 'amount' => $v['amount']);
                }
            }
            if (!empty($gift_certificates)) {
                foreach ($gift_certificates as $cert_id => $cert_data) {
                    $cart['gift_certificates'][$cert_id]['products'] = $cert_data['products'];
                }
            }
        }
    }
    //
    // Update totals
    //
    if ($mode == 'update_totals') {
        if (!empty($_REQUEST['gift_cert_code'])) {
            if (fn_check_gift_certificate_code($_REQUEST['gift_cert_code'], true) == true) {
                if (!isset($cart['use_gift_certificates'][$_REQUEST['gift_cert_code']])) {
                    $cart['use_gift_certificates'][$_REQUEST['gift_cert_code']] = 'Y';
                }
            }
        }
    }
    return;
}
//
// 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.totals");
    //
コード例 #8
0
ファイル: func.php プロジェクト: diedsmiling/busenika
function fn_gift_certificates_apply_google_codes(&$cart, $codes)
{
    $cart['use_gift_certificates'] = array();
    foreach ($codes as $_code) {
        if (true == fn_check_gift_certificate_code($_code, true)) {
            if (!isset($cart['use_gift_certificates'][$_code])) {
                $cart['use_gift_certificates'][$_code] = 'Y';
            }
        }
    }
    return true;
}
コード例 #9
0
*                                                                          *
****************************************************************************
* PLEASE READ THE FULL TEXT  OF THE SOFTWARE  LICENSE   AGREEMENT  IN  THE *
* "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE.            *
****************************************************************************/
//
// $Id: checkout.post.php 10229 2010-07-27 14:21:39Z 2tl $
//
if (!defined('AREA')) {
    die('Access denied');
}
$gift_cert_code = empty($_REQUEST['gift_cert_code']) ? '' : strtoupper(trim($_REQUEST['gift_cert_code']));
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if ($mode == 'apply_certificate') {
        if (!empty($gift_cert_code)) {
            if (true == fn_check_gift_certificate_code($gift_cert_code, true)) {
                if (!isset($_SESSION['cart']['use_gift_certificates'][$gift_cert_code])) {
                    $_SESSION['cart']['use_gift_certificates'][$gift_cert_code] = 'Y';
                    fn_set_notification('N', fn_get_lang_var('notice'), fn_get_lang_var('text_gift_cert_applied'));
                } else {
                    fn_set_notification('W', fn_get_lang_var('warning'), fn_get_lang_var('certificate_already_used'));
                }
            } else {
                $status = db_get_field("SELECT status FROM ?:gift_certificates WHERE gift_cert_code = ?s", $gift_cert_code);
                if (!empty($status) && !strstr('A', $status)) {
                    fn_set_notification('W', fn_get_lang_var('warning'), fn_get_lang_var('certificate_code_not_available'));
                } else {
                    fn_set_notification('W', fn_get_lang_var('warning'), fn_get_lang_var('certificate_code_not_valid'));
                }
            }
        }