Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Bundled products


Recommended Posts

How can I make this (otherwise perfekt) mod. add the items back to stock when I cancel an order ?

 

It dosen't restock the single items from the bundle.. !

Link to comment
Share on other sites

  • Replies 331
  • Created
  • Last Reply

Top Posters In This Topic

Yet another quick question for your PHP guru's :D

 

Have anyone had the bundle split into org. parts on the invoice page ?

 

Thanks in advance

Link to comment
Share on other sites

Ive changed Product Bundles in database to 'tinyint' but i get the following error

 

Error

 

SQL-query :

 

ALTER TABLE `products_bundles` CHANGE `bundle_id` `bundle_id` TINYINT( 6 ) DEFAULT '0' NOT NULL

 

MySQL said:

 

 

#1062 - Duplicate entry '127-11' for key 1

 

Any ideas?

Link to comment
Share on other sites

Firstly...thanks Chris for this contribution, I've needed this for a long time now! No more stock problems for my "bundles" which were actually just a product with no link to the subproducts.

 

I have a couple of issues (not major but niggles) in the admin...

 

1. You cannot add more subproducts to a bundle by editing

2. You cannot delete subproducts by editing

3. How would I set this up for more than 6 subproducts?

 

Thanks in advance for any help.

Many Thanks,

 

Steve

Link to comment
Share on other sites

cdamianou: It looks like changing the data type on your field is causing duplicate values. You will need to delete the existing data before making the change.

Many Thanks,

 

Steve

Link to comment
Share on other sites

Sorry Steve

 

Can you explain how to do this. You are probably sayng, oh my God, this Guy is useless. Sorry mate. Im still learning SQL basics. I can add queries etc, but delete items, well, maybe with your help on this, i will learn something else about SQL.

 

Thanks in advance

Link to comment
Share on other sites

Hi,

 

Thanks for the mod - it's been a real life saver. Just one problem (and I've tried applying the mod twice both on clean installations but still have the same problem). Creating a product and bundle at the same time is fine. Updating the bundle doesn't happen at all. I've checked the database and it's fine but it won't update. I did also get this when I did a bundle change, went to the preview page and then clicked on 'back':

 

1064 - You have an error in your SQL syntax near 'and language_id = '1'' at line 1

 

SELECT products_bundles.subproduct_id, products_bundles.subproduct_qty, products_description.products_name FROM products_description INNER JOIN products_bundles ON products_bundles.subproduct_id=products_description.products_id WHERE products_bundles.bundle_id = and language_id = '1'

 

Not sure whether this would be of any relevance.

 

I've tried creating a product from scratch just in case is was a problem with modifying an old product but still no luck.

 

I can post the code if that would be useful but thought I'd save space in the meantime.

 

Many thanks,

 

 

Richard

Link to comment
Share on other sites

cdamianou:

 

No worries...to delete you use the following syntax:

 

DELETE FROM products_bundles

 

Remember! This will delete all of the records from this table. In this instance, it's OK because it's your only option. But you must use it with caution.

 

One tip: If you were going to delete a selection of records, e.g:

 

DELETE FROM products WHERE products_id > 50

 

it would be wise to do it as a selection first, to ensure you are deleting the records you expect to delete:

 

SELECT * FROM products WHERE products_id > 50

Many Thanks,

 

Steve

Link to comment
Share on other sites

Thanks Steve

 

I pressume i just us ethe following in the query box, and it should delete everything for bundled Products? DELETE FROM products_bundles

 

Then i just run the sql file again, hopefully it will work ok?

 

Thanks

 

Costas

Link to comment
Share on other sites

rpain - I think it might be because I have removed the "preview" step in my admin system. I had completely forgotten that the original osC had the preview step! There's a mod somewhere that I used, and I guess that step forgets the bundle data somehow.

 

as for more than 6 subproducts:

 

