Contributions
Bundled Products
This contribution allows you to create bundles of products:
- a user can buy a bundle of parts that may be priced at something different from the total cost of the parts. The cost saving is shown to the customer on the products_info page.
- The stock of each sub product is updated separately when a sale is made.
- A subproduct that is out of stock will prevent the bundle from selling (if you have set STOCK_ALLOW_CHECKOUT to false in admin)
- bundles are created and edited using the admin system
- bundle "master products" are virtual containers for subproducts, ie the stock is not updated. Otherwise, they are regular products with a description, price and other features.
For an example of how the system works take a look at the longboards at www.lushlongboards.com.
Expand All / Collapse All
The bug fixes by OSSamm have been incorporated into the instruction files and the corresponding PHP files that are included with this contribution.
The complete install is enclosed.
***This is not a full package. ***
This fix should be applied to the latest full package
In Firefox clicking the Add a Line caused the following
Error: uncaught exception: [Exception... "Not enough arguments" nsresult: "0x80570001 (NS_ERROR_XPC_NOT_ENOUGH_ARGS)"
The Fix:
In catalog/admin/categories.php
function addSubproduct(){
currentElement.setAttribute("disabled");
Should read:
currentElement.setAttribute("disabled", "");
**The setAttribute methods takes two parameters
***** This is not a full package ****
The package below has a typo in step 7 and should read as follows:
***FIND:
<td class="main" align="right"><?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?></td>
***CHANGE TO:
<td class="main" align="right"><?php echo tep_draw_hidden_field('products_id', $product_info['products_id']);
if ($product_info['sold_in_bundle_only'] == "yes") {
echo TEXT_BUNDLE_ONLY;
} elseif ((STOCK_CHECK == 'true') && (STOCK_ALLOW_CHECKOUT != 'true') && ($qty < 1)) {
echo tep_image_button('button_out_of_stock.gif', IMAGE_BUTTON_OUT_OF_STOCK);
} else {
echo tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART);
} ?></td>
Updated the instruction file that covers converting bundled products to work with the protected images contribution. I had forgotten to check to make sure the product image was not null.
Complete contribution is enclosed.
Modified database and contribution to allow a product to be marked as only available for sale as part of a bundle. While this could be accomplished by turning the product status red, the customer would then not be able to view the details of the product if they clicked on that product name while viewing the bundle that contains it.
All add to cart buttons are now disabled if the product is sold only in a bundle or if it is out of stock and purchasing of out of stock items is prohibited including the one in products_new that was previously missed by this contribution. Checks have also been added to stop checkout if a "bundle only" product was added to a shopping cart prior to being marked as not for separate sale.
Minor changes to the product_info.php and product_listing.php files and the corresponding manual install instructions.
As orginally written the contribution displayed the Out Of Stock button instead of Buy Now in the product listing any time the product quantity was less than one. However, this should only be done if the store settings don't allow customers to check out when stock levels are insufficient. I've therefore changed the contribution so that the out of stock button is displayed only when the store configuration prevents checking out with insufficient stock.
I've also added an instruction to replace the Add To Cart button on the product_info page with the Out Of Stock button if the store configuration prevents checking out with insufficient stock and the product quantity is less than one.
Complete install is attached.
I've added an instruction file for those who want to use my Protected Images with Unlimited Images Per Product contribution with the Bundled Products contribution. Since Protected Images moves product images out of catalog/images the bundle display routines in product_info.php and categories.php have to be updated to use the two contributions together.
Full install with new additional instructions is attached.
version 2.0
--Changed database definitions of the fields so that the type of the ids in the product_bundles table is the same as the products_id in the products table. Also changed the products_bundles definition from tinytext to enumerated to save database space.
--Replaced hardcoded language in categories.php with defined language.
--Added capability of properly duplicating product bundles in categories.php.
--Added instruction for properly deleting a bundle.
--Added preview of bundle information in categories.php to match the one in product_info.php.
--If the same product is added to a bundle twice the quantities are combined so that only one line per subproduct exists in the product_bundles table which enables PRIMARY indexing on this table.
--Added headings for the Bundled products columns during edit, hid the fields for the subproduct ids, and disabled entry in the subproduct name fields to prevent possible errors that might be caused by tampering with these fields during entry/editing.
--Changed code that only allowed bundles to be nested one level to allow nesting to any level.
--Added code to prevent adding to a bundle another bundle that, directly or via nested bundles, contains the bundle being edited.
--Added code for checking bundle stock that was missing from checkout_payment.php.
--Added code to verify that a product marked as a bundle actually is one. If a product is marked as a bundle during editing in categories.php but no products are added to it the bundle will be changed to "no" while saving the product in the database.
--Bundle weight is calculated automatically from the products it contains when saving the bundle to the database.
--Added code for the packaging routines added to the shopping cart class by the UPSXML contribution so that information for bundle products comes from the products contained in the bundle.
need to add following in catalog/admin/categories.php
$bundle_count = count($bundle_array)
after following
while ($bundle_contents = tep_db_fetch_array($bundle_query)) {
$bundle_array[] = array('id' => $bundle_contents['subproduct_id'],
'qty' => $bundle_contents['subproduct_qty'],
'name' => $bundle_contents['products_name']);
}
minor fix: shopping cart was displaying the wrong items as out of stock due to a sorting error
Full Package
Added indexes to products_bundles table, removed primary key to allow multiple items, altered subproduct_id size to allow higher id's, added dynamic javascript interface and pull down menu to turn the bundle on/off
Full Package
Minor bug fix - Admin login page produced error
Defined TABLE_ADMINISTRATORS in catalog/admin/includes/database_tables.php
added a couple of minor changes for osCommerce Online Merchant v2.2
Complete Package.
Rewrote the install docs and added support thread. Much easier to understand. This is based on v1.5.1, and also includes all previous mods, no code changes, just updated install docs.
http://forums.oscommerce.com/index.php?showtopic=313412
Complete package and
By popular demand, assemble all the manual installation instructions into the package.
This is a rollup of all the uploads to this contribution to date, plus
some added features and fixes.
Fixes: I ran into a few problems with Eoin's otherwise very helpful
upload, and hopefully I've managed to include all of my fixes here.
Kudos to Eoin for getting the ball rolling in the right direction.
Features: I included some code intended to prevent overselling. For
example, if a bundle contains 3 apples and 2 pears, you have 3 apples
in stock, and a customer puts 1 of these bundles into the cart, plus
an apple by itself, this code will mark the individual apple as being
insufficiently stocked. The code tries to give priority to bundles when doing
its insufficient-stock marking, i.e. it allows the bundle to sell before it
allows the individual item(s) that make up the bundle to sell. Please PM me if
you have questions or suggestions about this added feature.
Eoin forgot to include the /catalog/admin/includes/database_tables.php file. This is a very important file and if you don't have it, this is the error you'll recieve
1146 - Table 'XXX_oscX.TABLE_PRODUCTS_BUNDLES' doesn't exist
SELECT pb.subproduct_id, pb.subproduct_qty, pd.products_name FROM products_description pd INNER JOIN TABLE_PRODUCTS_BUNDLES pb ON pb.subproduct_id=pd.products_id WHERE pb.bundle_id = '12' and language_id = '1'
http://forums.oscommerce.com/index.php?showtopic=77738&st=240#
I installed the contribution according to the directions included in version 1.4 as well as the various fixes listed.
Here are the resulting changed files. I hope it's useful for anyone else installing this contribution.
This is a little modification to the great contribution. It will allow you to sort your products by Model --- Name (ID) in your admin/categories.php Set Bundles dropdown list. I hope anybody else can find it useful.
It's not a full package, just a sorting by Model modification.
This is my first post/contriubtion.
I installed the Bundled Products contribution and found while testing that deleting
orders would not put the items in the bundle back in stock, but instead it put
the bundle back in stock even though it was never taken out. Below is the fix I used.
Most likely nobody else but me would use this, but I like things to be neat.
Calculate the Bundle Quantity before displaying it in Product Listing ..
This is my 1st post .. i hope everything is alright
Thanks
Major improvement!
Quantity of bundles is calculated before a sale is made.
If there isn't sufficient stock of one or all of the subproducts, the bundle is marked "Out of Stock" in the cart (if you want).
Also, if there is abundant stock of the subproducts, you can buy as many bundles as the stock level will allow.
This is a bugfix. Nothing new in this one.
Fixes some admin side problems:
1. adds a missing text def
2. allows for updates of existing bundles
3. denys the ability to link a bundle to itself
(this is a good thing. would break both the admin
and catalog displays for an affected bundle.)
Cheers,
Matt
Addition with product image, link to product and price per unit
Bundle Mod Addition is multilanguage see step 7
Attention: No stock update of the subproducts
In action here:
http://www.infotopnet.de/oscommerce_2.2ms2_vkp1/product_info.php?cPath=3_21&products_id=28
In checkcout_confirmation.php I get an error that says table TABLE_PRODUCTS_BUNDLES does not exist. The query in question is: $bundle_query_nested .Where do I define it? I have the table in the database. I have done everything according to the instruction and everything works great except that it crashes in checkout_process.php because it can not find the table. I have tried to make a define in both database_tables.php, configure.php and checkout_process.php without result
This contribution allows you to create bundles of products:
- a user can buy a bundle of parts that may be priced at something different from the total cost of the parts. The cost saving is shown to the customer on the products_info page.
- The stock of each sub product is updated separately when a sale is made.
- A subproduct that is out of stock will prevent the bundle from selling (if you have set STOCK_ALLOW_CHECKOUT to false in admin)
- bundles are created and edited using the admin system
- bundle "master products" are virtual containers for subproducts, ie the stock is not updated. Otherwise, they are regular products with a description, price and other features.
For an example of how the system works take a look at the longboards at www.lushlongboards.com.
Note: Contributions are used at own risk.