Exemple #1
0
function fn_reward_points_clone_product(&$from_product_id, &$to_product_id)
{
    $reward_points = fn_get_reward_points($from_product_id);
    if (!empty($reward_points)) {
        foreach ($reward_points as $v) {
            unset($v['reward_point_id']);
            fn_add_reward_points($v, $to_product_id, PRODUCT_REWARD_POINTS);
        }
    }
    $fake = '';
    $price_in_points = fn_get_price_in_points($from_product_id, $fake);
    fn_add_price_in_points(array('point_price' => $price_in_points), $to_product_id);
}
Exemple #2
0
function fn_reward_points_clone_product($from_product_id, $to_product_id)
{
    $reward_points = fn_get_reward_points($from_product_id);
    if (!empty($reward_points)) {
        foreach ($reward_points as $v) {
            $_data = fn_check_table_fields($v, 'reward_points');
            fn_add_reward_points($_data, $to_product_id, PRODUCT_REWARD_POINTS);
        }
    }
    $fake = '';
    $price_in_points = fn_get_price_in_points($from_product_id, $fake);
    fn_add_price_in_points(array('point_price' => $price_in_points), $to_product_id);
}
Exemple #3
0
* 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 ($_SERVER['REQUEST_METHOD'] == 'POST') {
    return;
}
if ($mode == 'update') {
    // Add new tab to page sections
    // [Page sections]
    // Add new tab to page sections
    Registry::set('navigation.tabs.reward_points', array('title' => __('reward_points'), 'js' => true));
    // [/Page sections]
    Tygh::$app['view']->assign('reward_points', fn_get_reward_points($_REQUEST['category_id'], CATEGORY_REWARD_POINTS));
    Tygh::$app['view']->assign('object_type', CATEGORY_REWARD_POINTS);
} elseif ($mode == 'add') {
    // Add new tab to page sections
    // [Page sections]
    Registry::set('navigation.tabs.reward_points', array('title' => __('reward_points'), 'js' => true));
    // [/Page sections]
    Tygh::$app['view']->assign('object_type', CATEGORY_REWARD_POINTS);
}
Tygh::$app['view']->assign('reward_usergroups', fn_get_usergroups(array('type' => 'C', 'status' => array('A', 'H'), 'include_default' => true)));
/** /Body **/
Exemple #4
0
            foreach ($products_data as $key => $value) {
                $products_data[$key]['reward_points'] = fn_get_reward_points($key, 'P');
            }
    
            Registry::get('view')->assign('products_data', $products_data);
    
        }*/
    if (isset($field_names['is_pbp'])) {
        unset($field_names['is_pbp']);
    }
    if (isset($field_names['is_oper'])) {
        unset($field_names['is_oper']);
    }
    if (isset($field_names['is_op'])) {
        unset($field_names['is_op']);
    }
    Registry::get('view')->assign('field_groups', $field_groups);
    Registry::get('view')->assign('filled_groups', $filled_groups);
    Registry::get('view')->assign('field_names', $field_names);
} elseif ($mode == 'update') {
    Registry::set('navigation.tabs.reward_points', array('title' => __('reward_points'), 'js' => true));
    Registry::get('view')->assign('reward_points', fn_get_reward_points($_REQUEST['product_id'], PRODUCT_REWARD_POINTS));
    Registry::get('view')->assign('object_type', PRODUCT_REWARD_POINTS);
} elseif ($mode == 'add') {
    // Add new tab to page sections
    // [Page sections]
    Registry::set('navigation.tabs.reward_points', array('title' => __('reward_points'), 'js' => true));
    // [/Page sections]
    Registry::get('view')->assign('object_type', PRODUCT_REWARD_POINTS);
}
Registry::get('view')->assign('reward_usergroups', fn_get_usergroups(array('type' => 'C', 'status' => array('A', 'H'), 'include_default' => true)));
Exemple #5
0
                            foreach ($companies as $company_id => $name) {
                                fn_add_reward_points($v, 0, GLOBAL_REWARD_POINTS, $company_id);
                            }
                        }
                        continue;
                    }
                }
                fn_add_reward_points($v, 0, GLOBAL_REWARD_POINTS);
            }
        }
    }
    if ($mode == 'delete') {
        if (!empty($_REQUEST['change_id'])) {
            db_query("DELETE FROM ?:reward_point_changes WHERE change_id = ?i", $_REQUEST['change_id']);
        }
        return array(CONTROLLER_STATUS_REDIRECT, 'reward_points.userlog?user_id=' . $_REQUEST['user_id']);
    }
    return array(CONTROLLER_STATUS_OK, 'reward_points.manage');
}
if ($mode == 'manage') {
    // Add new tab to page sections
    Registry::set('navigation.tabs.reward_points', array('title' => __('reward_points'), 'js' => true));
    Registry::get('view')->assign('reward_points', fn_get_reward_points(0, GLOBAL_REWARD_POINTS));
    Registry::get('view')->assign('object_type', GLOBAL_REWARD_POINTS);
} elseif ($mode == 'add') {
    // Add new tab to page sections
    Registry::set('navigation.tabs.reward_points', array('title' => __('reward_points'), 'js' => true));
    Registry::get('view')->assign('object_type', GLOBAL_REWARD_POINTS);
}
Registry::get('view')->assign('reward_usergroups', fn_get_usergroups(array('type' => 'C', 'status' => array('A', 'H'), 'include_default' => true)));
/** /Body **/
            foreach ($products_data as $key => $value) {
                $products_data[$key]['reward_points'] = fn_get_reward_points($key, 'P');
            }
    
            \Tygh::$app['view']->assign('products_data', $products_data);
    
        }*/
    if (isset($field_names['is_pbp'])) {
        unset($field_names['is_pbp']);
    }
    if (isset($field_names['is_oper'])) {
        unset($field_names['is_oper']);
    }
    if (isset($field_names['is_op'])) {
        unset($field_names['is_op']);
    }
    Tygh::$app['view']->assign('field_groups', $field_groups);
    Tygh::$app['view']->assign('filled_groups', $filled_groups);
    Tygh::$app['view']->assign('field_names', $field_names);
} elseif ($mode == 'update') {
    Registry::set('navigation.tabs.reward_points', array('title' => __('reward_points'), 'js' => true));
    Tygh::$app['view']->assign('reward_points', fn_get_reward_points($_REQUEST['product_id'], PRODUCT_REWARD_POINTS));
    Tygh::$app['view']->assign('object_type', PRODUCT_REWARD_POINTS);
} elseif ($mode == 'add') {
    // Add new tab to page sections
    // [Page sections]
    Registry::set('navigation.tabs.reward_points', array('title' => __('reward_points'), 'js' => true));
    // [/Page sections]
    Tygh::$app['view']->assign('object_type', PRODUCT_REWARD_POINTS);
}
Tygh::$app['view']->assign('reward_usergroups', fn_get_usergroups(array('type' => 'C', 'status' => array('A', 'H'), 'include_default' => true)));
Exemple #7
0
function fn_twg_gather_reward_points_data(&$product, &$auth, $get_point_info = true)
{
    // Check, if the product has any option points modifiers
    if (empty($product['options_update']) && !empty($product['product_options'])) {
        foreach ($product['product_options'] as $_id => $option) {
            if (!empty($product['product_options'][$_id]['variants'])) {
                foreach ($product['product_options'][$_id]['variants'] as $variant) {
                    if (!empty($variant['point_modifier']) && floatval($variant['point_modifier'])) {
                        $product['options_update'] = true;
                        break 2;
                    }
                }
            }
        }
    }
    if (isset($product['exclude_from_calculate']) || isset($product['points_info']['reward']) && !(CONTROLLER == 'products' && MODE == 'options') || $get_point_info == false) {
        return false;
    }
    $main_category = db_get_field("SELECT category_id FROM ?:products_categories WHERE product_id = ?i AND link_type = 'M'", $product['product_id']);
    $candidates = array(PRODUCT_REWARD_POINTS => $product['product_id'], CATEGORY_REWARD_POINTS => $main_category, GLOBAL_REWARD_POINTS => 0);
    $reward_points = array();
    foreach ($candidates as $object_type => $object_id) {
        $_reward_points = fn_get_reward_points($object_id, $object_type, $auth['usergroup_ids']);
        if ($object_type == CATEGORY_REWARD_POINTS && !empty($_reward_points)) {
            // get the "override point" setting
            $category_is_op = db_get_field("SELECT is_op FROM ?:categories WHERE category_id = ?i", $_reward_points['object_id']);
        }
        if ($object_type == CATEGORY_REWARD_POINTS && (empty($_reward_points) || $category_is_op != 'Y')) {
            // if there is no points of main category of the "override point" setting is disabled
            // then get point of secondary categories
            $secondary_categories = db_get_fields("SELECT category_id FROM ?:products_categories WHERE product_id = ?i AND link_type = 'A'", $product['product_id']);
            if (!empty($secondary_categories)) {
                $secondary_categories_points = array();
                foreach ($secondary_categories as $value) {
                    $_rp = fn_get_reward_points($value, $object_type, $auth['usergroup_ids']);
                    if (isset($_rp['amount'])) {
                        $secondary_categories_points[] = $_rp;
                    }
                    unset($_rp);
                }
                if (!empty($secondary_categories_points)) {
                    $sorted_points = fn_sort_array_by_key($secondary_categories_points, 'amount', Registry::get('addons.reward_points.several_points_action') == 'min' ? SORT_ASC : SORT_DESC);
                    $_reward_points = array_shift($sorted_points);
                }
            }
            if (!isset($_reward_points['amount'])) {
                if (Registry::get('addons.reward_points.higher_level_extract') == 'Y' && !empty($candidates[$object_type])) {
                    $id_path = db_get_field("SELECT REPLACE(id_path, '{$candidates[$object_type]}', '') FROM ?:categories WHERE category_id = ?i", $candidates[$object_type]);
                    if (!empty($id_path)) {
                        $c_ids = explode('/', trim($id_path, '/'));
                        $c_ids = array_reverse($c_ids);
                        foreach ($c_ids as $category_id) {
                            $__reward_points = fn_get_reward_points($category_id, $object_type, $auth['usergroup_ids']);
                            if (!empty($__reward_points)) {
                                // get the "override point" setting
                                $_category_is_op = db_get_field("SELECT is_op FROM ?:categories WHERE category_id = ?i", $__reward_points['object_id']);
                                if ($_category_is_op == 'Y') {
                                    $category_is_op = $_category_is_op;
                                    $_reward_points = $__reward_points;
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
        if (!empty($_reward_points) && ($object_type == GLOBAL_REWARD_POINTS || $object_type == PRODUCT_REWARD_POINTS && $product['is_op'] == 'Y' || $object_type == CATEGORY_REWARD_POINTS && (!empty($category_is_op) && $category_is_op == 'Y'))) {
            // if global points or category points (and override points is enabled) or product points (and override points is enabled)
            $reward_points = $_reward_points;
            break;
        }
    }
    if (isset($reward_points['amount'])) {
        if ((defined('ORDER_MANAGEMENT') || CONTROLLER == 'checkout' || CONTROLLER == 'twigmo') && isset($product['subtotal']) && isset($product['original_price'])) {
            if (Registry::get('addons.reward_points.points_with_discounts') == 'Y' && $reward_points['amount_type'] == 'P' && !empty($product['discounts'])) {
                $product['discount'] = empty($product['discount']) ? 0 : $product['discount'];
                $reward_points['coefficient'] = floatval($product['price']) ? ($product['price'] * $product['amount'] - $product['discount']) / $product['price'] * $product['amount'] / pow($product['amount'], 2) : 0;
            } else {
                $reward_points['coefficient'] = 1;
            }
        } else {
            $reward_points['coefficient'] = Registry::get('addons.reward_points.points_with_discounts') == 'Y' && $reward_points['amount_type'] == 'P' && isset($product['discounted_price']) ? $product['discounted_price'] / $product['price'] : 1;
        }
        if (isset($product['extra']['configuration'])) {
            if ($reward_points['amount_type'] == 'P') {
                // for configurable product calc reward points only for base price
                $price = $product['original_price'];
                if (!empty($product['discount'])) {
                    $price -= $product['discount'];
                }
                $reward_points['amount'] = $price * $reward_points['amount'] / 100;
            } else {
                $points_info = Registry::get("runtime.product_configurator.points_info");
                if (!empty($points_info[$product['product_id']])) {
                    $reward_points['amount'] = $points_info[$product['product_id']]['reward'];
                    $reward_points['coefficient'] = 1;
                }
            }
        } else {
            if ($reward_points['amount_type'] == 'P') {
                $reward_points['amount'] = $product['price'] * $reward_points['amount'] / 100;
            }
        }
        $reward_points['raw_amount'] = $reward_points['coefficient'] * $reward_points['amount'];
        $reward_points['raw_amount'] = !empty($product['selected_options']) ? fn_apply_options_modifiers($product['selected_options'], $reward_points['raw_amount'], POINTS_MODIFIER_TYPE) : $reward_points['raw_amount'];
        $reward_points['amount'] = round($reward_points['raw_amount']);
        $product['points_info']['reward'] = $reward_points;
    }
    fn_twg_calculate_product_price_in_points($product, $auth, $get_point_info);
}
* 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 ($_SERVER['REQUEST_METHOD'] == 'POST') {
    return;
}
if ($mode == 'update') {
    // Add new tab to page sections
    // [Page sections]
    // Add new tab to page sections
    Registry::set('navigation.tabs.reward_points', array('title' => __('reward_points'), 'js' => true));
    // [/Page sections]
    Registry::get('view')->assign('reward_points', fn_get_reward_points($_REQUEST['category_id'], CATEGORY_REWARD_POINTS));
    Registry::get('view')->assign('object_type', CATEGORY_REWARD_POINTS);
} elseif ($mode == 'add') {
    // Add new tab to page sections
    // [Page sections]
    Registry::set('navigation.tabs.reward_points', array('title' => __('reward_points'), 'js' => true));
    // [/Page sections]
    Registry::get('view')->assign('object_type', CATEGORY_REWARD_POINTS);
}
Registry::get('view')->assign('reward_usergroups', fn_array_merge(fn_get_default_usergroups(), fn_get_usergroups('C')));
/** /Body **/
    }
    if ($mode == 'do_cleanup_logs') {
        db_query("DELETE FROM ?:reward_point_changes WHERE user_id = ?i", $_REQUEST['user_id']);
    }
    // Add/Update wholesale prices info
    if ($mode == 'add' || $mode == 'update') {
        if (isset($_REQUEST['reward_points'])) {
            foreach ($_REQUEST['reward_points'] as $k => $v) {
                fn_add_reward_points($v, 0, GLOBAL_REWARD_POINTS);
            }
        }
    }
    return array(CONTROLLER_STATUS_OK, "reward_points.manage");
}
if ($mode == 'manage') {
    // Add new tab to page sections
    Registry::set('navigation.tabs.reward_points', array('title' => fn_get_lang_var('reward_points'), 'js' => true));
    $view->assign('reward_points', fn_get_reward_points(0, GLOBAL_REWARD_POINTS));
    $view->assign('object_type', GLOBAL_REWARD_POINTS);
} elseif ($mode == 'add') {
    // Add new tab to page sections
    Registry::set('navigation.tabs.reward_points', array('title' => fn_get_lang_var('reward_points'), 'js' => true));
    $view->assign('object_type', GLOBAL_REWARD_POINTS);
} elseif ($mode == 'do_userlog_delete') {
    if (!empty($_REQUEST['change_id'])) {
        db_query("DELETE FROM ?:reward_point_changes WHERE change_id = ?i", $_REQUEST['change_id']);
    }
    return array(CONTROLLER_STATUS_REDIRECT, "reward_points.userlog?user_id={$_REQUEST['user_id']}");
}
$view->assign('reward_usergroups', fn_array_merge(fn_get_default_usergroups(), fn_get_usergroups('C')));
/** /Body **/
Exemple #10
0
                            foreach ($companies as $company_id => $name) {
                                fn_add_reward_points($v, 0, GLOBAL_REWARD_POINTS, $company_id);
                            }
                        }
                        continue;
                    }
                }
                fn_add_reward_points($v, 0, GLOBAL_REWARD_POINTS);
            }
        }
    }
    if ($mode == 'delete') {
        if (!empty($_REQUEST['change_id'])) {
            db_query("DELETE FROM ?:reward_point_changes WHERE change_id = ?i", $_REQUEST['change_id']);
        }
        return array(CONTROLLER_STATUS_REDIRECT, 'reward_points.userlog?user_id=' . $_REQUEST['user_id']);
    }
    return array(CONTROLLER_STATUS_OK, 'reward_points.manage');
}
if ($mode == 'manage') {
    // Add new tab to page sections
    Registry::set('navigation.tabs.reward_points', array('title' => __('reward_points'), 'js' => true));
    Tygh::$app['view']->assign('reward_points', fn_get_reward_points(0, GLOBAL_REWARD_POINTS));
    Tygh::$app['view']->assign('object_type', GLOBAL_REWARD_POINTS);
} elseif ($mode == 'add') {
    // Add new tab to page sections
    Registry::set('navigation.tabs.reward_points', array('title' => __('reward_points'), 'js' => true));
    Tygh::$app['view']->assign('object_type', GLOBAL_REWARD_POINTS);
}
Tygh::$app['view']->assign('reward_usergroups', fn_get_usergroups(array('type' => 'C', 'status' => array('A', 'H'), 'include_default' => true)));
/** /Body **/