in categories.php, find

     function fillCodes() {     
      for (var n=0;n<6;n++) {

 

and change the "6".

 

then find all occurences of

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

 

and change the "6".... there are two places, one where the input fields are written to html and one where the database is written on an "update".

 

updating stock when you delete an order? I've not worked on it yet...

 

Chris

Link to comment
Share on other sites

Thanks - does this mean that if I bypass the preview page and just submit to the categories page with 'action=update_product' then it should work correctly? I do agree that the preview page is a waste of time.

 

Richard

Link to comment
Share on other sites

Sorry, the only other question is how I can get the bundle contents to show up in the shopping cart, invoice and the email sent to the customer?

 

I thought that when the product is added to the orders_products table, I'd append the bundle as a string to the products_name field. I'm not sure where to look to do this, though. Firstly, which page stores the products in the database and secondly is it near the product_info page when the bundle contents are displayed? Would the best thing to do be to create a session with the bundle contents and then append it later on?

 

Confusing...

 

Thanks,

 

 

Richard

Link to comment
Share on other sites

Sorry for the last but one message. I tried this out myself and found the setting bundle to be 'yes' shows the bundle but now leaving blank removes it. I still can't change the bundle itself, though

Link to comment
Share on other sites

Im ryng to egt this contribution to work, but no luck.

 

I try to add and confirm bundled products, but i get the following error.

 

1054 - Unknown column 'products_bundle' in 'field list'

 

insert into products_description (products_name, products_bundle, products_description, products_url, products_head_title_tag, products_head_desc_tag, products_head_keywords_tag, products_id, language_id) values ('testing', 'e', 'ddfdsf', '', '', '', '', '328', '1')

 

[TEP STOP]

 

 

Can anyone help

 

Thanks

Link to comment
Share on other sites

cdamianou,

 

You made a mistake in your installation. The 'products_description' table does not (and should not) have a 'products_bundle' column, which means you made a change at the wrong place in your code. On which page does this error show up on? Upload the old file for the page this shows up on (example categories.php) and apply the changes again making sure you are doing them in the correct places.

Link to comment
Share on other sites

Hi Safoo

 

I believe i had. The explanations i didnt find easy to follow like other contributions, so confused as to what i ahve done wrong.

 

If their is anyone that would liek to have a look at this code, ill be happy to supply the file.

 

Thanks

Link to comment
Share on other sites

cdamianou,

 

So upload your backup file of catalog/admin/categories.php and add a regular product (non-bundle) and make sure it works. Then once you check that the regular product is added correctly, start applying the changes to the file one by one making sure you double check everything. If after doing this you still have the error then post your categories.php (using the [ CODE ] function) with the changes applied. There is nothing wrong with the instructions because it works correctly in everyone else's carts. You are making a mistake in the installation somewhere.

 

You are using OSC MS2.2 correct? Are you using a language other than english?

 

Try what I said above and let me know what happens.

Link to comment
Share on other sites

rpain -

 

here is one solution. The script looks at the product model on the invoice and pulls up the current bundle contents from the products database (which is the limitation since this is not necessarily the same as the bundle contents at time of order)

 

add

 

   $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

 

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

 

after the products_name is written to the user.

 

 

Here's my invoice.php that you can drop into your cart to see what it looks like.

 

<?php
/*
 $Id: invoice.php,v 1.6 2003/06/20 00:37:30 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 require('includes/application_top.php');

 require(DIR_WS_CLASSES . 'currencies.php');
 $currencies = new currencies();

 $oID = tep_db_prepare_input($HTTP_GET_VARS['oID']);
 $orders_query = tep_db_query("select orders_id from " . TABLE_ORDERS . " where orders_id = '" . (int)$oID . "'");

 include(DIR_WS_CLASSES . 'order.php');
 $order = new order($oID);
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">

<!-- body_text //-->
<table border="0" width="100%" cellspacing="0" cellpadding="10">
 <tr> 
   <td>
     <table width="100%" border="0" cellspacing="0" cellpadding="2">
       <tr> 
         <td valign="top"> 
           <table width="100%" border="0" cellspacing="0" cellpadding="2">
             <tr> 
               <td class="smallText"><b> Ship to:</b></td>
             </tr>
             <tr> 
               <td class="smallText"> 
                 <?php echo "[" . $oID . "] " . tep_address_format($order->delivery['format_id'], $order->delivery, 1, '', '<br>'); ?>
               </td>
             </tr>
             <tr> 
               <td class="smallText"> 
                 <?php echo $order->customer['telephone']; ?>
               </td>
             </tr>
             <tr> 
               <td class="smallText"> <font color="#666666"><b><font color="#000066">From:</font> 
                 <br>
                 Lush, Unit 30, 62 Hoyland Rd, Sheffield, S3 8AB </b></font></td>
             </tr>
           </table>
         </td>
         <td valign="top"> 
           <table width="100%" border="0" cellspacing="0" cellpadding="2">
             <tr> 
               <td class="smallText"><b> Billing Address:</b></td>
             </tr>
             <tr> 
               <td class="smallText"> 
                 <?php echo tep_address_format($order->customer['format_id'], $order->customer, 1, '', '<br>'); ?>
               </td>
             </tr>
           </table>
         </td>
       </tr>
     </table>
   </td>
 </tr>
 <tr> 
   <td class="pageHeading">
     <p> </p>
     <p> </p>
     <p><?php echo 'Order ref ' . $oID . ' , Time: ' . $order->info['date_purchased']; ?></p>
   </td>
 </tr>
 <tr> 
   <td>
     <table border="0" cellspacing="0" cellpadding="2">
       <tr> 
         <td class="main"><b>
           <?php echo ENTRY_PAYMENT_METHOD; ?>
           </b></td>
         <td class="main">
           <?php 
	 if ($order->info['payment_method']) {
    echo $order->info['payment_method']; 
	 } else {
    echo 'Manual or phone sale'; 
	 }
	 ?>
         </td>
       </tr>
     </table>
   </td>
 </tr>
 <tr> 
   <td class="main"> 
     <?php 
  $comments_query = tep_db_query("SELECT comments, date_added FROM " . TABLE_ORDERS_STATUS_HISTORY . " where orders_id = '" . $oID . "'");
  while ($comments = tep_db_fetch_array($comments_query)) {
   if ($comments['comments']) {
   echo '<br><b>Order comments:</b><br>' . $comments['date_added'] . ' : <font color="red">' . $comments['comments'] . "</font>"; 
 }
  }
  ?>
   </td>
 </tr>
 <tr> 
   <td>
     <table border="0" width="100%" cellspacing="0" cellpadding="2">
       <tr class="dataTableHeadingRow"> 
         <td class="dataTableHeadingContent" colspan="2"> 
           <?php echo TABLE_HEADING_PRODUCTS; ?>
         </td>
         <td class="dataTableHeadingContent"> 
           <?php echo TABLE_HEADING_PRODUCTS_MODEL; ?>
         </td>
         <td class="dataTableHeadingContent" align="right">  </td>
         <td class="dataTableHeadingContent" align="right">  </td>
         <td class="dataTableHeadingContent" align="right"> 
           <?php echo TABLE_HEADING_PRICE_INCLUDING_TAX; ?>
         </td>
         <td class="dataTableHeadingContent" align="right">  </td>
         <td class="dataTableHeadingContent" align="right"> 
           <?php echo TABLE_HEADING_TOTAL_INCLUDING_TAX; ?>
         </td>
       </tr>
       <?php
   for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) {
     echo '      <tr class="dataTableRow">' . "\n" .
          '        <td class="dataTableContent" valign="top" align="right">' . $order->products[$i]['qty'] . ' x</td>' . "\n" .
          '        <td class="dataTableContent" valign="top">' . $order->products[$i]['name'];

     if (isset($order->products[$i]['attributes']) && (($k = sizeof($order->products[$i]['attributes'])) > 0)) {
       for ($j = 0; $j < $k; $j++) {
         echo '<br><nobr><small> <i> - ' . $order->products[$i]['attributes'][$j]['option'] . ': ' . $order->products[$i]['attributes'][$j]['value'];
         if ($order->products[$i]['attributes'][$j]['price'] != '0') echo ' (' . $order->products[$i]['attributes'][$j]['prefix'] . $currencies->format($order->products[$i]['attributes'][$j]['price'] * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . ')';
         echo '</i></small></nobr>';
       }
     }
  
  $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>";
  }

     echo '        </td>' . "\n" .
          '        <td class="dataTableContent" valign="top">' . $order->products[$i]['model'] . '</td>' . "\n";
     echo '        <td class="dataTableContent" align="right" valign="top"></td>' . "\n" .
          '        <td class="dataTableContent" align="right" valign="top"></td>' . "\n" .
          '        <td class="dataTableContent" align="right" valign="top"><b>' . $currencies->format(tep_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']), true, $order->info['currency'], $order->info['currency_value']) . '</b></td>' . "\n" .
          '        <td class="dataTableContent" align="right" valign="top"></td>' . "\n" .
          '        <td class="dataTableContent" align="right" valign="top"><b>' . $currencies->format(tep_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']) * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . '</b></td>' . "\n";
     echo '      </tr>' . "\n";
   }
?>
       <tr> 
         <td align="right" colspan="8"> 
           <table border="0" cellspacing="0" cellpadding="2">
             <?php
 for ($i = 0, $n = sizeof($order->totals); $i < $n; $i++) {
   echo '          <tr>' . "\n" .
        '            <td align="right" class="smallText">' . $order->totals[$i]['title'] . '</td>' . "\n" .
        '            <td align="right" class="smallText">' . $order->totals[$i]['text'] . '</td>' . "\n" .
        '          </tr>' . "\n";
 }
?>
           </table>
         </td>
       </tr>
       <tr>
         <td class="smallText" colspan="8">
           <p>Thanks for your order! Don't forget you can view the status of 
             any of your past orders online.</p>
           <p> </p>
           </td>
       </tr>
       <tr> 
         <td class="smallText" colspan="8"> 
           <p>
             <?php echo nl2br(STORE_NAME_ADDRESS); ?>
           </p>
           </td>
       </tr>
     </table>
   </td>
 </tr>
</table>
<!-- body_text_eof //-->
<br>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

 

The other solution I see is adding another table to the database to hold bundle contents at order stage. The order process as it is at the moment creates so much data per order that I'd be hesitant to create more ...

:)

chris

Link to comment
Share on other sites

I'd love to know how to integrate this with Master Products so that the master may optionally be a bundle of its slave products.

 

You would see at the top of the page the description of the set with with the option to buy the complete set at a discounted price as it is possible to do in Master Products.

 

Below it would be decriptions for the individual compoments with their prices when purchased alone again just as in Master products.

 

The main difference would be that purchasing thwe master product would update the stock of the slaves.

 

Anyone know how to do this?

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...