Advertisement
Guest User

MPQ Install

a guest
Jan 28th, 2012
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.50 KB | None | 0 0
  1. # Minimum Product Quantity with Admin v1.5
  2.  
  3.  
  4. # A little history on this contrib:
  5. - it is based heavily on "Min Order Quantity" By Dave Latham
  6. (http://www.oscommerce.com/community/contributions,2198)
  7.  
  8. - improvement by Mark Rickert
  9. mjar81[a]gmail.com
  10. http://www.markrickert.net
  11. Contribution located at: http://www.oscommerce.com/community/contributions,2953
  12. This contrib improves on Dave Latham's version by allowing you to specify a minimum value for each product.
  13. There is an admin interface where you can turn on or off the features of this contrib.
  14. Product minimums are displayed on the product_info page right under the model number.
  15.  
  16. - improvement by many contributors,
  17. like Gidgidonihah who released the version 1.4
  18.  
  19. - (version 1.5) improvement by Piero Trono (tropic)
  20. (contact: http://php-multishop.com/contact.htm)
  21. In the version 1.5 I added the capability to specify the order in which to display the
  22. "MQP column" in the products listing page (index.php file).
  23.  
  24.  
  25. # Changes:
  26. 1.5
  27. the changes of this version are the steps 12-19
  28.  
  29. ...
  30.  
  31. 1.2
  32. Changed - minorder is not stored in the "products" table since there was virtually no need
  33. to have a different product minimum for each language... if you want this feature,
  34. use ver. 1.1.
  35. 1.1
  36. Added - Ability to manage each individual product's minimum level via admin catalog feature.
  37. Added - Country/Language specific data is retained when using admin interface.
  38. Added - Comments to differentiate my code from original code.
  39.  
  40.  
  41. # INSTALLATION
  42. ________________________________________________________________________________________________
  43. STEP 1:
  44. _____________________________________________________________________________________________________
  45. In ./catalog/shopping_cart.php around line 144
  46.  
  47. after this:
  48.  
  49. while (list($option, $value) = each($products[$i]['attributes'])) {
  50. $products_name .= '<br><small><i> - ' . $products[$i][$option]['products_options_name'] . ' ' . $products[$i][$option]['products_options_values_name'] . '</i></small>';
  51. }
  52. }
  53. $products_name .= '</td>' .
  54. '</tr>' .
  55. '</table>';
  56.  
  57. insert this:
  58.  
  59. //Minimum quantity code
  60. if(MINIMUM_ORDERS == 'true'){
  61. $min_order_query = tep_db_query("select p.minorder as min_quant FROM " . TABLE_PRODUCTS . " p where p.products_id = '".$products[$i]['id']."'");
  62. while ($min_order = tep_db_fetch_array($min_order_query)) {
  63. if ($products[$i]['quantity'] < $min_order['min_quant'] ) {
  64. $products[$i]['min_quant']=$min_order['min_quant'];
  65. }
  66. }
  67.  
  68. if ($products[$i]['quantity'] < $products[$i]['min_quant'] ) {
  69. $products[$i]['quantity']=$products[$i]['min_quant'];
  70. $cart->add_cart($products[$i]['id'],$products[$i]['quantity'],$products[$i]['attributes']);
  71. $cart_notice = sprintf(MINIMUM_ORDER_NOTICE, $products[$i]["name"], $products[$i]["min_quant"]);
  72. }
  73. }
  74. //End Minimum quantity code
  75.  
  76. _____________________________________________________________________________________________________
  77. STEP 2:
  78. _____________________________________________________________________________________________________
  79. In ./catalog/shopping_cart.php around line 174
  80.  
  81. after this:
  82.  
  83. <td class="stockWarning" align="center"><br><?php echo OUT_OF_STOCK_CANT_CHECKOUT; ?></td>
  84. </tr>
  85. <?php
  86. }
  87. }
  88.  
  89. insert this:
  90.  
  91. //Minimum quantity code
  92. if ($cart_notice) {
  93. ?>
  94. <tr>
  95. <td class="stockWarning" align="center"><br><?php echo $cart_notice; ?></td>
  96. </tr>
  97. <?php
  98. }
  99. //End Minimum quantity code
  100.  
  101. _____________________________________________________________________________________________________
  102. STEP 3:
  103. _____________________________________________________________________________________________________
  104. in product_info.php
  105.  
  106. find:
  107. $product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");
  108. add:
  109. p.minorder to the field list
  110. or just replace with this:
  111. //Minimum quantity code
  112. $product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id, p.minorder from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");
  113.  
  114. _____________________________________________________________________________________________________
  115. STEP 4:
  116. _____________________________________________________________________________________________________
  117. in product_info.php
  118.  
  119.  
  120. find:
  121. if (tep_not_null($product_info['products_model'])) {
  122. $products_name = $product_info['products_name'] . '<br><span class="smallText">[' . $product_info['products_model'] . ']</span>';
  123. } else {
  124. $products_name = $product_info['products_name'];
  125. }
  126.  
  127. and insert after it:
  128. //Minimum quantity code
  129. if (tep_not_null($product_info['minorder']) && MINIMUM_ORDERS == 'true') {
  130. $products_name .= '<br><span class="smallText">Minimum order: ' . $product_info['minorder'] . '</span>';
  131. }
  132. //End: Minimum quantity code
  133.  
  134. _____________________________________________________________________________________________________
  135. STEP 5:
  136. _____________________________________________________________________________________________________
  137.  
  138. Run this SQL query on your database:
  139.  
  140. INSERT INTO `configuration` (`configuration_id` , `configuration_title` , `configuration_key` , `configuration_value` , `configuration_description` , `configuration_group_id` , `sort_order` , `last_modified` , `date_added` , `use_function` , `set_function`)
  141. VALUES ('', 'Minimum Orders', 'MINIMUM_ORDERS', 'true', 'Whether or not to enforce minimum orders', '1', '19', NOW( ) , NOW( ) , NULL , NULL);
  142.  
  143. _____________________________________________________________________________________________________
  144. STEP 6:
  145. _____________________________________________________________________________________________________
  146.  
  147. Run this SQL query to modify your "products description" table:
  148.  
  149. ALTER TABLE `products` ADD `minorder` INT( 4 ) DEFAULT '1' NOT NULL ;
  150. _____________________________________________________________________________________________________
  151. STEP 7:
  152. _____________________________________________________________________________________________________
  153.  
  154. Populate the minorder field in your products_description table.
  155. *note* that the table automatically sets all minorder's to one (1).
  156. Or continue to be able to do it via Admin interface.
  157.  
  158. _____________________________________________________________________________________________________
  159. STEP 8:
  160. _____________________________________________________________________________________________________
  161.  
  162. You can turn this feature on and off in the admin panel under Configuration:My Store:Minimum Orders
  163.  
  164.  
  165. *****************************************************************************************************
  166. If you want, you can stop here, but continue if you want to be able to change the values via the
  167. admin page.
  168. *****************************************************************************************************
  169. _____________________________________________________________________________________________________
  170. STEP 9: Define languages for admin web interface
  171. _____________________________________________________________________________________________________
  172.  
  173. insert into all language files ./admin/includes/languages/$language/categories.php
  174.  
  175. //Minimum quantity code
  176. define('TEXT_PRODUCTS_MINIMUM','Minimum per order:');
  177. //End: Minimum quantity code
  178.  
  179. (or correct translation)
  180. (use babelfish.altavista.com)
  181.  
  182. _____________________________________________________________________________________________________
  183. STEP 10: (this part is pretty intense... follow c.a.r.e.f.u.l.l.y.)
  184. _____________________________________________________________________________________________________
  185. in ./admin/categories.php
  186.  
  187. Find: (around line 220)
  188. 'manufacturers_id' => tep_db_prepare_input($HTTP_POST_VARS['manufacturers_id']));
  189.  
  190. and insert BEFORE it:
  191. 'minorder' => tep_db_prepare_input($HTTP_POST_VARS['minorder']),
  192.  
  193. Find: (about line 375)
  194. 'manufacturers_id' => '');
  195. Insert BEFORE it:
  196. //Minimum quantity code
  197. 'minorder' => '',
  198. //End: Minimum quantity code
  199.  
  200. Find: (about line 381)
  201. $product_query = tep_db_query("select pd.products_name, pd.products_description, pd.products_url, p.products_id, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_date_added, p.products_last_modified, date_format(p.products_date_available, '%Y-%m-%d') as products_date_available, p.products_status, p.products_tax_class_id, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'");
  202. REPLACE WITH:
  203. //Minimum quantity code
  204. $product_query = tep_db_query("select pd.products_name, pd.products_description, pd.products_url, p.products_id, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_date_added, p.products_last_modified, date_format(p.products_date_available, '%Y-%m-%d') as products_date_available, p.products_status, p.products_tax_class_id, p.manufacturers_id, p.minorder from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'");
  205. //End Minimum quantity code
  206.  
  207. Find: (about line 587)
  208. <tr>
  209. <td class="main"><?php echo TEXT_PRODUCTS_QUANTITY; ?></td>
  210. <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . tep_draw_input_field('products_quantity', $pInfo->products_quantity); ?></td>
  211. </tr>
  212. Insert AFTER it:
  213. <tr>
  214. <td class="main"><?php echo TEXT_PRODUCTS_MINIMUM; ?></td>
  215. <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . tep_draw_input_field('minorder', $pInfo->minorder); ?></td>
  216. </tr>
  217.  
  218.  
  219. Find: (about line 612)
  220. $product_query = tep_db_query("select p.products_id, pd.language_id, pd.products_name, pd.products_description, pd.products_url, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "'");
  221. REPLACE WITH:
  222. //Minimum quantity code
  223. $product_query = tep_db_query("select p.products_id, pd.language_id, pd.products_name, pd.products_description, pd.products_url, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.manufacturers_id, p.minorder from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "'");
  224. //End: Minimum quantity code
  225.  
  226. Find: (about line 818)
  227. $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p2c.categories_id, from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and pd.products_name like '%" . tep_db_input($search) . "%' order by pd.products_name");
  228. REPLACE WITH:
  229. //Minimum quantity code
  230. $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p2c.categories_id, p.minorder from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and pd.products_name like '%" . tep_db_input($search) . "%' order by pd.products_name");
  231. //End: Minimum quantity code
  232.  
  233. Find: (about line 820)
  234. $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$current_category_id . "' order by pd.products_name");
  235. REPLACE WITH:
  236. //Minimum quantity code
  237. $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.minorder from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$current_category_id . "' order by pd.products_name");
  238. //End Minimum quantity code
  239.  
  240. _____________________________________________________________________________________________________
  241. STEP 11:
  242. _____________________________________________________________________________________________________
  243.  
  244. In includes/languages/english/shopping_cart.php before the ?> add
  245.  
  246. define('MINIMUM_ORDER_NOTICE', "Minimum order amount for %s is %d. Your cart has been updated to reflect this.");
  247.  
  248. _____________________________________________________________________________________________________
  249. STEP 12 (v.1.5):
  250. _____________________________________________________________________________________________________
  251.  
  252. Run this SQL query on your database:
  253.  
  254. INSERT INTO `configuration` (`configuration_id` , `configuration_title` , `configuration_key` , `configuration_value` , `configuration_description` , `configuration_group_id` , `sort_order` , `last_modified` , `date_added` , `use_function` , `set_function`)
  255. VALUES ('', 'Minimum Product Quantity', 'PRODUCT_LIST_MINORDER', '6', 'Do you want to display the Minimum Product Quantity?', '8', '11', NOW( ) , NOW( ) , NULL , NULL);
  256.  
  257. _____________________________________________________________________________________________________
  258. STEP 13:
  259. _____________________________________________________________________________________________________
  260. In ./catalog/index.php around line 133
  261.  
  262. after this:
  263. 'PRODUCT_LIST_QUANTITY' => PRODUCT_LIST_QUANTITY,
  264.  
  265. add this:
  266. //Minimum quantity code
  267. 'PRODUCT_LIST_MINORDER' => PRODUCT_LIST_MINORDER,
  268. //End: Minimum quantity code
  269.  
  270. _____________________________________________________________________________________________________
  271. STEP 14:
  272. _____________________________________________________________________________________________________
  273. In ./catalog/index.php around line 164
  274.  
  275. after this:
  276. case 'PRODUCT_LIST_QUANTITY':
  277. $select_column_list .= 'p.products_quantity, ';
  278. break;
  279.  
  280. add this:
  281. //Minimum quantity code
  282. case 'PRODUCT_LIST_MINORDER':
  283. $select_column_list .= 'p.minorder, ';
  284. break;
  285. //End: Minimum quantity code
  286.  
  287. _____________________________________________________________________________________________
  288. STEP 15:
  289. _____________________________________________________________________________________________________
  290. In ./catalog/index.php around line 223
  291.  
  292. after this:
  293. case 'PRODUCT_LIST_QUANTITY':
  294. $listing_sql .= "p.products_quantity " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
  295. break;
  296.  
  297. add this:
  298. //Minimum quantity code
  299. case 'PRODUCT_LIST_MINORDER':
  300. $listing_sql .= "p.minorder " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
  301. break;
  302. //End: Minimum quantity code
  303.  
  304. ________________________________________________________________________________
  305. STEP 16:
  306. _____________________________________________________________________________________________________
  307. In ./catalog/includes/modules/product_listing.php around line 50
  308.  
  309. after this:
  310. case 'PRODUCT_LIST_QUANTITY':
  311. $lc_text = TABLE_HEADING_QUANTITY;
  312. $lc_align = 'right';
  313. break;
  314.  
  315. add this:
  316. //Minimum quantity code
  317. case 'PRODUCT_LIST_MINORDER':
  318. $lc_text = TABLE_HEADING_MINORDER;
  319. $lc_align = 'right';
  320. break;
  321. //End Minimum quantity code
  322.  
  323. ________________________________________________________________________________
  324. STEP 17:
  325. _____________________________________________________________________________________________________
  326. In ./catalog/includes/modules/product_listing.php around line 125
  327.  
  328. after this:
  329. case 'PRODUCT_LIST_QUANTITY':
  330. $lc_align = 'right';
  331. $lc_text = '&nbsp;' . $listing['products_quantity'] . '&nbsp;';
  332. break;
  333.  
  334. add this:
  335. //Minimum quantity code
  336. case 'PRODUCT_LIST_MINORDER':
  337. $lc_align = 'right';
  338. $lc_text = '&nbsp;' . $listing['minorder'] . '&nbsp;';
  339. break;
  340. //End Minimum quantity code
  341.  
  342. _____________________________________________________________________________________________________
  343. STEP 18:
  344. _____________________________________________________________________________________________________
  345. In ./catalog/includes/languages/$language/index.php
  346. before the ?> add
  347.  
  348. //Minimum quantity code
  349. define('TABLE_HEADING_MINORDER', 'Minimum order q.ty');
  350. //End Minimum quantity code
  351.  
  352. _____________________________________________________________________________________________________
  353. STEP 19:
  354. _____________________________________________________________________________________________________
  355.  
  356. You can turn On/Off or change the order in which to display the MPQ column in the index.php file,
  357. through the admin panel under the path:
  358. Configuration: Product Listing: Minimum Product Quantity
  359. The values allowed are:
  360. 0: hide the MPQ column
  361. x: display the column in the x position
  362.  
  363. _____________________________________________________________________________________________________
  364. THAT'S IT!
  365. _____________________________________________________________________________________________________
  366.  
  367. We hope you like it!
  368.  
  369. Thanks for all the great support of this community and this awesome program!
  370.  
  371. Thanks to all the previous (an future) contributors,
  372. Piero Trono
  373. (http://php-multishop.com)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement