Jump to content
lushlongboards

Bundled products

Recommended Posts

Ok i guess i am not as bright as i thought i was. Here is the code that puts the underlying products on the admin invoice.Its great .

 

My question is how do i get the underlying products models on there too:

 

ODE

$bundleContents = '';

$bundle_query = tep_db_query("SELECT pb.subproduct_id, pb.subproduct_qty, p.products_id, pd.products_name, pd.language_id FROM " . TABLE_PRODUCTS . " p LEFT JOIN products_bundles pb ON (pb.bundle_id=p.products_id) LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd ON (pd.products_id=pb.subproduct_id) WHERE p.products_model = '" . $order->products[$i]['model'] . "' AND pd.language_id = '1'");

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

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

}

 

 

 

 

into invoice.php just before the closing

 

 

CODE

echo ' </td>' . "\n" .


Selwyn Wacks

Share this post


Link to post
Share on other sites

ANy one out there?

 

This puts the sub-products on the invoice and packing slip

 

its a vital contribution coz you can send the packing slip to your manufacturer as an order

 

we just need someone that knows SQL JOINS !!!


Selwyn Wacks

Share this post


Link to post
Share on other sites

Hi,

 

Does anybody have any idea on how can I sort products by Model instead of by Name in a drop-down list of products in admin/categories.php? Any help would be appreciated.

 

Thanks,

Irina.

Edited by Irin

Share this post


Link to post
Share on other sites
I've got everything smoothly except 1 problem. When setting up the bundle in the admin, once I select the item to add to the bundle from the dropdown and it adds it in to the blank row, it shows undefined in the first colum. The other colums are fine... and show product id # and quantity. Any way to get the rows to display product name instead of undefined?

 

There is a problem in javascript that goes in admin/categories.php, in the function fillCodes( ), the line

var name = document.new_product.subproduct_selector[document.new_product.subproduct_selector.selectedIndex].name

should have .text at the end, not .name

 

I've seen this problem in Firefox but not in IE. Now it works in both.

 

- Rigadin

Edited by 241

STS PLUS, a variation of STS, is now available.

ACA 2.0 is also out!

Share this post


Link to post
Share on other sites

I have successfully installed this mod on CRE Loaded 6.15 and it worked right out of the box.

 

There is one change I would like to make, but all efforts thus far have failed.

 

On a bundled product info page, when a user clicks on one of the bundled item's image, it loads that item's product page. Instead, I would like for it to popup an image window and show the enlarged pic of that item (just like at the top of each regular product page where you can enlarge the item by clicking on its pic).

 

I have tried several different changes to the code, but have had no luck.

 

This is the line I think that needs to be changed:

echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $bundle_data['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $bundle_data['products_image'], $bundle_data['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="1" vspace="1"') . '</a>';

 

I have already removed the target="_blank" so that at least a new window doesn't open.

 

Anyone have any ideas? Suggestions are most appreciated!

 

Site with this mod can be viewed here:

 

JustPillows.com Collections Category


Soft, elegant, yet suprisingly affordable

Share this post


Link to post
Share on other sites

If anyone is interested, I have figured out a way to do what I wanted (see above post).

 

Now, when a user clicks on an image in the bundle, a pop up of that image appears instead of going to that product's info page.

 

You can view here:

JustPillows.com Collections

Here are the code changes:

 

In product_info_tpl.php (the one from the bundle contrib), find:

 echo "<tr><td class=main valign=top>";
	  echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $bundle_data['products_id']) . '" target="blank">' . tep_image(DIR_WS_IMAGES . $bundle_data['products_image'], $bundle_data['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="1" vspace="1"') . '</a>';

 

And replace with:

 echo "<tr><td class=main valign=top>"; ?>
						   <script language="javascript"><!--
						   document.write('<?php echo '<a href="javascript:popupWindow(\\\'' . tep_href_link(FILENAME_POPUP_IMAGE, 'pID=' . $bundle_data['products_id'] . 'ℑ=0') . '\\\')">' . tep_image(DIR_WS_IMAGES . $bundle_data['products_image'], addslashes($bundle_data['products_name']), SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="1" vspace="1"') . '</a>'; ?>');
						   //--></script>
<?php

 

Hope that helps someone.

 

Thanks again for the absolutely AWESOME contrib!


Soft, elegant, yet suprisingly affordable

Share this post


Link to post
Share on other sites

Rigadin:

 

Thank you!

 

"should have .text at the end, not .name"

 

There is a problem in javascript that goes in admin/categories.php, in the function fillCodes( ), the line

var name = document.new_product.subproduct_selector[document.new_product.subproduct_selector.selectedIndex].name

should have .text at the end, not .name

 

I've seen this problem in Firefox but not in IE. Now it works in both.

 

- Rigadin

Share this post


Link to post
Share on other sites

Has anyone had an issue with the bundled product info not remaining on the edit product pages in the admin section? When I go back to edit a bundled product (like to change a price), the bundle info is gone and I have to add it again or lose it on the store side of the site.

Any help would be greatly appreciated!

TIA


Soft, elegant, yet suprisingly affordable

Share this post


Link to post
Share on other sites
Ok i guess i am not as bright as i thought i was. Here is the code that puts the underlying products on the admin invoice.Its great .

 

My question is how do i get the underlying products models on there too:

 

ODE

$bundleContents = '';

$bundle_query = tep_db_query("SELECT pb.subproduct_id, pb.subproduct_qty, p.products_id, pd.products_name, pd.language_id FROM " . TABLE_PRODUCTS . " p LEFT JOIN products_bundles pb ON (pb.bundle_id=p.products_id) LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd ON (pd.products_id=pb.subproduct_id) WHERE p.products_model = '" . $order->products[$i]['model'] . "' AND pd.language_id = '1'");

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

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

}

 

into invoice.php just before the closing

 

CODE

echo ' </td>' . "\n" .

Hi all!

 

Just a question swack (or anyone else), when I put in your code it puts extra lines and the "x" on the invioce for all products. In my case there is often both bundles and "ordinary" products on the invoice and I only want your code to apply to bundles. Any idea how to do that?

 

Cheers!

Share this post


Link to post
Share on other sites

This is a great contribution so thanks much!

 

My question is to the number of bundled items. Right now it seems to be fixed at whatever you put in the loops (6 is what is in the code). What happenes if you set that number to say 20 but only put 10 items in the bundle. Does it break?

 

-mx

Share this post


Link to post
Share on other sites

HI,

just checking if ive missed something. Ive installed the bundled products and got it working ok except for attributes. I want to be able to have one attribute or none per product and have these selectable somehow. At the moment this doesnt seem to work. Ive tried adding attributes for the bundle itself but that doesnt seem to work properly either. Are attributes supported in this contrib ?

 

What i was actually after is a way to let customers have a discount if they bought say three (or more) products - one from each of three (or more) different catagories, and then throw in a free gift too. The discount isnt based on price or quantity, but is based on the catagory the products belong to (being different), all being selected at the same time - you drop one from the basket and you lose the discount until you add back in another one - not from all catagories - just a set of say 3 or 4 catagories.

 

Anyone know of something that will do this ? Ive been trawling the contribs for days now trying to find something close to what i need with no avail.

 

thanks


Regards

Mark Brindle

Share this post


Link to post
Share on other sites

Ok i got attributes for the bundle to work ok now. For a single attribute.

was a fix in this thread for adding (int) to a query with some curly brackets in it {} that was failing without it now that the product_id isnt just a single number any more.

 

I then tried to get this working with a price sensitive discount contrib too which did work when there was no attributes (and made sure the extra % discount wasnt also given to the bundle), but as soon as the attributes were back on, the discount contrib still added the discount...so back to square one again..

