Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Bundled products


Recommended Posts

Hi there, can't get this to work at all after 3 installs, I am getting a error on the product_info pages as described earlier in the thread with no answers given. The query that is causing problems is:

 

SELECT pd.products_name, pb.*, p.products_bundle, p.products_id, p.products_price FROM products p INNER JOIN products_description pd ON p.products_id=pd.products_id INNER JOIN products_bundles pb ON pb.subproduct_id=pd.products_id WHERE pb.bundle_id =and language_id = '1'

 

The script is making this:

 

pb.bundle_id = " . tep_get_prid($products_id) . "

 

I would appreciate any help on this as I cannot figure it out, the General.php says that tep_get_prid is used for Attributed products ID??

 

Kindest regards

Link to comment
Share on other sites

  • 2 weeks later...
  • Replies 331
  • Created
  • Last Reply

Top Posters In This Topic

Hi...

 

May I have a simple question here.

 

Bundled products work great for me. However, one feature I don't like is when I click on one of the bundled items, popup image shows up, rather than its product_info page like that of Amazon.com.

 

Would anybody please help me how to do modify the code?

 

Your help would be greatly appreciated.

 

Thanks,

David

Link to comment
Share on other sites

  • 2 weeks later...

Here is an answer to the Adding / Modifying / Deleting either exisiting bundles or turning existing products into a new bundle:

 

