Guest Posted June 15, 2011 Share Posted June 15, 2011 Since Im new to the forum I would like to say "Hello" to everyone. Normally Im not much of a forum Troll and certainly dont like having to go here to ask for help. But theres a first for everything. For the pas weeks Ive been living in the OScommerce PHP code. Making tweaks and edits to get it everything configured as I see fit. However, I got one last thing on my list and I just cant seem to figure it out. Im trying to edit prices for products of certain categories on certain days. The concept is "Tuesday + Wednesday = Pizza day" and all pizzas go for € 5.99 instead of their usual prices. At first I was trying to directly edit the displayed prices using the following codes (or equivalent) in various files. if ($producs_cat == "42" && date("l")=="Wednesday" || $producs_cat == "42" && date("l")=="Tuesday" ) { $products_price2 = $product['products_price']; $products_price = $products_price2-$products_price2+5.99; } elseif ($producs_cat == "41" && date("l")=="Wednesday" || $producs_cat == "41" && date("l")=="Tuesday" ) { $products_price2 = $product['products_price']; $products_price = $products_price2-$products_price2+3.99; } else { $products_price = $products[$i]['final_price']; } All looked good and the prices of these cats/prods displayed with their discount. However when I continued to my "checkout_confirmation.php" page the order total module counts and displays the normal prices. Where does order_total pull the price from? Ive been digging trough the order_total module but just cant seem to figure it out. When I couldnt get it to work using this method, I tried downloading several discount modules (Easydiscount ea.) and had them deduct the difference in prices. For some reason I cant get that to work either. Im not looking for a ready to go solution (even tho if someone has one it would be nice ofc.), but a push in the right direction would be much appreciated. Please note that Im not a PHP programmer, but only have some basic skills. Thanks in advanced, Erwin Link to comment Share on other sites More sharing options...
KDM Posted June 16, 2011 Share Posted June 16, 2011 Oscommerce is database driven which means that pretty much all data (from products, customers, orders etc) is found in it. I haven't checked for a while but I believe you are right about the discount contributions. What you need is something that will set the special pricing regularly each week. I tweaked the specials.php to handle a start and end date for my specials. You need to go a step further which would be to set a new field or two inside of the specials file to handle the day of week. Then when that day comes around it could automatically enable your sell as well as disable the sell when the time period is over. You can look at my contribution and see if you could modify it to work for you. Here it is: Specials Maintenance - Administration Good Luck! Link to comment Share on other sites More sharing options...
Guest Posted June 16, 2011 Share Posted June 16, 2011 Thanks for the tip, I'll give it a try. Link to comment Share on other sites More sharing options...
Guest Posted June 16, 2011 Share Posted June 16, 2011 KDM, after installing you module by following the attached instructions, Im getting the following error. Fatal error: Call to undefined function gfc_base_filename() in /catalog/admin/includes/application_top.php on line 40 I cant find this function defined anywhere. Am I missing something? Link to comment Share on other sites More sharing options...
KDM Posted June 16, 2011 Share Posted June 16, 2011 This is my mistake. in /catalog/admin/includes/application_top.php FIND: // set php_self in the local scope $PHP_SELF = gfc_base_filename(); // $PHP_SELF = (isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']); REPLACE WITH: // set php_self in the local scope $PHP_SELF = (isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']); The gfc_base_filename is something I use in another program. I will move that out of the contribution. Thanks For future questions would you use: Specials Maintenance - Administration support thread Link to comment Share on other sites More sharing options...
Guest Posted June 18, 2011 Share Posted June 18, 2011 This problem has been solved with the help of KDM. For the archive: Using the contrib KDM mentioned above, I added 2 fields to the special table in the DB. ALTER TABLE `specials` ADD `specials_day` TINYINT( 1 ) NOT NULL DEFAULT '0'; ALTER TABLE `specials` ADD `specials_day2` TINYINT( 1 ) NOT NULL DEFAULT '0'; These collums represent the day of the week, in my case I needed 2 (tuesday + wednessday). Then edited the following files catalog/includes/functions/specials_maintenance.php and catalog/admin/includes/functions/specials_maintenance.php in both functions: gfc_expire_specials() and gfc_start_specials() function gfc_expire_specials() { // BOF kdm added limit_specials_quantity field to check against products_quantity // to limit the number of items that can be sold for special price // (ex: if you have products_quantity of 8 and limit_specials_quantity of 5 you could only sell 3 at special price) $current = gfc_current_date(true); $day = date("w"); $specials_query = tep_db_query("select s.specials_id from " . TABLE_SPECIALS . " s left join " . TABLE_PRODUCTS . " p on (s.products_id=p.products_id) where (s.status='1' and '".$current."'< s.start_date and s.start_date>0) or (s.status='1' and '".$current."'>= s.expires_date and s.expires_date>0) or (s.status='1' and s.limit_specials_quantity>=p.products_quantity) or (s.status='1' and p.products_quantity=0) or ('".$day."' != s.specials_day)"); if (tep_db_num_rows($specials_query)) { while ($specials = tep_db_fetch_array($specials_query)) { gfc_set_specials_status($specials['specials_id'], '0'); } } } function gfc_start_specials() { // BOF kdm added start_date field to pre set productc for specials // this will not activate special if no start date is given as store manager may have not decided on start date // which means he will have to enter a future start date or self activate from admin side? $day = date("w"); $current = gfc_current_date(true); $specials_query = tep_db_query("select s.specials_id from " . TABLE_SPECIALS . " s left join " . TABLE_PRODUCTS . " p on (s.products_id=p.products_id) where (s.status='0' and '".$day."' = s.specials_day)"); if (tep_db_num_rows($specials_query)) { while ($specials = tep_db_fetch_array($specials_query)) { gfc_set_specials_status($specials['specials_id'], '1'); } } } Last I defined my specials in the admin panel > catalog > Specials Maintenance. Kudo's to KDM, for his swift support. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.