商品批发增加起订数功能,设置购买数量(v2.6.2 默认模板)

2016-07-07 14:55 来源:www.chinab4c.com 作者:ecshop专家

1.在ECS_goods数据表中新增最小购买数量字段min_number
  1. alter table `ecs_goods` add column `min_number` tinyint (3) UNSIGNEDDEFAULT '0' NOT NULLafter `warn_number`
复制代码

2.修改admin/goods.php

  1. 'warn_number'=> 1,
  2. 代码行后插入
  3. 'min_number' => 0,
复制代码



  1. $warn_number = isset($_POST['warn_number']) ? $_POST['warn_number'] : 0;
  2. 代码行后插入
  3. $min_number = isset($_POST['min_number']) ? $_POST['min_number'] : 0;
复制代码




  1. /* 入库 */
  2. if ($is_insert)
  3. {
  4. if ($code == '')
  5. {
  6. ....由于发帖篇幅的限制省略原有代码无数
  7. }
  8. else
  9. {
  10. ......
  11. }
  12. }
  13. else
  14. {
  15. /* 如果有上传图片,删除原来的商品图 */
  16. .....
  17. }
复制代码

修改成

  1. /* 入库 */
  2. if ($is_insert)
  3. {
  4. if ($code == '')
  5. {
  6. $sql = "INSERT INTO " . $ecs->table('goods') . " (goods_name, goods_name_style, goods_sn, " .
  7. "cat_id, brand_id, shop_price, market_price, is_promote, promote_price, " .
  8. "promote_start_date, promote_end_date, goods_img, goods_thumb, original_img, keywords, goods_brief, " .
  9. "seller_note, goods_weight, goods_number, warn_number,min_number, integral, give_integral, is_best, is_new, is_hot, " .
  10. "is_on_sale, is_alone_sale, goods_desc, add_time, last_update, goods_type, rank_integral)" .
  11. "VALUES ('$_POST[goods_name]', '$goods_name_style', '$goods_sn', '$catgory_id', " .
  12. "'$brand_id', '$shop_price', '$market_price', '$is_promote','$promote_price', ".
  13. "'$promote_start_date', '$promote_end_date', '$goods_img', '$goods_thumb', '$original_img', ".
  14. "'$_POST[keywords]', '$_POST[goods_brief]', '$_POST[seller_note]', '$goods_weight', '$goods_number',".
  15. " '$warn_number','$min_number', '$_POST[integral]', '$give_integral', '$is_best', '$is_new', '$is_hot', '$is_on_sale', '$is_alone_sale', ".
  16. " '$_POST[goods_desc]', '" . gmtime() . "', '". gmtime() ."', '$goods_type', '$rank_integral')";
  17. }
  18. else
  19. {
  20. $sql = "INSERT INTO " . $ecs->table('goods') . " (goods_name, goods_name_style, goods_sn, " .
  21. "cat_id, brand_id, shop_price, market_price, is_promote, promote_price, " .
  22. "promote_start_date, promote_end_date, goods_img, goods_thumb, original_img, keywords, goods_brief, " .
  23. "seller_note, goods_weight, goods_number, warn_number, min_number,integral, give_integral, is_best, is_new, is_hot, is_real, " .
  24. "is_on_sale, is_alone_sale, goods_desc, add_time, last_update, goods_type, extension_code, rank_integral)" .
  25. "VALUES ('$_POST[goods_name]', '$goods_name_style', '$goods_sn', '$catgory_id', " .
  26. "'$brand_id', '$shop_price', '$market_price', '$is_promote','$promote_price', ".
  27. "'$promote_start_date', '$promote_end_date', '$goods_img', '$goods_thumb', '$original_img', ".
  28. "'$_POST[keywords]', '$_POST[goods_brief]', '$_POST[seller_note]', '$goods_weight', '$goods_number',".
  29. " '$warn_number','$min_number', '$_POST[integral]', '$give_integral', '$is_best', '$is_new', '$is_hot', 0, '$is_on_sale', '$is_alone_sale', ".
  30. " '$_POST[goods_desc]', '" . gmtime() . "', '". gmtime() ."', '$goods_type', '$code', '$rank_integral')";
  31. }
  32. }
  33. else
  34. {
  35. /* 如果有上传图片,删除原来的商品图 */
  36. $sql = "SELECT goods_thumb, goods_img, original_img " .
  37. " FROM " . $ecs->table('goods') .
  38. " WHERE goods_id = '$_REQUEST[goods_id]'";
  39. $row = $db->getRow($sql);
  40. if ($proc_thumb && $goods_img && $row['goods_img'] && !goods_parse_url($row['goods_img']))
  41. {
  42. @unlink(ROOT_PATH . $row['goods_img']);
  43. @unlink(ROOT_PATH . $row['original_img']);
  44. }
  45. if ($proc_thumb && $goods_thumb && $row['goods_thumb'] && !goods_parse_url($row['goods_thumb']))
  46. {
  47. @unlink(ROOT_PATH . $row['goods_thumb']);
  48. }
  49. $sql = "UPDATE " . $ecs->table('goods') . " SET " .
  50. "goods_name = '$_POST[goods_name]', " .
  51. "goods_name_style = '$goods_name_style', " .
  52. "goods_sn = '$goods_sn', " .
  53. "cat_id = '$catgory_id', " .
  54. "brand_id = '$brand_id', " .
  55. "shop_price = '$shop_price', " .
  56. "market_price = '$market_price', " .
  57. "is_promote = '$is_promote', " .
  58. "promote_price = '$promote_price', " .
  59. "promote_start_date = '$promote_start_date', " .
  60. "promote_end_date = '$promote_end_date', ";
  61. /* 如果有上传图片,需要更新数据库 */
  62. if ($goods_img)
  63. {
  64. $sql .= "goods_img = '$goods_img', original_img = '$original_img', ";
  65. }
  66. if ($goods_thumb)
  67. {
  68. $sql .= "goods_thumb = '$goods_thumb', ";
  69. }
  70. if ($code != '')
  71. {
  72. $sql .= "is_real=0, extension_code='$code', ";
  73. }
  74. $sql .= "keywords = '$_POST[keywords]', " .
  75. "goods_brief = '$_POST[goods_brief]', " .
  76. "seller_note = '$_POST[seller_note]', " .
  77. "goods_weight = '$goods_weight'," .
  78. "goods_number = '$goods_number', " .
  79. "warn_number = '$warn_number', " .
  80. "min_number = '$min_number', " .
  81. "integral = '$_POST[integral]', " .
  82. "give_integral = '$give_integral', " .
  83. "rank_integral = '$rank_integral', " .
  84. "is_best = '$is_best', " .
  85. "is_new = '$is_new', " .
  86. "is_hot = '$is_hot', " .
  87. "is_on_sale = '$is_on_sale', " .
  88. "is_alone_sale = '$is_alone_sale', " .
  89. "goods_desc = '$_POST[goods_desc]', " .
  90. "last_update = '". gmtime() ."', ".
  91. "goods_type = '$goods_type' " .
  92. "WHERE goods_id = '$_REQUEST[goods_id]' LIMIT 1";
  93. }
