Bundled products
#301
Posted 04 January 2009 - 12:48 AM
The Fix: What I discovered was happening was the PRODUCTS table had the products_bundle field type set to tinyint. This in effect stored a '1' in the table for products with bundles and since that does not equal a "yes" the bundled items were never being pulled from the table to be displayed in the product detail page.
The other side of this was that the website would not display or work with the bundles either as all tests on that side of the app require the string value "yes" as well and not a numeric value. It is possible that this began as in issue from a database restore, but since it took me about 5 hours to find this needle, I thought I would share - in case anyone else is having the same problem.
check profile for web address
#302
Posted 12 January 2009 - 10:33 PM
One thing I need is more items in the bundle. I have some kits that take up to 15 items but this thing seems limited to 6. Any way to expand it? I have had some general looks at the code but I am not a PHP programmer!
#303
Posted 15 January 2009 - 05:11 PM
peasplease, on Jun 24 2007, 11:46 AM, said:
2.
We need to find a way of sorting the product list that appears in the bundle setup in the admin section. If you only have 10 products then I guess it's not too difficult to find the single items you want to add to your bundle, but we have around 500 products. Trying to find a single items from the seemingly random list can be a major pain.
If anyone has ideas on how to improve the sorting of the list I would be very happy to hear it.
Again, congrats on such a fantastic mod, keep up the good work.
The list really isn't random. It sorts alphabetically based on the Products Model. At least it does on mine!
#304
Posted 15 January 2009 - 05:12 PM
Desertsky, on Jan 12 2009, 10:33 PM, said:
One thing I need is more items in the bundle. I have some kits that take up to 15 items but this thing seems limited to 6. Any way to expand it? I have had some general looks at the code but I am not a PHP programmer!
Anyone?
#307
Posted 18 February 2009 - 06:20 PM
I need this to be on the page:
// BOF Bundled Products
case 'PRODUCT_LIST_BUY_NOW':
$lc_align = 'center';
$StockChecker1 = tep_get_products_stock($listing['products_id']);
if ( $StockChecker1 <> 0){
$lc_text = (($listing['products_price'] > 0) ? '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a> ' : ' ');
}else{
$lc_text = tep_image_button('button_out_of_stock.gif', IMAGE_BUTTON_OUT_OF_STOCK) . ' ';
}
break;
// EOF Bundled Products
My code has a qty box, an add to cart button and a read more info button. I want the add to cart button to go to out of stock, like the above code does. Below is my code on the product_info page, can anyone give tips on how I can integrate the out of stock bit into my version?
case 'PRODUCT_LIST_BUY_NOW':
$lc_align = 'center';
$lc_text = tep_draw_form('buy_now' . $listing['products_id'], tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']), 'POST') . '<b>Qty:</b> ' . tep_draw_input_field('list_quantity', '1', 'size=2') . '<br><br>' . tep_image_submit('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</form> ' . ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . tep_image_button('small_view.gif', IMAGE_BUTTON_BUY_NOW) . '</a>';
break;
#308
Posted 08 April 2009 - 10:26 AM
since there are many duplicate codes need to modify on those 2 contributions.. especially in catalog/includes/functions/general.php
function tep_get_products_stock($products_id)..
can any help me to combine those 2 codes ? thanks
osc version: 2.2rc2a
bundle product version:1.5.4
qtpro version: 4.51b
here is original code
// Return a product's stock
// TABLES: products
function tep_get_products_stock($products_id) {
$products_id = tep_get_prid($products_id);
$stock_query = tep_db_query("select products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
$stock_values = tep_db_fetch_array($stock_query);
return $stock_values['products_quantity'];
}
qtpro code
// Return a product's stock
// TABLES: products
//++++ QT Pro: Begin Changed code
function tep_get_products_stock($products_id, $attributes=array()) {
global $languages_id;
$products_id = tep_get_prid($products_id);
if (sizeof($attributes)>0) {
$all_nonstocked = true;
$attr_list='';
$options_list=implode(",",array_keys($attributes));
$track_stock_query=tep_db_query("select products_options_id, products_options_track_stock from " . TABLE_PRODUCTS_OPTIONS . " where products_options_id in ($options_list) and language_id= '" . (int)$languages_id . "order by products_options_id'");
while($track_stock_array=tep_db_fetch_array($track_stock_query)) {
if ($track_stock_array['products_options_track_stock']) {
$attr_list.=$track_stock_array['products_options_id'] . '-' . $attributes[$track_stock_array['products_options_id']] . ',';
$all_nonstocked=false;
}
}
$attr_list=substr($attr_list,0,strlen($attr_list)-1);
}
if ((sizeof($attributes)==0) | ($all_nonstocked)) {
$stock_query = tep_db_query("select products_quantity as quantity from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
} else {
$stock_query=tep_db_query("select products_stock_quantity as quantity from " . TABLE_PRODUCTS_STOCK . " where products_id='". (int)$products_id . "' and products_stock_attributes='$attr_list'");
}
if (tep_db_num_rows($stock_query)>0) {
$stock=tep_db_fetch_array($stock_query);
$quantity=$stock['quantity'];
} else {
$quantity = 0;
}
return $quantity;
//++++ QT Pro: End Changed Code
}
bundle product code
// BOF Bundled Products
////
// Return a product's stock
// TABLES: products
// function heavily modified for bundle mod
function tep_get_products_stock($products_id) {
$products_id = tep_get_prid($products_id);
//add bundle field to database query
$stock_query = tep_db_query("select products_quantity, products_bundle from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
//determine whether product is a bundle
$stock_data = tep_db_fetch_array($stock_query);
if ($stock_data['products_bundle'] == 'yes') {
// order item is a bundle and must be separated
$bundle_query = tep_db_query("select pb.subproduct_id, pb.subproduct_qty, p.products_quantity, p.products_bundle from " . TABLE_PRODUCTS_BUNDLES . " pb LEFT JOIN " . TABLE_PRODUCTS . " p ON p.products_id=pb.subproduct_id where pb.bundle_id = '" . (int)$products_id . "'");
while ($bundle_data = tep_db_fetch_array($bundle_query)) {
if ($bundle_data['products_bundle'] == "yes") {
//seperation routine in case there is also a bundle within a bundle
$bundle_query_nested = tep_db_query("select pb.subproduct_id, pb.subproduct_qty, p.products_quantity, p.products_bundle from " . TABLE_PRODUCTS_BUNDLES . " pb LEFT JOIN " . TABLE_PRODUCTS . " p ON p.products_id=pb.subproduct_id where pb.bundle_id = '" . $bundle_data['subproduct_id'] . "'");
while ($bundle_data_nested = tep_db_fetch_array($bundle_query_nested)) {
//generate stock levels string within 2nd level bundle, adding commas between values
$stock_bundle .= (int)($bundle_data_nested['products_quantity'] / $bundle_data_nested['subproduct_qty']) . ',';
}
} else {
//generate stock levels string if it is only a 1st level bundle, adding commas between values
$stock_bundle .= (int)($bundle_data['products_quantity'] / $bundle_data['subproduct_qty']) . ',';
}
}
//create an array from the stock_bundle string
$stock_bundle_array = explode (',', $stock_bundle);
//sorts the array in order of stock levels of subproducts
sort($stock_bundle_array);
//select the smallest subproduct stock value as the stock level of the bundle (first value is null due to way $stock_bundle is made)
$stock_values = $stock_bundle_array[1];
} else {
//generate stock value for single product
$stock_values = $stock_data['products_quantity'];
}
return $stock_values;
}
// EOF Bundled Products
#309
Posted 21 April 2009 - 08:55 AM
I would like for the customer & store emails to list all the sub products within a bundle when sold.
I have modified the admin order.php, invoice.php and packingslip.php to display this way, but no luck with the email part yet. I'm probably missing something simple... it's been a long session.
Any pointers would be greatly appreciated. In the meantime, i will watch mighty boosh and then have another bash with a fresh mind
Thx
Bee
#310
Posted 05 May 2009 - 12:40 PM
Malawi, on Dec 20 2004, 11:36 PM, said:
Parse error: parse error, unexpected T_ELSEIF in /home/customers/bleie/www.domain.com/catalog/admin/categories.php on line 256
----
When I try to checkout, /catalog/checkout_confirmation.php gives me this error:
1064 - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
SELECT products_bundle FROM products where products_id =
[TEP STOP]
The strange thing is that i cannot find this line in checkout_confirmation.php or any other file for that sake.
Anyhow, I think the error may be here(checkout_confirmation.php):
// Stock Check
if (STOCK_CHECK == 'true') {
$bundle_status_query = tep_db_query("SELECT products_bundle FROM " . TABLE_PRODUCTS . " where products_id = " . tep_get_prid($order->products[$i]['id']));
$bundle_status = tep_db_fetch_array($bundle_status_query);
I got the same error and your right, the error is in checkout_confirmation.php. I looked at this forum and found people like yourself with the same problem, but no fixes, so went through the code myself and found the error. Having fixed it, I thought of your entry and so posting my fix to you.
if (STOCK_CHECK == 'true') {
$bundle_status_query = tep_db_query("SELECT products_bundle FROM " . TABLE_PRODUCTS . " where products_id = '1'" . tep_get_prid($order->products[$i]['id']));
$bundle_status = tep_db_fetch_array($bundle_query_raw);
#311
Posted 05 May 2009 - 02:46 PM
bluebozzle, on May 5 2009, 01:40 PM, said:
if (STOCK_CHECK == 'true') {
$bundle_status_query = tep_db_query("SELECT products_bundle FROM " . TABLE_PRODUCTS . " where products_id = '1'" . tep_get_prid($order->products[$i]['id']));
$bundle_status = tep_db_fetch_array($bundle_query_raw);
Ignore last post as I had a problem in checkout with:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\xxx\xxx\includes\functions\database.php on line 99
so I commented out the above code and it now works.
COPY THIS CODE:
if (STOCK_CHECK == 'true') {
// $bundle_status_query = tep_db_query("select products_bundle from " . TABLE_PRODUCTS . " where products_id = ''" . tep_get_prid($order->products[$i]['id']));
// $bundle_status = tep_db_fetch_array($bundle_query_raw);
#312
Posted 28 May 2009 - 03:59 PM
Any ideas on what might be wrong?
#313
Posted 16 January 2010 - 01:56 PM
nnclyn, on 28 May 2009 - 03:59 PM, said:
Any ideas on what might be wrong?
Hi, I have found the code that does this, its in catalog/includes/modules/product_listing.php
Do a search for the following code;
// BOF Bundled Products
case 'PRODUCT_LIST_BUY_NOW':
$lc_align = 'center';
$StockChecker1 = tep_get_products_stock($listing['products_id']);
if ( $StockChecker1 <> 0){
$lc_text = (($listing['products_price'] > 0) ? '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a> ' : ' ');
}else{
$lc_text = tep_image_button('button_out_of_stock.gif', IMAGE_BUTTON_OUT_OF_STOCK) . ' ';
}
break;
// EOF Bundled Products
As you can see, it's checking to see if the stock level is <> 0, if so, it displays the Buy It Now button, if not, i.e. the stock level is 0 it displays the Out of Stock image instead.
I am currently looking at this code with the view to modifying it to include the check to see whether stock checking is turned on or off in the stock section of the configuration part of the Admin area.
Once I have figured it out, I will post the modified code here too, so keep an eye out for it;)
#314
Posted 18 January 2010 - 12:30 PM
I have now modified the code to comply with the stock settings in the admin panel. It now checks to see whether both stock check and Allow Checkout are enabled or not.
// BOF Bundled Products
case 'PRODUCT_LIST_BUY_NOW':
$lc_align = 'center';
$StockChecker1 = tep_get_products_stock($listing['products_id']);
// Peter Milner - Phoenix Model Aviation Ltd (www.phoenixmodelaviation.co.uk)
// Check to see if stock_check is true or false, also check stock_allow_checkout is true or false
if (STOCK_CHECK == 'true')
{
if ($StockChecker1 < 1)
{
if (STOCK_ALLOW_CHECKOUT == 'false')
{
$lc_text = tep_image_button('button_out_of_stock.gif', IMAGE_BUTTON_OUT_OF_STOCK) . ' ';
}
else
{
$lc_text = (($listing['products_price'] > 0) ? '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a> ' : ' ');
}
}
else
{
$lc_text = (($listing['products_price'] > 0) ? '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a> ' : ' ');
}
}
else
{
$lc_text = (($listing['products_price'] > 0) ? '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a> ' : ' ');
}
break;
#315
Posted 26 May 2010 - 01:27 AM
1146 - Table '*******.TABLE_PRODUCTS_BUNDLES' doesn't exist
DELETE FROM TABLE_PRODUCTS_BUNDLES WHERE bundle_id = '63'
[TEP STOP]
My webmaster cant figure out what to do so i am at the mercy of the forum
What have i done wrong? the install instructions are not any help i am lost
please someone help:(
#316
Posted 26 May 2010 - 01:36 AM
canadianvapour, on 26 May 2010 - 01:27 AM, said:
1146 - Table '*******.TABLE_PRODUCTS_BUNDLES' doesn't exist
DELETE FROM TABLE_PRODUCTS_BUNDLES WHERE bundle_id = '63'
[TEP STOP]
My webmaster cant figure out what to do so i am at the mercy of the forum
What have i done wrong? the install instructions are not any help i am lost
please someone help:(
Quote
STEP 3: /catalog/includes/database_tables.php
***ADD BEFORE FINAL ?>:
// BOF Bundled Products
define('TABLE_PRODUCTS_BUNDLES', 'products_bundles');
// EOF Bundled Products
######################################################
STEP 4: /catalog/admin/includes/database_tables.php
***ADD BEFORE FINAL ?>:
// BOF Bundled Products
define('TABLE_PRODUCTS_BUNDLES', 'products_bundles');
// EOF Bundled Products
######################################################
"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."
- Me -
"Headers already sent" - The definitive help
"Cannot redeclare ..." - How to find/fix it
SSL Implementation Help
Like this post? "Like" it again over there >
#317
Posted 26 May 2010 - 02:15 AM
germ, on 26 May 2010 - 01:36 AM, said:
DELETE FROM products_bundles WHERE bundle_id = '64'
#318
Posted 26 May 2010 - 04:37 PM
canadianvapour, on 26 May 2010 - 02:15 AM, said:
DELETE FROM products_bundles WHERE bundle_id = '64'
Notice how the missing table name changed from UPPER CASE to lower case.
Now it's telling you the table doen't exist in the database.
The previous error was indicative of the table name constant not being defined.
"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."
- Me -
"Headers already sent" - The definitive help
"Cannot redeclare ..." - How to find/fix it
SSL Implementation Help
Like this post? "Like" it again over there >
#319
Posted 26 May 2010 - 04:41 PM
germ, on 26 May 2010 - 04:37 PM, said:
Notice how the missing table name changed from UPPER CASE to lower case.
Now it's telling you the table doen't exist in the database.
The previous error was indicative of the table name constant not being defined.
im so lost. i have no idea how i got into this so deep. any chance you may be able to help me with the new error?
#320
Posted 26 May 2010 - 04:50 PM
canadianvapour, on 26 May 2010 - 04:41 PM, said:
Did this contribution get installed recently or has it been around on the site for a while?
"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."
- Me -
"Headers already sent" - The definitive help
"Cannot redeclare ..." - How to find/fix it
SSL Implementation Help
Like this post? "Like" it again over there >









