コード例 #1
0
function cw_ean_get_product_info($ean)
{
    global $tables, $config, $addons;
    if (empty($ean)) {
        return array();
    }
    cw_ean_clear($ean);
    $where = array();
    if (in_array(1, $config['pos']['fields_for_ean'])) {
        $where[] = "productcode='{$ean}'";
    }
    if (in_array(0, $config['pos']['fields_for_ean'])) {
        $where[] = "eancode='{$ean}'";
    }
    if (!count($where)) {
        $where[] = "eancode='{$ean}'";
    }
    $where = implode(' or ', $where);
    $product_info = array();
    # kornev, TOFIX
    if ($addons['product_options']) {
        $product_info = cw_query_first("select product_id, variant_id from {$tables['product_variants']} where {$where}");
    }
    if (!$product_info['product_id']) {
        $product_info = cw_query_first("select product_id, 0 as variant_id from {$tables['products']} where {$where}");
    }
    if (!$product_info['product_id'] && in_array(2, $config['pos']['fields_for_ean'])) {
        $product_info = cw_query_first("select product_id, variant_id from {$tables['products_supplied_amount']} where productcode='{$ean}'");
    }
    if (!$product_info['product_id'] && in_array(3, $config['pos']['fields_for_ean']) && $addons['sn']) {
        $product_info = cw_query_first("select product_id, 0 as variant_id from {$tables['serial_numbers']} where sn='{$ean}'");
    }
    return $product_info;
}
コード例 #2
0
if ($product_id) {
    $smarty->assign('main', 'product_modify');
} else {
    $smarty->assign('main', 'product_add');
}
if ($REQUEST_METHOD == "POST" && ($action == "product_modify" || $action == 'add') && (AREA_TYPE == 'A' || AREA_TYPE == 'V')) {
    $is_variant = false;
    # kornev, TOFIX
    if ($product_id && $addons['product_options']) {
        $is_variant = cw_product_has_variants($product_id);
    }
    $last_added_product_type = $product_data['product_type'];
    if (!$product_data['eancode'] && $addons['barcode'] && $config['barcode']['gen_product_code']) {
        $product_data['eancode'] = cw_product_generate_sku($config['barcode']['gen_product_code'], 'eancode');
    }
    cw_ean_clear($product_data['eancode']);
    if ($mode == 'add') {
        if (!$product_data['productcode']) {
            $product_data['productcode'] = cw_product_generate_sku();
        }
        if (!$product_data['membership_ids']) {
            $product_data['membership_ids'] = array_keys(unserialize($config['product_settings']['default_product_memberships']));
        }
    }
    $rules = array('category_id' => '', 'product' => '', 'productcode' => array('func' => 'cw_error_sku_exists'), 'manufacturer_code' => array('func' => 'cw_error_manufacturer_code_exists'));
    if ($config['General']['product_descr_is_required'] == 'Y') {
        $rules['fulldescr'] = '';
    }
    $product_data['product_id'] = $product_id;
    $product_data['attributes'] = $attributes;
    if ($config['Appearance']['categories_in_products'] == '0') {