附件:http://files.cnblogs.com/lzj87980239/Category_Quantity_Discount.rar
效果图
后台
1.将update.sql导入到数据库
2.将YOUR_TEMPLATES文件夹改为自己的模板名,然后上传到网站根目录
3.在includes/database_tables.php 在末尾添加代码
define('TABLE_CATEGORIES_DISCOUNT_QUANTITY', DB_PREFIX . 'categories_discount_quantity');
4.在includes/functions/functions_prices.php查找
$display_price = zen_get_products_base_price($product_id);
在其上添加
$products_query_discount_type = $products_query->fields['products_discount_type']; if ($products_discounts_query->RecordCount() <=0 and $products_query_discount_type == 0) { $products_query2 = $db->Execute("select categories_discount_type, categories_discount_type_from FROM " . TABLE_CATEGORIES . " c , ". TABLE_PRODUCTS_TO_CATEGORIES ." pc where c.categories_id = pc.categories_id AND products_id='" . (int)$product_id . "'"); $products_query_discount_type = $products_query2->fields['categories_discount_type']; $products_discounts_query = $db->Execute("SELECT * FROM " . TABLE_CATEGORIES_DISCOUNT_QUANTITY ." cd,". TABLE_PRODUCTS_TO_CATEGORIES." pc WHERE cd.categories_id = pc.categories_id AND products_id = " . (int)$product_id. " AND discount_qty <= '" .(float)$check_qty. "' ORDER BY discount_qty DESC"); }
查找
switch ($products_query->fields['products_discount_type']) {
替换为
switch ($products_query_discount_type) {
5.在includes/classes/shopping_cart.php查找
// discount qty pricing
在其下添加(有2处,2处都添加)
$categories_query = $db->Execute("SELECT categories_discount_type FROM ". TABLE_CATEGORIES ." WHERE categories_id = ". zen_get_products_category_id($products_id));
再查找
if ($products->fields['products_discount_type'] != '0') {
修改为
if ($products->fields['products_discount_type'] != '0' || $categories_query->fields['categories_discount_type'] != '0') {
再查找
if ($product->fields['products_discount_type'] != '0') {
修改为
if ($product->fields['products_discount_type'] != '0' || $categories_query->fields['categories_discount_type'] != '0') {
6.在includes/modules/pages/product_info/main_template_vars.php查找
$products_discount_type = $product_info->fields['products_discount_type']; $products_discount_type_from = $product_info->fields['products_discount_type_from'];
修改为
$categories_discount = $db->Execute("SELECT * FROM ".TABLE_CATEGORIES." WHERE categories_id = ".$current_category_id); if( $product_info->fields['products_discount_type']!=0 ){ $products_discount_type = $product_info->fields['products_discount_type']; $products_discount_type_from = $product_info->fields['products_discount_type_from']; }else{ $products_discount_type = $categories_discount->fields['categories_discount_type']; $products_discount_type_from = $categories_discount->fields['categories_discount_type_from']; }
7.在includes/modules/products_quantity_discounts.php中查找
$discount_col_cnt = DISCOUNT_QUANTITY_PRICES_COLUMN;
在其上添加
if ($products_discounts_query->RecordCount() <=0 ) { $products_discounts_query = $db->Execute("SELECT * FROM " . TABLE_CATEGORIES_DISCOUNT_QUANTITY ." WHERE categories_id = " . (int)$current_category_id . " AND discount_qty !=0" . " ORDER BY discount_qty" ); }
8.在includes emplatesYOUR_TEMPLATE emplates pl_product_info_display.php查找
if ($products_discount_type != 0) {
修改为
if ($products_discount_type != 0 || $categories_discount_type != 0) {