复制代码

3.修改admin/templates/goods_info.htm

  1. <!--商品优惠价格 end -->
  2. <tr>
  3. <td class="label">{$lang.lab_market_price}</td>
  4. <td><input type="text" name="market_price" value="{$goods.market_price}" size="20" />
  5. <input type="button" value="{$lang.integral_market_price}" onclick="integral_market_price()" />
  6. </td>
  7. </tr>
  8. 之后新增插入
  9. <!--新增 批发数量限制 begin -->
  10. <tr>
  11. <td class="label">{$lang.lab_min_number}</td>
  12. <td><input type="text" name="min_number" value="{$goods.min_number}" size="20" />
  13. <br /><span class="notice-span" {if $help_open}style="display:block" {else} style="display:none" {/if} id="minNumber">{$lang.notice_min_number}</span></td>
  14. </td>
  15. </tr>
  16. <!-- 批发数量限制 end -->
复制代码

4.修改languages/zh_cn/admin/goods.php
  1. 在文件最后新增
  2. /* 新增 */
  3. $_LANG['lab_min_number']= '最小购买数量:';
  4. $_LANG['notice_min_number']= '该商品最小购买数量,0表示按购买数量无限制.';
复制代码

5.修改themes/default/goods.dwt

  1. <input name="number" type="text" id="number" value="1" size="4" onblur="changePrice()" style="border:1px solid #ccc; "/>
  2. 修改成
  3. <input name="number" type="text" id="number" value="{$goods.min_number|default:"1"}" size="4" onblur="changePrice()" style="border:1px solid #ccc; "/>
复制代码


  1. var qty = document.forms['ECS_FORMBUY'].elements['number'].value;
  2. 之后添加
  3. <!-- {if $goods.min_number} -->
  4. if (qty < {$goods.min_number})
  5. {
  6. alert('您输入的数字小于此商品最小购买数量:{$goods.min_number}');
  7. qty = {$goods.min_number};
  8. }
  9. <!-- {/if} -->
复制代码

6.效果如图所示
后台图片
前台显示页面:
7.功能不完善之处请多多包涵。

回答:
不错的功能

好东西,收藏了

先收藏了,再慢慢改

很不错大礼收下了

谢谢共享,这个必须收藏的

收藏了楼主共享精神可嘉!

很好,很强大

比较实用,谢谢共享

学习了 :)



有一個bug
在下訂單後的商品列表也可以改到其他數字

真好!!!谢谢!!

有人會改了BUG嗎?

在下訂單後有一個bug,商品列表可以改到其他數字
有人會改嗎?