:(

 

I am now trying the easy discount contrib to do the whole thing instead of using bundled products - this contrib 'seems' to be the way for me to go as you can made arbitary discount rules - ie 'dynamic bundles' and still have full conrol of the producuts themselves - so full attribute handling. Its all hard-coded rules though so not so easy admin.


Regards

Mark Brindle

Share this post


Link to post
Share on other sites

hi, i was just wondering if anyone had the changes needed to get this to work with downloadable products?

 

i had some extra code a few months ago, but not sure how to get it to work as a lot was missing i think...

Share this post


Link to post
Share on other sites

Is the contribution supposed to show any attributes a product has ?

 

ie: Bundled Product contains:

Product1

Attribute: size

Product2

Attribute: size

Product3

Attribute: size

 

The individual products when viewed show their attributes fine, but when i bundle them into a pack similar to above, the bundled products mod doesnt seem to get the attributes of the products it contains.

 

This i need to happen, any ideas on how i can acheive this ?

Share this post


Link to post
Share on other sites

You're probably going to have to read the whole thread. This is a recurring problem and different people have solved it in their own ways.

 

The good news is that there are only 13 pages of posts to sift through.

Share this post


Link to post
Share on other sites

I am a relative n00b with regard to oscommerce, but not php or mysql in general.

 

I have recently installed the Bundled Products contrib to my new oscommerce site and was very happy with how it worked, until I realized that it wasn't updating the stock/quantity of the individual items in the bundle, while it was updating the stock of the master.

 

I realized that the IPN module was somehow interfering with the stock update part of the product bundle contrib and, although it doesn't say so anywhere, a n00b like me didn't think about the fact that the IPN module repeats the stock update section from catalog/checkout_process.php, thereby superceding the necessary mod.

 

So if you've got the IPN module, in addition to changing catalog/checkout_process.php, you've got to change catalog/includes/module/payment/paypal_ipn.php from:

 

  for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
// Stock Update - Joao Correia
if (STOCK_LIMITED == 'true') {
  if (DOWNLOAD_ENABLED == 'true') {
	$stock_query_raw = "SELECT products_quantity, pad.products_attributes_filename 
						FROM " . TABLE_PRODUCTS . " p
						LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES . " pa
						 ON p.products_id=pa.products_id
						LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad
						 ON pa.products_attributes_id=pad.products_attributes_id
						WHERE p.products_id = '" . tep_get_prid($order->products[$i]['id']) . "'";
// Will work with only one option for downloadable products
// otherwise, we have to build the query dynamically with a loop
	$products_attributes = $order->products[$i]['attributes'];
	if (is_array($products_attributes)) {
	  $stock_query_raw .= " AND pa.options_id = '" . $products_attributes[0]['option_id'] . "' AND pa.options_values_id = '" . $products_attributes[0]['value_id'] . "'";
	}
	$stock_query = tep_db_query($stock_query_raw);
  } else {
	$stock_query = tep_db_query("select products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
  }
  if (tep_db_num_rows($stock_query) > 0) {
	$stock_values = tep_db_fetch_array($stock_query);
// do not decrement quantities if products_attributes_filename exists
	if ((DOWNLOAD_ENABLED != 'true') || (!$stock_values['products_attributes_filename'])) {
	  $stock_left = $stock_values['products_quantity'] - $order->products[$i]['qty'];
	} else {
	  $stock_left = $stock_values['products_quantity'];
	}
	tep_db_query("update " . TABLE_PRODUCTS . " set products_quantity = '" . $stock_left . "' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
	if ( ($stock_left < 1) && (STOCK_ALLOW_CHECKOUT == 'false') ) {
	  tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '0' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
	}
  }
}

 

to this:

  for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
// Stock Update - Joao Correia
if (STOCK_LIMITED == 'true') {
  if (DOWNLOAD_ENABLED == 'true') {
	$stock_query_raw = "SELECT products_quantity, products_bundle, pad.products_attributes_filename 
						FROM " . TABLE_PRODUCTS . " p
						LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES . " pa
						 ON p.products_id=pa.products_id
						LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad
						 ON pa.products_attributes_id=pad.products_attributes_id
						WHERE p.products_id = '" . tep_get_prid($order->products[$i]['id']) . "'";
// Will work with only one option for downloadable products
// otherwise, we have to build the query dynamically with a loop
	$products_attributes = $order->products[$i]['attributes'];
	if (is_array($products_attributes)) {
	  $stock_query_raw .= " AND pa.options_id = '" . $products_attributes[0]['option_id'] . "' AND pa.options_values_id = '" . $products_attributes[0]['value_id'] . "'";
	}
	$stock_query = tep_db_query($stock_query_raw);
  } else {
	$stock_query = tep_db_query("select products_quantity, products_bundle from " . TABLE_PRODUCTS . " where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
  }

  if (tep_db_num_rows($stock_query) > 0) {
	  $stock_values = tep_db_fetch_array($stock_query);
	  if ($stock_values['products_bundle'] == 'yes') {
		// order item is a bundle and must be separated
		$report_text .= "Bundle found in order : " . tep_get_prid($order->products[$i]['id']) . "<br>\n";
		  $bundle_query = tep_db_query("select pb.subproduct_id, pb.subproduct_qty, p.products_model, 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 = '" . tep_get_prid($order->products[$i]['id']) . "'");

		while ($bundle_data = tep_db_fetch_array($bundle_query)) {
			if ($bundle_data['products_bundle'] == "yes") {
				$report_text .= "<br>level 2 bundle found in order :  " . $bundle_data['products_model'] . "<br>";
				  $bundle_query_nested = tep_db_query("select pb.subproduct_id, pb.subproduct_qty, p.products_model, 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)) {
					$stock_left = $bundle_data_nested['products_quantity'] - $bundle_data_nested['subproduct_qty'] * $order->products[$i]['qty'];
					$report_text .= "updating level 2 item " . $bundle_data_nested['products_model'] . " : was " . $bundle_data_nested['products_quantity'] . " and number ordered is " . ($bundle_data_nested['subproduct_qty'] * $order->products[$i]['qty']) . " <br>\n";
					tep_db_query("update " . TABLE_PRODUCTS . " set products_quantity = '" . $stock_left . "' where products_id = '" . $bundle_data_nested['subproduct_id'] . "'");
				}
			} else {
				$stock_left = $bundle_data['products_quantity'] - $bundle_data['subproduct_qty'] * $order->products[$i]['qty'];
				$report_text .= "updating level 1 item " . $bundle_data['products_model'] . " : was " . $bundle_data['products_quantity'] . " and number ordered is " . ($bundle_data['subproduct_qty'] * $order->products[$i]['qty']) . " <br>\n";
				tep_db_query("update " . TABLE_PRODUCTS . " set products_quantity = '" . $stock_left . "' where products_id = '" . $bundle_data['subproduct_id'] . "'");
			}
		}

	  } else {
// order item is normal and should be treated as such
		$report_text .= "Normal product found in order : " . tep_get_prid($order->products[$i]['id']) . "\n";
// do not decrement quantities if products_attributes_filename exists
		if ((DOWNLOAD_ENABLED != 'true') || (!$stock_values['products_attributes_filename'])) {
		  $stock_left = $stock_values['products_quantity'] - $order->products[$i]['qty'];
		} else {
		  $stock_left = $stock_values['products_quantity'];
		}
		tep_db_query("update " . TABLE_PRODUCTS . " set products_quantity = '" . $stock_left . "' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
		if ( ($stock_left < 1) && (STOCK_ALLOW_CHECKOUT == 'false') ) {
		  tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '0' where products_id = '" . tep_get_prid($order->products[$i]['id']) . "'");
		}
	  }
  }
}

 

-adam

Share this post


Link to post
Share on other sites

Adam,

 

I installed the updated code into my paypal_ipn module and the stock updating appears to work. But sometimes I don't think it is. I noticed there were references made to report_text=, but then never saved or displayed anywhere.

 

Can you tell me what the report_text is used for? Is this just a debugging thing? I would like to write a log of what items are being updated from inventory so I can double check.

 

It appears my items are updating correctly from sandbox testing, but when I run live things do not seem to work all the time so I need to do some debugging.

 

Thanks in advance to anyone that can help.

 

Mike

Share this post


Link to post
Share on other sites

Adam or anyone that can help here.

 

After hours of troubling shooting I have found what is going on with stock updates.

 

When I make a purchase in test (paypal sandbox), all stock items update correctly. When I run live (real transactions) only orders without a bundled item update stock, otherwise no stock updates occur.

 

Has anyone else had this problem? I am going crazy here because I have a couple of new bundled items with more than 20 items attached to it and multiple qualties of some items.

 

I called paypal and spoke with tech and they have no answers. They think it is the stock updating module.

 

Thanks,

Mike

Share this post


Link to post
Share on other sites
I also have solved the download problem that I posted earlier. For example lets say you have the following:

Bundle 01

>Product A

>Product B

>Product C

 

and Products A, B and C have downloads

 

If someone purchases Bundle 01, the downloads for the subproducts are automatically added to the order and they are named after the subproducts NOT the bundle.

 

I have also added code that shows the subproducts as attributes of the bundle so in the cart and invoice looks like:

 

Bundle 02

- Subproduct: 1 x Product A

- Subproduct: 2 x Product B

- Subproduct: 1 x Product C

 

I need to test some more, but can post if there is interest

 

 

Hello there,

 

This IS EXACTLY what i need as well, please would you be so marvellously kind to indeed post it ? :-D

 

Thanks a lot,

Steph

Share this post


Link to post
Share on other sites

hy guys,

 

i tried to make this great contribution work for me on heavy modified OSC, everything is ok in the admin side.

 

The problem is because i cannot get bundles visible on product info?

 

any ideas why?

 

please help

Share this post


Link to post
Share on other sites

im having trouble as well. I installed it onto my test directory with everythin the same running on my real store. THe admin side it's fine, or at least it seem to be fine. But after i set up the bundle it doesnt show up on the product page. DId i miss edit something? i had other contri running on it before such as Mor Pic

Share this post


Link to post
Share on other sites
im having trouble as well. I installed it onto my test directory with everythin the same running on my real store. THe admin side it's fine, or at least it seem to be fine. But after i set up the bundle it doesnt show up on the product page. DId i miss edit something? i had other contri running on it before such as Mor Pic

whops i forgot to upload product_info

 

nevermind it works now!

Share this post


Link to post
Share on other sites

I installed the mode today and LOVE IT!. Instructions were clear and it was pretty easy to do. I am a novice, but wanted to know it there is a way to change the table layout. I would lke to put 2 products in a row and have the product description above or below the pic. I do not need to show the individual product prices. My site is not live yet but you can see what I am doing at www.hechtboys.com Click on Matching sets under Categories.

 

Any suggestions would be appreciated

Edited by cybercon

Jeff

 

Contributions I use: DynaMenus - Light Box - Best Sellers Content Box - Related Products 3.2 - UPS XML - Secure Admin Login - Vendor Locator - Graphical Borders.

Share this post


Link to post
Share on other sites

OK so I said in a previous post I Love this Contribution and I do but I cannot check out anymore. When I get to the final stage "confirm order" - even if I am not purchasing a bundle - I get the following:

 

1065 - Query was empty

 

 

 

[TEP STOP]

 

any suggestions?


Jeff

 

Contributions I use: DynaMenus - Light Box - Best Sellers Content Box - Related Products 3.2 - UPS XML - Secure Admin Login - Vendor Locator - Graphical Borders.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×