Contributions
Multiple Sales Per Product
Our store often sets up sale prices several months in advance due to the lead time for the magazines in which we advertise. Many times the same products are repeated from ad to ad but the sale price changes. Since osCommerce as written only allows one sale price per product but has the potential to set more than one since sale prices are in their own file linked to the products I decided to see about writing my own contribution to allow sales to be set in advance and activated automatically at the proper time.
This contribution also allows you to create named sales. The names can be anything you like such as "July Magazine Ad" or "April 15 Newspaper Ad" or "Summer Sale Flyer" or whatever else you like. Each named sale will have its own beginning and ending dates which can overlap if you like. When you create a new sale for a product and associate it with an named sale the product sale will automatically take its beginning and ending dates from the named sale so you won't need to enter those again. On the catalog side specials.php the user will now be able to choose which sale items to view, whether all items on sale, items on sale that aren't associated with a named sale, or only items that are part of a specific named sale.
I’ve modified the stock osCommerce specials maintenance just enough to allow for the new beginning date and named sale features but focused my attention on writing a new sale price entry file that focuses on products. Only those sales for the focal product are listed. You can choose different products using either an advanced search or a drop down list of all products. One button click will return you to category/product maintenance with the current focal product selected. I've also added a button in the product information info box of categories.php to take you directly to sale maintenance for that product. This could make life easier since the stock osCommerce specials maintenance provides no way to search for the sale information for a specific product.
Expand All / Collapse All
The March 3, 2011 revision adds a configuration variable that determines whether you are allowed to create unending sale prices. This will appear under My Store in Configuration. If set to true then the expiration date for the sale can be left blank to create sale prices that never expire. If set to false a valid expiration date will be required in order to create a new sale price or named sale. Note that this only applies when you create or edit a sale, it does NOT have any effect on sale prices that are already stored in the database. All of the PHP files for this contribution have been updated to accommodate this new feature.
The complete contribution is enclosed with update instructions for those who already have installed it. Upgrade basically involves replacing all of the admin side PHP files for the contribution, installing a new configuration variable into the database, and making some minor modifications to one function in admin/includes/functions/general.php to allow for reposting variables.
Corrected the script declaration tags in the utilities from <script language="javascript"> to the proper <script type="text/javascript">.
Complete contribution is attached but only the admin/*.php files have changed.
Fixed a bug related to search keywords in two files. Complete contribution is enclosed but only admin/sale_prices.php and admin/multi_product_sale_prices.php have changed. To update just replace those two files.
The queries have been revised so that products that are not assigned to a manufacturer can be found. It also adds the ability to find products in the subcategories of the category being searched when searching by category in the Multi-Product Sales utility.
Complete install is enclosed but the only revised files are multi_product_sale_prices.php (both of them) and sale_prices.php (just the admin file).
Fixed a bug in the Multi-Product Sale utility that would prevent searching for items in the "TOP" category.
Complete contribution attached but only the admin/multi_product_sale_prices.php file has changed.
Added a new file to this contribution that allows you to set sale prices on multiple items at once. Sale prices can be set as an amount, as a dollar reduction, or as a percentage discount. Products can be found using any combination of keyword, category, manufacturer or regular price. This file also makes use of the named sale feature. You will be presented with a list of matching products showing you the regular price and the new sale price. You can then deselect any unexpected finds that shouldn't be put on sale before committing all of the new sale prices to the database.
All of the other files have been updated slightly as well. Empty dates that designate that a sale has no beginning (or ending) date are now saved as NULL in the database rather than as 0000-00-00 00:00:00. Sale prices are now rounded to the maximum number of decimal places allowed by the default currency to prevent unexpected totals when multiples of a single product are ordered. You may choose the number of decimals of rounding when using sale_prices.php and multi_product_sale_prices.php. (For example: Using US dollars a sale price calculated to be 1.3333 would display as $1.33 in the catalog but add up to $2.67 if two were ordered. You would now round this to the nearest $1.00, $0.10 or $0.01 automatically.)
If updating from an earlier version copy all of the admin and languages files from this version over your older version files and then perform instructions 7, 8 and 9 of the install (noting that only the last line added by each instruction is new).
Fixed a bug in the admin/sale_prices.php file. When editing an existing sale price the current expiration date wasn't loading into the fields due to an incorrect variable reference.
Added a sale prices table to the product info box of admin/categories.php so you can see all sale prices that apply to the currently selected product. Active sale prices are displayed in green and inactive ones in red.
Complete package is attached. If upgrading from the previous version simply replace the sale_prices.php file and follow instructions 11 and 12b. Note that the very first line in instruction 11 existed in the previous version so don't duplicate it or you will create an error.
After adding a step for the catalog/specials.php file to ensure that the correct price was displayed I realized that the query could then be simplified somewhat so it should run a bit faster. Only step 18b of the instructions has changed.
Complete package attached.
I discovered that the specials.php and product_listing.php files were still not always displaying the correct price and so have added a line to the install for each of those two file.
Complete install attached only steps 13 and 18 have changed. If you have already installed this contribution you need only follow steps 13b and 18a to correct the problem.
Fixed a bug in the sale_prices.php file. When searching for a different product if only one match was found it didn't correctly switch to that product. Also fixed finding multiple instances of the same product when products exist in more than one category.
Major changes have been made to the installation instructions for the catalog/index.php, catalog/advanced_search_results.php, catalog/includes/classes/split_page_results.php and catalog/includes/modules/product_listing.php files. As originally written the SQL queries worked fine on our test site with only a few products and sale prices. However on our actual web site with over 11,000 different products and almost 3,600 defined sale prices the queries slowed the web site down tremendously. As originally written the queries sorted the entire list of sale prices every time a category was accessed or a search was made. The rewritten queries in the updated instructions now only sort the matching results and therefore work MUCH faster. If you have already installed this contribution I highly recommend that you change your install using the new instructions.
Added an instruction for those using the Dynamic Sitemaps with XML Sitemaps contribution to correctly generate the XML site map for specials.
Complete package attached. Only the instructions and the admin/sale_prices.php files have changed.
Our store often sets up sale prices several months in advance due to the lead time for the magazines in which we advertise. Many times the same products are repeated from ad to ad but the sale price changes. Since osCommerce as written only allows one sale price per product but has the potential to set more than one since sale prices are in their own file linked to the products I decided to see about writing my own contribution to allow sales to be set in advance and activated automatically at the proper time.
This contribution also allows you to create named sales. The names can be anything you like such as "July Magazine Ad" or "April 15 Newspaper Ad" or "Summer Sale Flyer" or whatever else you like. Each named sale will have its own beginning and ending dates which can overlap if you like. When you create a new sale for a product and associate it with an named sale the product sale will automatically take its beginning and ending dates from the named sale so you won't need to enter those again. On the catalog side specials.php the user will now be able to choose which sale items to view, whether all items on sale, items on sale that aren't associated with a named sale, or only items that are part of a specific named sale.
I’ve modified the stock osCommerce specials maintenance just enough to allow for the new beginning date and named sale features but focused my attention on writing a new sale price entry file that focuses on products. Only those sales for the focal product are listed. You can choose different products using either an advanced search or a drop down list of all products. One button click will return you to category/product maintenance with the current focal product selected. I've also added a button in the product information info box of categories.php to take you directly to sale maintenance for that product. This could make life easier since the stock osCommerce specials maintenance provides no way to search for the sale information for a specific product.
Note: Contributions are used at own risk.