This add-on is based on a Zen Cart contribution by dafonz (products_with_attributes_stock), which was adapted by danielcor for Zen Cart 1.3 and further adapted by kuroi for 1.3.5+.
NOTE: This is a simple modification to version 4.7 that allow multiple attribute combinations to be added at the same time.
This current version (4.7a) is designed specifically to work correctly in version 1.3.8 of Zen Cart and is unlikely to work with earlier versions. If you are running Zen Cart 1.2.5-1.2.7d, please use the "products_with_attributes_stock" add-on by dafonz. If you are using versions 1.3.0 - 1.3.0.2 please use "Stock Attributes by danielcor". If you are using version 1.3.5, please use version 4.2 of this mod, for 1.3.6 use version 4.3 of this mod. Versions 4.4, 4.5 and 4.6 should be compatible with versions 1.3.7 and 1.3.7.1 of Zen Cart (though obviously the latter versions of Zen Cart and this add-on are recommended).
This add-on allows a store owner to set a stock value for each variant of a product. For example, if you have three sizes, large, medium and small, this module will allow you to keep track of all the different quantities. It will work for a virtually unlimited number of amount of attribute combinations. For example, if you offered cotton or polyester shirts in green, red or blue and small medium or large sizes, this add-on would allow you to enter and maintain a separate stock level for each of the 18 possible combinations.
Previous versions of the module insisted that once installed you maintained stock at attribute level for products with attributes (otherwise the products would be treated as being out of stock). This version (4.6) gives you the choice of managing stock at a product or an attribute level on a product-by-product basis.
If you enter stock for any combination of product attributes (product variants), stock calculations will done using attribute level data. Any attributions that have not been set up will be treated as having zero stock. However, if you have no product variants set up, or delete them all, stock for that product will be calculated based on its overall product quantity.
Create a new database table and a new configuration switch by running the 'stock_attribute.sql'
via Admin->Tools->Install SQL Patches. If you prefer to use another method to create this table, you will need to edit the file if you use a prefix such as "zen_" for your tables.
Prepare the package for upload to your server by renaming the following folders to match your template name: includes/modules/YOUR_TEMPLATE and includes/templates/YOUR_TEMPLATE.
If you are installing onto a new install or upgrade of Zen Cart 1.3.5 or later then with most good FTP programs (such as FileZilla) you can simply drag and drop the admin and includes directories into the root directory of your site. The files are already arranged in their directory structure.
There are six core Zen Cart files modified by this add-on. If you have installed other add-ons or customised your cart since your Zen Cart installation or upgrade, you will need to check whether they have changed any of the following files:
In addition, one file is over-ridden
If you, or any mods that you have installed, have changed any of these files (or over-ridden the last one), then you will need to merge the any changes into the relevant file.
To upgrade from any version 4.x to 4.7a, it is easiest to overwrite all the files. No changes are needed to your database. If you are upgrading from version 4.0 - 4.4 you should also delete the following file To upgrade from versions 4.0 - 4.4, it is easiest to overwrite all the files and then delete the following file (unless you have made other changes to it):
To use, log into the admin area, click on Catalog->Products with Attributes Stock to modify inventory levels of your products by attributes. You will also want to consider the settings in Configuration->Stock. The settings here will determine things such as whether or not a customer will be allowed to checkout when insufficient stock is on hand. As well as controlling the new feature that allows you display the amount of stock available on the shopping cart page if a customer tries to buy more than the recorded stock.
Many of the changes made to this add-on from its previous incarnation were to support proper language support in the Admin functions and an additional "stock available + quantity" message in the shopping cart. To take advantage of these facilities three files need to be created. As a guide, I have included my translations of these files into French in the release pack. If you are using a language other than French, edit the directory paths from "french" to your language and similarly edit the three files.
1. Removed zen_ prefix from table creation SQL allowing it to be run by Admin > Tools > Install SQL Patches (bug fix)
2. Changed quantity field to float in products with attributes table allowing fractional stock quantities (bug fix)
3. admin/orders.php updated for compatibility with Zen Cart 1.3.5
4. admin/products_with_attributes_stock.php updated to pass a languages_id to functions get_products_attributes and get_attributes_name each time they are called (bug fix)
5. includes/functions/functions_lookups.php updated for compatibility with Zen Cart 1.3.5
6. products_with_attributes_catalog_dhtml.php file created so that catalog_dhtml.php no longer needs to be over-written (new feature)
7. Language file for Admin is now used, which together with earlier bug fix should allow full integration with carts whose Admin is not in English (new feature)
8. Multiple changes to allow all data and add-on generated text to correctly reflect Admin language.
9. Re-enabled check stock and disable checkout feature for all products (bug fix)
10. Fixed "Out of Stock" indicators in Shopping Cart for products with attributes (bug fix)
11. Added "Stock Available" to shopping cart page for display when stock is low. This can be turned on and off via the Admin > Stock menu (new feature)
12. Low stock email now triggered by low stock on an attribute, even if overall stock for product remains above stock reorder level (new feature)
13. Removed all uses of the <? shortform php tag (best practice)
14. Moved the inline styling on the Products with Attributes Stock page to a stylesheet (best practice)
15. Added model to Products with Attributes Stock page (new feature)
16. Fixed occasional corruption of product variants on stock page (bug fix)
Incorporated two Zen Cart bug fixes in the files used by this mod.
Corrected a missing double quote in the SQL patch file
Removed a stray diagnostic line
Corrected the "invalid argument supplied for foreach()" in order.php
Corrected the problem with product variants sometimes not showing on the stock screen (actually a database corruption)
Improved the layout of the stock page by adding some extra CSS.
To upgrade from 4.1, just replace all the files.
Multiple small changes in accordance with the security patches incorporated in Zen Cart 1.3.6
Minor change to define statements to eliminate a hard-coded English-language "Quantity" missed in previous releases.
To upgrade from 4.1 or 4.2, just replace all the files.
Minor changes to the following files to keep them in line with the new functionality in Zen Cart 1.3.7 and avoid a duplicate include of the http_client class:
To upgrade from 4.1 or 4.2, just replace all the files To upgrade from 4.3, replace the three files above.
Two Zen Cart security patches from 1.3.7.1:
A minor change to make the HTML generated for orders easier to read. This is a Zen Cart 1.3.7.1 change that will make debugging and maintenance easier, but not affect functionality:
Allowance for recent Zen Cart changes for paypal in the shopping cart:
Removes the attributes.php file from the includes folder. The only thing that this file was doing was blocking a small Zen Cart enhancement introduced in version 1.3.5.
Additional styling for the input labels in the Admin - just makes the world a slightly nicer place:
Slight change to the low stock message switch wording to make clear that this for showing stock levels in cart when there is insufficent to meet the customer's order
Re-working (and commenting) of the function that obtains stock values
Integration of changes in Zen Cart 1.3.8 into the following files:
There are no functional enhancements.
Zen Cart Open Source E-commerce - Stock by Attributes
Copyright (c) 2006-2007 kuroi Ltd (www.kuroiwebdesign.com)
Portions Copyright (c) 2005 dafonz, 2006 danielcor
Portions Copyright (c) 2003 osCommerce, 2003-2007 Zen Cart
This contribution is subject to version 2.0 of the GPL license, that is bundled with this package in the file LICENSE, and is available through the world-wide-web at the following url: http://www.zen-cart.com/license/2_0.txt. If you did not receive a copy of the Zen Cart license and are unable to obtain it through the world-wide-web, please send a note to license@zen-cart.com.