if ($action == 'insert_product') {

$insert_sql_data = array('products_date_added' => 'now()');

 

$sql_data_array = array_merge($sql_data_array, $insert_sql_data);

 

tep_db_perform(TABLE_PRODUCTS, $sql_data_array);

$products_id = tep_db_insert_id();

 

// update bundle contents

 

if ($HTTP_POST_VARS['products_bundle'] == "yes") { // original was: if ($HTTP_POST_VARS['products_bundle'] = "yes")

tep_db_query("DELETE FROM products_bundles WHERE bundle_id = " . $products_id . "");

 

for ($i=0; $i<6; $i++) {

if (isset($HTTP_POST_VARS['subproduct_' . $i . '_qty']) && $HTTP_POST_VARS['subproduct_' . $i . '_qty'] > 0) {

tep_db_query("INSERT INTO products_bundles (bundle_id, subproduct_id, subproduct_qty) VALUES (" . $products_id . ", " . $HTTP_POST_VARS['subproduct_' . $i . '_id'] . ", " . $HTTP_POST_VARS['subproduct_' . $i . '_qty'] . ")");

}

}

}

//exit; ////END update bundle contents

 

} elseif ($action == 'update_product') {

$update_sql_data = array('products_last_modified' => 'now()');

 

$sql_data_array = array_merge($sql_data_array, $update_sql_data);

 

tep_db_perform(TABLE_PRODUCTS, $sql_data_array, 'update', "products_id = '" . (int)$products_id . "'");

 

//delete categories saved in the tables

tep_db_query("delete from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '". $products_id . "'");

// update bundle contents

 

if ($HTTP_POST_VARS['products_bundle'] == "yes") { // original was: if ($HTTP_POST_VARS['products_bundle'] = "yes")

tep_db_query("DELETE FROM products_bundles WHERE bundle_id = " . $products_id . "");

 

for ($i=0; $i<6; $i++) {

if (isset($HTTP_POST_VARS['subproduct_' . $i . '_qty']) && $HTTP_POST_VARS['subproduct_' . $i . '_qty'] > 0) {

tep_db_query("INSERT INTO products_bundles (bundle_id, subproduct_id, subproduct_qty) VALUES (" . $products_id . ", " . $HTTP_POST_VARS['subproduct_' . $i . '_id'] . ", " . $HTTP_POST_VARS['subproduct_' . $i . '_qty'] . ")");

}

}

}

////END update bundle contents

 

 

Its amazing when a careful inspection turns up a small mistake.....

Link to comment
Share on other sites

Hi

 

Thanks for the fix, I actually gave up on this mod a long time ago.

I tested your fix, but the only thing I dont see a need for was this bit of code:

 

//delete categories saved in the tables

tep_db_query("delete from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '". $products_id . "'");

 

Why do you have this in there?

All it seems to do is delete the product completely when you try to edit it...

 

Without that line the mod works perfectly now.

Just wondered why you added it?

 

Thnx again

CC.

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...
  • 4 weeks later...

I've have bundles installed and working, even with master products. I have no idea how I even did it. When I delete an order, the products are not restocked that are in a bundle. Is this an error in my code or a known "feature".

 

Before I go are write something, has anyone fixed this problem already?

Edited by nesincg
Link to comment
Share on other sites

  • 2 weeks later...

@ burtsmith

 

Hi there, can't get this to work at all after 3 installs, I am getting a error on the product_info pages as described earlier in the thread with no answers given.  The query that is causing problems is:

 

SELECT pd.products_name, pb.*, p.products_bundle, p.products_id, p.products_price FROM products p INNER JOIN products_description pd ON p.products_id=pd.products_id INNER JOIN products_bundles pb ON pb.subproduct_id=pd.products_id WHERE pb.bundle_id =and language_id = '1'

 

The script is making this:

 

pb.bundle_id = " . tep_get_prid($products_id) . "

 

I would appreciate any help on this as I cannot figure it out, the General.php says that tep_get_prid is used for Attributed products ID??

 

Kindest regards

 

 

Hallo,

 

have you fixed this problem ? I have the same error - can you help me?

 

Regards

Rainer

Link to comment
Share on other sites

Hello world, I have been working on this issue and have at least found out what is not working. For the above error messages that we all seem to be getting on the query as follows:

 

SELECT pd.products_name, pb.*, p.products_bundle, p.products_id, p.products_price FROM products p INNER JOIN products_description pd ON p.products_id=pd.products_id INNER JOIN products_bundles pb ON pb.subproduct_id=pd.products_id WHERE pb.bundle_id =and language_id = '1'

 

 

THere is a call in the product_info.php file as follows:

 

 

<!-- start bundle -->

<?php

if ($product_info['products_bundle'] == "yes") {

$products_bundle = $product_info['products_bundle'];

echo "This product contains the following items: ";

$bundle_query = tep_db_query(" SELECT pd.products_name, pb.*, p.products_bundle, p.products_id, p.products_price

FROM products p

INNER JOIN products_description pd

ON p.products_id=pd.products_id

INNER JOIN products_bundles pb

ON pb.subproduct_id=pd.products_id

WHERE pb.bundle_id = " . tep_get_prid($products_id) . " and language_id = '" . (int)$languages_id . "'");

 

 

This is the query producing the acatual error. The issue is this, the function in the WHERE statement at the end is NOT returning the proper bundle ID. In fact, it does not reurn the ID at all as evidenced by the following in the above error.

 

SELECT pd.products_name, pb.*, p.products_bundle, p.products_id, p.products_price FROM products p INNER JOIN products_description pd ON p.products_id=pd.products_id INNER JOIN products_bundles pb ON pb.subproduct_id=pd.products_id WHERE pb.bundle_id =and language_id = '1'

 

Note that the language_id has a value of '1', but the bundle_id has no returned value at all.

WHERE pb.bundle_id = it is this missing return from the function tep_get_prid($product_id)

 

I have proven this by taking this function out and replacing it with an actual value of a known bundle, then it works fine.

 

I have also had to implement the code from 'Monk' posted Sep 9, 2004 to even get my system to write the bundle to the database. This may be related but I have NOT yet figgered that one out.

 

This post is just an update of where I am now, I will indeed keep working on this to figure out why this function is not returning a value, once I do I believe that this mod will work for me. With the exception of the attributes issue I have yet to tackle.

 

I will keep this thread updated if I find anything new on this mod. If anyone else can look into this specific function it would be helpfull. Please feel free to contact me with any questions.

Link to comment
Share on other sites

OK, I got this figured out for me at least.

 

To get this error out of the way replace the following function in the product_info.php file.

 

seach for:

 

WHERE pb.bundle_id = " . tep_get_prid($products_id) . " and language_id = '" . (int)$languages_id . "'");

 

and replace with:

WHERE pb.bundle_id = " . (int)$HTTP_GET_VARS['products_id'] . " and language_id = '" . (int)$languages_id . "'");

 

This fixed this issue for me. I hope it helps you too!

Link to comment
Share on other sites

Sorry for the double post. Could not edit previous post.

 

OK, I got this figured out for me at least.

 

To get this error out of the way replace the following function in the product_info.php file.

 

seach for:

 

WHERE pb.bundle_id = " . tep_get_prid($products_id) . " and language_id = '" . (int)$languages_id . "'");

 

and replace with:

WHERE pb.bundle_id = " . (int)$HTTP_GET_VARS['products_id'] . " and language_id = '" . (int)$languages_id . "'");

 

 

additionaly I implemented Monks code with a slight change, otherwise the tables never get updated correctly. A missing right bracket was the culprit as mentioned earlier in this thread.

 

In admin/catagories.php

 

Find this code...

 

// update bundle contents

if ($HTTP_POST_VARS['products_bundle'] = "yes") {

tep_db_query("DELETE FROM products_bundles WHERE bundle_id = '" . $products_id . "'");

for ($i=0, $n=6; $i<$n; $i++) {

if (isset($HTTP_POST_VARS['subproduct_' . $i . '_qty']) && $HTTP_POST_VARS['subproduct_' . $i . '_qty'] > 0) {

tep_db_query("INSERT INTO products_bundles (bundle_id, subproduct_id, subproduct_qty) VALUES ('" . $products_id . "', '" . $HTTP_POST_VARS['subproduct_' . $i . '_id'] . "', '" . $HTTP_POST_VARS['subproduct_' . $i . '_qty'] . "')");

}

}

}

 

and replace with this:

 

// update bundle contents

}

 

if ($HTTP_POST_VARS['products_bundle'] == "yes") { // original was: if ($HTTP_POST_VARS['products_bundle'] = "yes")

tep_db_query("DELETE FROM products_bundles WHERE bundle_id = " . $products_id . "");

 

for ($i=0; $i<6; $i++) {

if (isset($HTTP_POST_VARS['subproduct_' . $i . '_qty']) && $HTTP_POST_VARS['subproduct_' . $i . '_qty'] > 0) {

tep_db_query("INSERT INTO products_bundles (bundle_id, subproduct_id, subproduct_qty) VALUES (" . $products_id . ", " . $HTTP_POST_VARS['subproduct_' . $i . '_id'] . ", " . $HTTP_POST_VARS['subproduct_' . $i . '_qty'] . ")");

}

}

}

//exit; ////END update bundle contents

 

} elseif ($action == 'update_product') {

$update_sql_data = array('products_last_modified' => 'now()');

 

$sql_data_array = array_merge($sql_data_array, $update_sql_data);

 

tep_db_perform(TABLE_PRODUCTS, $sql_data_array, 'update', "products_id = '" . (int)$products_id . "'");

 

//delete categories saved in the tables

tep_db_query("delete from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '". $products_id . "'");

// update bundle contents

 

if ($HTTP_POST_VARS['products_bundle'] == "yes") { // original was: if ($HTTP_POST_VARS['products_bundle'] = "yes")

tep_db_query("DELETE FROM products_bundles WHERE bundle_id = " . $products_id . "");

 

for ($i=0; $i<6; $i++) {

if (isset($HTTP_POST_VARS['subproduct_' . $i . '_qty']) && $HTTP_POST_VARS['subproduct_' . $i . '_qty'] > 0) {

tep_db_query("INSERT INTO products_bundles (bundle_id, subproduct_id, subproduct_qty) VALUES (" . $products_id . ", " . $HTTP_POST_VARS['subproduct_' . $i . '_id'] . ", " . $HTTP_POST_VARS['subproduct_' . $i . '_qty'] . ")");

}

}

}

////END update bundle contents

 

This fixed this issue for me. I hope it helps you too! Feel free to contact me if you need help with this.

Link to comment
Share on other sites

I would like the Bundle article as Url to call to explain and the price inclusive Tax wheel behind it to represent... Can that be done?

 

 

 

who can form the code for me?

 

best regards

rainer

Edited by Johnson
Link to comment
Share on other sites

I am getting a this error for this part of the code...Parse error:  parse error, unexpected T_ELSEIF

 

Well I thought I had made progress...I added the changes that DS_Sultan posted and all appeared to work. But then I noticed that new products or bundles where not showing up in admin to edit....But they do show up in database.

 

And also only the bundle name shows in check out...Maybe I will start over...

 

This would be very cool if it would work!

Link to comment
Share on other sites

Figures that my fix does not help everyone. My site is heavily mod'ed and I take carefull measures when applying another one.

 

My site works perfectly with the exception of attributes, even existing items can become a bundle master.

 

If they do not work for you, then it is likely you missed something during the install.

 

The unexpected T_ELSEIF is ussually due to a missing bracket, so be sure you check your installation instructions and go thru each step in detail.

 

If you need help you can PM me and I will see what I can do to help get this workin for you.

Link to comment
Share on other sites

I got all of your code to work except I get this error...Parse error: parse error, unexpected T_VARIABLE in /home/httpd/vhosts/xtremecrawlers.com/httpdocs/catalog/product_info.php on line 244

 

If I comment it out it all works....this is the code: The line getting the error is in Red...I still have to work on the new products not showing up in Admin...

 

<!-- start bundle -->

<?php

if ($product_info['products_bundle'] == "yes") {

$products_bundle = $product_info['products_bundle'];

echo TEXT_BUNDLE_CONTENTS . "<br><table>";

$bundle_query = tep_db_query("SELECT pd.products_name, pb.*, p.products_bundle, p.products_id, p.products_price

FROM products p

INNER JOIN products_description pd

ON p.products_id=pd.products_id

INNER JOIN products_bundles pb

ON pb.subproduct_id=pd.products_id

WHERE pb.bundle_id = " . (int)$HTTP_GET_VARS['products_id'] . " and language_id = '" . (int)$languages_id . "'");

while ($bundle_data = tep_db_fetch_array($bundle_query)) {

if ($bundle_data['products_bundle'] == "yes") {

// uncomment the following line to display subproduct qty

// echo "<br>» <b>" . $bundle_data['subproduct_qty'] . " x " . $bundle_data['products_name'] . "</b>";

//echo "<br>» <b> " . $bundle_data['products_name'] . "</b>";

echo '<tr><td valign="top" class="main">» <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $bundle_data['products_id']) . '"><b><u>' . $bundle_data['products_name'] . '</u></b></a></td></tr>';

 

$bundle_query_nested = tep_db_query("SELECT pd.products_name, pb.*, p.products_bundle, p.products_id, p.products_price

FROM products p

INNER JOIN products_description pd

ON p.products_id=pd.products_id

INNER JOIN products_bundles pb

ON pb.subproduct_id=pd.products_id

WHERE pb.bundle_id = " . $bundle_data['products_id'] . " and language_id = '" . (int)$languages_id . "'");

while ($bundle_data_nested = tep_db_fetch_array($bundle_query_nested)) {

// uncomment the following line to display subproduct qty

// echo "<br><i>     " . $bundle_data_nested['subproduct_qty'] . " x " . $bundle_data_nested['products_name'] . "</i>";

//echo "<br><i>     " . $bundle_data_nested['products_name'] . "</i>";

echo '<tr><td valign="top" class="main">     <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $bundle_data_nested['products_id']) . '"><i><u>' . $bundle_data_nested['products_name'] . '</u></i></a></td></tr>';

 

// CB use special price if available

if ($new_price = tep_get_products_special_price($bundle_data_nested['products_id'])) {

$bundle_sum += $new_price*$bundle_data_nested['subproduct_qty'];

} else {

$bundle_sum += $bundle_data_nested['products_price']*$bundle_data_nested['subproduct_qty'];

}

// endof CB mod

}

} else {

// uncomment the following line to display subproduct qty

// echo "<br>» <b>" . $bundle_data['subproduct_qty'] . " x " . $bundle_data['products_name'] . "</b>";

//echo "<br>» <b> " . $bundle_data['products_name'] . "</b>";

echo '<tr><td valign="top" class="main">» <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $bundle_data['products_id']) . '"><b><u>' . $bundle_data['products_name'] . '</u></b></a></td></tr>';

 

// CB use special price if available

if ($new_price = tep_get_products_special_price($bundle_data_nested['products_id'])) {

$bundle_sum += $new_price*$bundle_data['subproduct_qty'];

} else {

$bundle_sum += $bundle_data['products_price']*$bundle_data['subproduct_qty'];

}

// endof CB mod

}

}

// CB use special bundle price if available

if ($new_price = tep_get_products_special_price($product_info['products_id'])) {

$bundle_saving = $bundle_sum - $new_price;

} else {

$bundle_saving = $bundle_sum - $product_info['products_price'];

}

// endof CB mod

 

$bundle_sum = $currencies->display_price($bundle_sum, tep_get_tax_rate($product_info['products_tax_class_id']));

$bundle_saving =?$currencies->display_price($bundle_saving, tep_get_tax_rate($product_info['products_tax_class_id']));

// comment out the following line to hide the "saving" text

echo '</table><p><table><tr><td class="main" align="right">' . TEXT_BUNDLE_SUM . '</td><td? class="main"><span class="productPrice">' . $bundle_sum . '</span></td></tr><tr><td class="main" align="right">' . TEXT_BUNDLE_SAVINGS . '</td><td? class="main"><span class="productSpecialPrice">' . $bundle_saving . '</span></td></tr></table>';

}

?>

<!-- end bundle -->

Link to comment
Share on other sites

I  got all of your code to work except I get this error...Parse error:  parse error, unexpected T_VARIABLE in /home/httpd/vhosts/xtremecrawlers.com/httpdocs/catalog/product_info.php on line 244

 

If I comment it out it all works....this is the code: The line getting the error is in Red...I still have to work on the new products not showing up in Admin...

 

 

I have tried your code in place of mine and it works fine on my site. I think there must either be a part of the insstall you missed or another mod that is involved. Perhaps we need to go a bit deeper into your other files...

Link to comment
Share on other sites

I have tried your code in place of mine and it works fine on my site.  I think there must either be a part of the insstall you missed or another mod that is involved.  Perhaps we need to go a bit deeper into your other files...

 

I have More pics 6 installed and I went back through the code and noticed that some of the bundle code fell in the middle of more pics. So I am going to go back to fresh copies and pay attention as to what is before and after the spots to put the bundle code and make sure I do not split it up...

Link to comment
Share on other sites

I have successfully installed this contribution, but I get this error when saving updates to products:

1062 - Duplicate entry '41-24' for key 1

The new subproducts are stored o.k. in table products_bundles, but any other changes to standard osc fields are not stored.

 

I have seen that others have encoutered the same problem, but have not been able to locate a solution. Below is an extract from my /admin/categories.php where I think the error might be:

            tep_db_perform(TABLE_PRODUCTS, $sql_data_array);
           $products_id = tep_db_insert_id();
       }
 // update bundle contents
 if ($HTTP_POST_VARS['products_bundle'] = "yes") {
   tep_db_query("DELETE FROM products_bundles WHERE bundle_id = '" . $products_id . "'");

   for ($i=0, $n=6; $i<$n; $i++) {
  if (isset($HTTP_POST_VARS['subproduct_' . $i . '_qty']) && $HTTP_POST_VARS['subproduct_' . $i . '_qty'] > 0) {
 tep_db_query("INSERT INTO products_bundles (bundle_id, subproduct_id, subproduct_qty) VALUES ('" . $products_id . "', '" . $HTTP_POST_VARS['subproduct_' . $i . '_id'] . "', '" . $HTTP_POST_VARS['subproduct_' . $i . '_qty'] . "')");

}
 }
   

           tep_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id) values ('" . (int)$products_id . "', '" . (int)$current_category_id . "')");
         } elseif ($action == 'update_product') {
           $update_sql_data = array('products_last_modified' => 'now()');

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...