Jump to content



Photo
- - - - -

Bundled products


  • Please log in to reply
330 replies to this topic

#21   CC

CC
  • Members
  • 1,289 posts
  • Real Name:....
  • Gender:Male
  • Location:Here \o/

Posted 16 April 2004 - 08:30

You can use this to run the creation of products_bundles:

CREATE TABLE `products_bundles` (
  `bundle_id` smallint(6) NOT NULL default '0',
  `subproduct_id` smallint(6) NOT NULL default '0',
  `subproduct_qty` tinyint(4) NOT NULL default '0',
  PRIMARY KEY  (`bundle_id`,`subproduct_id`)
) TYPE=MyISAM;


And just add this into products table:

`products_bundle` tinytext NOT NULL,


Talking a 30 second job.

CC.

#22   cdamianou

cdamianou
  • Members
  • 239 posts
  • Real Name:Costas

Posted 16 April 2004 - 12:23

Hi

Sorry if i have got this wrong.

I pressume i run the 2 above as 2 seperate SQL queries?

Thanks

#23   CC

CC
  • Members
  • 1,289 posts
  • Real Name:....
  • Gender:Male
  • Location:Here \o/

Posted 16 April 2004 - 12:32

Yes you can do that.

The first can be run from SQL heading in phpmyadmin, just copy paste and go.

The second you need something more like this if you dont know how to manually create the table:

ALTER TABLE `products` ADD `products_bundle` tinytext NOT NULL AFTER `manufacturers_id` ;


If you are going to get into OSC and adding/creating mods, I would suggest you make yourself familiar with phpMyAdmin, it is a major part of OSC if this is your chosen program for mySQL.

#24   CC

CC
  • Members
  • 1,289 posts
  • Real Name:....
  • Gender:Male
  • Location:Here \o/

Posted 16 April 2004 - 12:33

BTW - BACKUP before you do any of it!
First rule in ALL cases, BACKUP BACKUP BACKUP!!

...
Then backup some more. /wink.gif' class='bbc_emoticon' alt=';)' />

#25   whoiswes

whoiswes
  • Members
  • 12 posts
  • Real Name:Wes

Posted 16 April 2004 - 16:34

we are running an almost completely custom OSC install - this is one of the last major mods we wanna set up.

i had been working on my own version for a while until i did one last search and came up with this thread. i'm gonna install this sucker and see if it does what we need (and it sounds PERFECT!!!)

will post my impressions later! thanks!

#26   lushlongboards

lushlongboards
  • Members
  • 42 posts
  • Real Name:Chris

Posted 16 April 2004 - 16:37

cool /smile.gif' class='bbc_emoticon' alt=':)' />

I'd be interested to see some other sites that use this mod when you have it running ...

chris

#27   cdamianou

cdamianou
  • Members
  • 239 posts
  • Real Name:Costas

Posted 16 April 2004 - 17:32

So far so good however i have encountered a confusion at the following part that says

add
'products_bundle' => '',
after
$parameters = array('products_name' => '',

(line 358)

Dont understand this part.

Thanks

#28   cdamianou

cdamianou
  • Members
  • 239 posts
  • Real Name:Costas

Posted 16 April 2004 - 18:02

Update to my querys.

Its the following i do not understand

1)
add
'products_bundle' => '',
after
$parameters = array('products_name' => '',

(line 358)

2)
insert "p.products_bundle," into the SQL query one line below this one (LINE 377)

if (isset($HTTP_GET_VARS['pID']) && empty($HTTP_POST_VARS)) {

so the whole line shoud be:

$product_query = tep_db_query("select pd.products_name, pd.products_description, pd.products_url, p.products_id, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_date_added, p.products_last_modified, date_format(p.products_date_available, '%Y-%m-%d') as products_date_available, p.products_status, p.products_tax_class_id, p.manufacturers_id, p.products_bundle from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'");

3)
add

if (isset($pInfo->products_bundle) && $pInfo->products_bundle == "yes") {
// this product is a bundle so get contents data
$bundle_query = tep_db_query("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 = " . $pInfo->products_id . " and language_id = '" . (int)$languages_id . "'");
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']);
}
}

ten lines lower than the above SQL query, just after the closing curly bracket "}" and before the code section starting with

$manufacturers_array = array(array('id' => '', 'text' => ''));

4)
add

", p.products_bundle"

after

p.manufacturers_id

into the query on line 72, so the whole line is as follows:

$product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id, p.products_bundle from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");

5)
STEP 4 : create a table to store the bundle information.
Run this SQL in your phpMyAdmin to add the table automatically.
***************************************************************
CREATE TABLE `products_bundles` (`bundle_id` SMALLINT NOT NULL, `subproduct_id` SMALLINT NOT NULL, `subproduct_qty` TINYINT NOT NULL , PRIMARY KEY (`bundle_id`, `subproduct_id`))



Sorry if this is allot

Thanks In Advance

#29   a.niedermann

a.niedermann
  • Members
  • 139 posts
  • Real Name:Andreas Niedermann

Posted 17 April 2004 - 10:35

Hi!

Great mod. Unfortunately it wont work that good on my side.

every time I set an bundle in the categories.php it don't save any bundle product. The only field which is getting stored is the ("yes" or blank).

I checked the installation several times but I didn't found any bug yet.

If you have any idea about it, please let me know

Andreas

#30   lushlongboards

lushlongboards
  • Members
  • 42 posts
  • Real Name:Chris

Posted 19 April 2004 - 09:00

this looks like it could be something missed out while you are editing categories.php ...

I don't have a server where I can test this mod against a clean copy of OSC, but it looks like CC has got it working fine with the instructions I wrote.

chris

#31   a.niedermann

a.niedermann
  • Members
  • 139 posts
  • Real Name:Andreas Niedermann

Posted 19 April 2004 - 09:50

Hi Chris!

Well, that could be! Because I have made several modifications on categories.php. My categories before the bundle modification looks like this:

[quote]

<?php
/*
  $Id: categories.php,v 1.146 2003/07/11 14:40:27 hpdl Exp $

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

  Copyright © 2003 osCommerce

  Released under the GNU General Public License
 
  Modify for cieto Featured Products 2.5 MS2
  cieto@msn.com
*/

  require('includes/application_top.php');

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

  $action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');

  if (tep_not_null($action)) {
    switch ($action) {
      case 'setflag':
        if ( ($HTTP_GET_VARS['flag'] == '0') || ($HTTP_GET_VARS['flag'] == '1') ) {
          if (isset($HTTP_GET_VARS['pID'])) {
            tep_set_product_status($HTTP_GET_VARS['pID'], $HTTP_GET_VARS['flag']);
          }

          if (USE_CACHE == 'true') {
            tep_reset_cache_block('categories');
            tep_reset_cache_block('also_purchased');
          }
        }

        tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $HTTP_GET_VARS['cPath'] . '&pID=' . $HTTP_GET_VARS['pID']));
        break;
      case 'setflag_featured':
        if ( ($HTTP_GET_VARS['flag'] == '0') || ($HTTP_GET_VARS['flag'] == '1') ) {
          if (isset($HTTP_GET_VARS['pID'])) {
            tep_set_product_featured($HTTP_GET_VARS['pID'], $HTTP_GET_VARS['flag']);
          }

          if (USE_CACHE == 'true') {
            tep_reset_cache_block('categories');
            tep_reset_cache_block('also_purchased');
          }
        }

        tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $HTTP_GET_VARS['cPath'] . '&pID=' . $HTTP_GET_VARS['pID']));
        break;

      case 'insert_category':
      case 'update_category':
        if (isset($HTTP_POST_VARS['categories_id'])) $categories_id = tep_db_prepare_input($HTTP_POST_VARS['categories_id']);
        $sort_order = tep_db_prepare_input($HTTP_POST_VARS['sort_order']);

        $sql_data_array = array('sort_order' => $sort_order);

        if ($action == 'insert_category') {
          $insert_sql_data = array('parent_id' => $current_category_id,
                                  'date_added' => 'now()');

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

          tep_db_perform(TABLE_CATEGORIES, $sql_data_array);

          $categories_id = tep_db_insert_id();
        } elseif ($action == 'update_category') {
          $update_sql_data = array('last_modified' => 'now()');

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

          tep_db_perform(TABLE_CATEGORIES, $sql_data_array, 'update', "categories_id = '" . (int)$categories_id . "'");
        }

        $languages = tep_get_languages();
        for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
          $categories_name_array = $HTTP_POST_VARS['categories_name'];

          $language_id = $languages[$i]['id'];

          $sql_data_array = array('categories_name' => tep_db_prepare_input($categories_name_array[$language_id]));

          if ($action == 'insert_category') {
            $insert_sql_data = array('categories_id' => $categories_id,
                                    'language_id' => $languages[$i]['id']);

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

            tep_db_perform(TABLE_CATEGORIES_DESCRIPTION, $sql_data_array);
          } elseif ($action == 'update_category') {
            tep_db_perform(TABLE_CATEGORIES_DESCRIPTION, $sql_data_array, 'update', "categories_id = '" . (int)$categories_id . "' and language_id = '" . (int)$languages[$i]['id'] . "'");
  }
  }

        if (HTML_AREA_WYSIWYG_DISABLE == 'Disable') {
          if ($categories_image = new upload('categories_image', DIR_FS_CATALOG_IMAGES)) {
            tep_db_query("update " . TABLE_CATEGORIES . " set categories_image = '" . tep_db_input($categories_image->filename) . "' where categories_id = '" . (int)$categories_id . "'");
          }
        } else {
          if (isset($HTTP_POST_VARS['categories_image']) && tep_not_null($HTTP_POST_VARS['categories_image']) && ($HTTP_POST_VARS['categories_image'] != 'none')) {
            tep_db_query("update " . TABLE_CATEGORIES . " set categories_image = '" . tep_db_input($HTTP_POST_VARS['categories_image']) . "' where categories_id = '" . (int)$categories_id . "'");
          }
        }

        if (USE_CACHE == 'true') {
          tep_reset_cache_block('categories');
          tep_reset_cache_block('also_purchased');
        }

        tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $categories_id));
        break;
      case 'delete_category_confirm':
        if (isset($HTTP_POST_VARS['categories_id'])) {
          $categories_id = tep_db_prepare_input($HTTP_POST_VARS['categories_id']);

          $categories = tep_get_category_tree($categories_id, '', '0', '', true);
          $products = array();
          $products_delete = array();

          for ($i=0, $n=sizeof($categories); $i<$n; $i++) {
            $product_ids_query = tep_db_query("SELECT products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . (int)$categories[$i]['id'] . "'");

            while ($product_ids = tep_db_fetch_array($product_ids_query)) {
              $products[$product_ids['products_id']]['categories'][] = $categories[$i]['id'];
            }
          }

          reset($products);
          while (list($key, $value) = each($products)) {
            $category_ids = '';

            for ($i=0, $n=sizeof($value['categories']); $i<$n; $i++) {
              $category_ids .= "'" . (int)$value['categories'][$i] . "', ";
            }
            $category_ids = substr($category_ids, 0, -2);

            $check_query = tep_db_query("SELECT count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$key . "' and categories_id not in (" . $category_ids . ")");
            $check = tep_db_fetch_array($check_query);
            if ($check['total'] < '1') {
              $products_delete[$key] = $key;
            }
          }

// removing categories can be a lengthy process
          tep_set_time_limit(0);
          for ($i=0, $n=sizeof($categories); $i<$n; $i++) {
            tep_remove_category($categories[$i]['id']);
          }

          reset($products_delete);
          while (list($key) = each($products_delete)) {
            tep_remove_product($key);
          }
        }

        if (USE_CACHE == 'true') {
          tep_reset_cache_block('categories');
          tep_reset_cache_block('also_purchased');
        }

        tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath));
        break;
      case 'delete_product_confirm':
        if (isset($HTTP_POST_VARS['products_id']) && isset($HTTP_POST_VARS['product_categories']) && is_array($HTTP_POST_VARS['product_categories'])) {
          $product_id = tep_db_prepare_input($HTTP_POST_VARS['products_id']);
          $product_categories = $HTTP_POST_VARS['product_categories'];

          for ($i=0, $n=sizeof($product_categories); $i<$n; $i++) {
            tep_db_query("delete from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$product_id . "' and categories_id = '" . (int)$product_categories[$i] . "'");
          }

          $product_categories_query = tep_db_query("SELECT count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$product_id . "'");
          $product_categories = tep_db_fetch_array($product_categories_query);

          if ($product_categories['total'] == '0') {
            tep_remove_product($product_id);
          }
        }

        if (USE_CACHE == 'true') {
          tep_reset_cache_block('categories');
          tep_reset_cache_block('also_purchased');
        }

        tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath));
        break;
      case 'move_category_confirm':
        if (isset($HTTP_POST_VARS['categories_id']) && ($HTTP_POST_VARS['categories_id'] != $HTTP_POST_VARS['move_to_category_id'])) {
          $categories_id = tep_db_prepare_input($HTTP_POST_VARS['categories_id']);
          $new_parent_id = tep_db_prepare_input($HTTP_POST_VARS['move_to_category_id']);

          $path = explode('_', tep_get_generated_category_path_ids($new_parent_id));

          if (in_array($categories_id, $path)) {
            $messageStack->add_session(ERROR_CANNOT_MOVE_CATEGORY_TO_PARENT, 'error');

            tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $categories_id));
          } else {
            tep_db_query("update " . TABLE_CATEGORIES . " set parent_id = '" . (int)$new_parent_id . "', last_modified = now() where categories_id = '" . (int)$categories_id . "'");

            if (USE_CACHE == 'true') {
              tep_reset_cache_block('categories');
              tep_reset_cache_block('also_purchased');
            }

            tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $new_parent_id . '&cID=' . $categories_id));
          }
        }

        break;
      case 'move_product_confirm':
        $products_id = tep_db_prepare_input($HTTP_POST_VARS['products_id']);
        $new_parent_id = tep_db_prepare_input($HTTP_POST_VARS['move_to_category_id']);

        $duplicate_check_query = tep_db_query("SELECT count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$products_id . "' and categories_id = '" . (int)$new_parent_id . "'");
        $duplicate_check = tep_db_fetch_array($duplicate_check_query);
        if ($duplicate_check['total'] < 1) tep_db_query("update " . TABLE_PRODUCTS_TO_CATEGORIES . " set categories_id = '" . (int)$new_parent_id . "' where products_id = '" . (int)$products_id . "' and categories_id = '" . (int)$current_category_id . "'");

        if (USE_CACHE == 'true') {
          tep_reset_cache_block('categories');
          tep_reset_cache_block('also_purchased');
        }

        tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $new_parent_id . '&pID=' . $products_id));
        break;
      case 'insert_product':
      case 'update_product':
        if (isset($HTTP_POST_VARS['edit_x']) || isset($HTTP_POST_VARS['edit_y'])) {
          $action = 'new_product';
        } else {
          if (isset($HTTP_GET_VARS['pID'])) $products_id = tep_db_prepare_input($HTTP_GET_VARS['pID']);
          $products_date_available = tep_db_prepare_input($HTTP_POST_VARS['products_date_available']);

          $products_date_available = (date('Y-m-d') < $products_date_available) ? $products_date_available : 'null';

          $sql_data_array = array('products_quantity' => tep_db_prepare_input($HTTP_POST_VARS['products_quantity']),
                                  'products_model' => tep_db_prepare_input($HTTP_POST_VARS['products_model']),
                                  'products_price' => tep_db_prepare_input($HTTP_POST_VARS['products_price']),
                                  'products_date_available' => $products_date_available,
                                  'products_weight' => tep_db_prepare_input($HTTP_POST_VARS['products_weight']),
         
          'products_isbn' => tep_db_prepare_input($HTTP_POST_VARS['products_isbn']),
          'products_versandfertig' => tep_db_prepare_input($HTTP_POST_VARS['products_versandfertig']),
          'products_sonstiges' => tep_db_prepare_input($HTTP_POST_VARS['products_sonstiges']),
          'products_verlag' => tep_db_prepare_input($HTTP_POST_VARS['products_verlag']),
          'products_auflage' => tep_db_prepare_input($HTTP_POST_VARS['products_auflage']),
          'products_autor' => tep_db_prepare_input($HTTP_POST_VARS['products_autor']),
         
         
                                  'products_featured' => tep_db_prepare_input($HTTP_POST_VARS['products_featured']),
                                  'products_status' => tep_db_prepare_input($HTTP_POST_VARS['products_status']),
                                  'products_tax_class_id' => tep_db_prepare_input($HTTP_POST_VARS['products_tax_class_id']),
                                  'manufacturers_id' => tep_db_prepare_input($HTTP_POST_VARS['manufacturers_id']));

          if (isset($HTTP_POST_VARS['products_image']) && tep_not_null($HTTP_POST_VARS['products_image']) && ($HTTP_POST_VARS['products_image'] != 'none')) {
            $sql_data_array['products_image'] = tep_db_prepare_input($HTTP_POST_VARS['products_image']);
          }

          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();

            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()');

            $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 . "'");
          }

          $languages = tep_get_languages();
          for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
            $language_id = $languages[$i]['id'];

            $sql_data_array = array('products_name' => tep_db_prepare_input($HTTP_POST_VARS['products_name'][$language_id]),
                                    'products_short' => tep_db_prepare_input($HTTP_POST_VARS['products_short'][$language_id]),
                                    'products_description' => tep_db_prepare_input($HTTP_POST_VARS['products_description'][$language_id]),
                                    'products_url' => tep_db_prepare_input($HTTP_POST_VARS['products_url'][$language_id]));

            if ($action == 'insert_product') {
              $insert_sql_data = array('products_id' => $products_id,
                                      'language_id' => $language_id);

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

              tep_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array);
            } elseif ($action == 'update_product') {
              tep_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array, 'update', "products_id = '" . (int)$products_id . "' and language_id = '" . (int)$language_id . "'");
            }
          }

          if (USE_CACHE == 'true') {
            tep_reset_cache_block('categories');
            tep_reset_cache_block('also_purchased');
          }

          tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products_id));
        }
        break;
      case 'copy_to_confirm':
        if (isset($HTTP_POST_VARS['products_id']) && isset($HTTP_POST_VARS['categories_id'])) {
          $products_id = tep_db_prepare_input($HTTP_POST_VARS['products_id']);
          $categories_id = tep_db_prepare_input($HTTP_POST_VARS['categories_id']);

          if ($HTTP_POST_VARS['copy_as'] == 'link') {
            if ($categories_id != $current_category_id) {
              $check_query = tep_db_query("SELECT count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$products_id . "' and categories_id = '" . (int)$categories_id . "'");
              $check = tep_db_fetch_array($check_query);
              if ($check['total'] < '1') {
                tep_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id) values ('" . (int)$products_id . "', '" . (int)$categories_id . "')");
              }
            } else {
              $messageStack->add_session(ERROR_CANNOT_LINK_TO_SAME_CATEGORY, 'error');
            }
          } elseif ($HTTP_POST_VARS['copy_as'] == 'duplicate') {
            $product_query = tep_db_query("SELECT products_quantity, products_model, products_image, products_price, products_date_available, products_weight, products_isbn, products_versandfertig, products_sonstiges, products_verlag, products_auflage, products_autor, products_tax_class_id, manufacturers_id from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
            $product = tep_db_fetch_array($product_query);

            tep_db_query("insert into " . TABLE_PRODUCTS . " (products_quantity, products_model,products_image, products_price, products_date_added, products_date_available, products_weight, products_isbn, products_versandfertig, products_sonstiges, products_verlag, products_auflage, products_autor, products_status, products_featured, products_tax_class_id, manufacturers_id) values ('" . tep_db_input($product['products_quantity']) . "', '" . tep_db_input($product['products_model']) . "', '" . tep_db_input($product['products_image']) . "', '" . tep_db_input($product['products_featured']) . "', '" . tep_db_input($product['products_price']) . "',  now(), '" . tep_db_input($product['products_date_available']) . "', '" . tep_db_input($product['products_weight']) . "', '0',  '" . tep_db_input($product['products_isbn']) . "', '" . tep_db_input($product['products_versandfertig']) . "', '" . tep_db_input($product['products_sonstiges']) . "', '" . tep_db_input($product['products_verlag']) . "','" . tep_db_input($product['products_auflage']) . "', '" . tep_db_input($product['products_autor']) . "','" . (int)$product['products_tax_class_id'] . "', '" . (int)$product['manufacturers_id'] . "')");
            $dup_products_id = tep_db_insert_id();

            $description_query = tep_db_query("SELECT language_id, products_name, products_description, products_short, products_url from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$products_id . "'");
            while ($description = tep_db_fetch_array($description_query)) {
              tep_db_query("insert into " . TABLE_PRODUCTS_DESCRIPTION . " (products_id, language_id, products_name, products_description, products_short, products_url, products_viewed) values ('" . (int)$dup_products_id . "', '" . (int)$description['language_id'] . "', '" . tep_db_input($description['products_name']) . "', '" . tep_db_input($description['products_description']) . "', '" . tep_db_input($description['products_short']) . "', '" . tep_db_input($description['products_url']) . "', '0')");
            }

            tep_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id) values ('" . (int)$dup_products_id . "', '" . (int)$categories_id . "')");
            $products_id = $dup_products_id;
          }

          if (USE_CACHE == 'true') {
            tep_reset_cache_block('categories');
            tep_reset_cache_block('also_purchased');
          }
        }

        tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $categories_id . '&pID=' . $products_id));
        break;
      case 'new_product_preview':
        if (HTML_AREA_WYSIWYG_DISABLE == 'Disable') {
          // copy image only if modified
          $products_image = new upload('products_image');
          $products_image->set_destination(DIR_FS_CATALOG_IMAGES);
          if ($products_image->parse() && $products_image->save()) {
            $products_image_name = $products_image->filename;
          } else {
            $products_image_name = (isset($HTTP_POST_VARS['products_previous_image']) ? $HTTP_POST_VARS['products_previous_image'] : '');
          }
        } else {
          if (isset($HTTP_POST_VARS['products_image']) && tep_not_null($HTTP_POST_VARS['products_image']) && ($HTTP_POST_VARS['products_image'] != 'none')) {
            $products_image_name = $HTTP_POST_VARS['products_image'];
          } else {
            $products_image_name = (isset($HTTP_POST_VARS['products_previous_image']) ? $HTTP_POST_VARS['products_previous_image'] : '');
          }
        }
        break;
    }
  }

// check if the catalog image directory exists
  if (is_dir(DIR_FS_CATALOG_IMAGES)) {
    if (!is_writeable(DIR_FS_CATALOG_IMAGES)) $messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_NOT_WRITEABLE, 'error');
  } else {
    $messageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_DOES_NOT_EXIST, 'error');
  }
?>
<!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>

        <script language="Javascript1.2"><!-- // load htmlarea
// MaxiDVD Added WYSIWYG HTML Area Box + Admin Function v1.7 - 2.2 MS2 Products Description HTML - Head
        _editor_url = "<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_ADMIN; ?>htmlarea/";  // URL to htmlarea files
          var win_ie_ver = parseFloat(navigator.appVersion.split("MSIE")[1]);
          if (navigator.userAgent.indexOf('Mac')        >= 0) { win_ie_ver = 0; }
            if (navigator.userAgent.indexOf('Windows CE') >= 0) { win_ie_ver = 0; }
            if (navigator.userAgent.indexOf('Opera')      >= 0) { win_ie_ver = 0; }
        <?php if (HTML_AREA_WYSIWYG_BASIC_PD == 'Basic'){ ?>  if (win_ie_ver >= 5.5) {
        document.write('<scr' + 'ipt src="' +_editor_url+ 'editor_basic.js"');
        document.write(' language="Javascript1.2"></scr' + 'ipt>');
            } else { document.write('<scr'+'ipt>function editor_generate() { return false; }</scr'+'ipt>'); }
        <?php } else{ ?> if (win_ie_ver >= 5.5) {
        document.write('<scr' + 'ipt src="' +_editor_url+ 'editor_advanced.js"');
        document.write(' language="Javascript1.2"></scr' + 'ipt>');
            } else { document.write('<scr'+'ipt>function editor_generate() { return false; }</scr'+'ipt>'); }
        <?php }?>
// --></script>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<script language="javascript" src="includes/general.js"></script>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="SetFocus();">
<div id="spiffycalendar" class="text"></div>
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
  <tr>
    <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
    </table></td>
<!-- body_text //-->
    <td width="100%" valign="top">
<?php
  if ($action == 'new_product') {
    $parameters = array('products_name' => '',
                      'products_short' => '',
                      'products_description' => '',
                      'products_url' => '',
                      'products_id' => '',
                      'products_quantity' => '',
                      'products_model' => '',
                      'products_image' => '',
                      'products_price' => '',
                      'products_weight' => '',
       
        'products_isbin' =>'',
        'products_versandfertig'=>'',
        'products_sonstiges'=>'',
        'products_verlag'=>'',
        'products_auflage'=>'',
        'products_autor'=>'',
       
       
       
       
       
       
       
                      'products_date_added' => '',
                      'products_last_modified' => '',
                      'products_date_available' => '',
                      'products_featured' => '',
                      'products_status' => '',
                      'products_tax_class_id' => '',
                      'manufacturers_id' => '');

    $pInfo = new objectInfo($parameters);

    if (isset($HTTP_GET_VARS['pID']) && empty($HTTP_POST_VARS)) {
      $product_query = tep_db_query("SELECT pd.products_name, pd.products_description, pd.products_short, pd.products_url, p.products_id, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_isbn, p.products_versandfertig, p.products_sonstiges, p.products_verlag, p.products_auflage, p.products_autor, p.products_date_added, p.products_last_modified, date_format(p.products_date_available, '%Y-%m-%d') as products_date_available, p.products_status, p.products_featured, p.products_tax_class_id, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'");
      $product = tep_db_fetch_array($product_query);

      $pInfo->objectInfo($product);
    } elseif (tep_not_null($HTTP_POST_VARS)) {
      $pInfo->objectInfo($HTTP_POST_VARS);
      $products_name = $HTTP_POST_VARS['products_name'];
      $products_short = $HTTP_POST_VARS['products_short'];
      $products_description = $HTTP_POST_VARS['products_description'];
      $products_url = $HTTP_POST_VARS['products_url'];
    }

    $manufacturers_array = array(array('id' => '', 'text' => TEXT_NONE));
    $manufacturers_query = tep_db_query("SELECT manufacturers_id, manufacturers_name from " . TABLE_MANUFACTURERS . " order by manufacturers_name");
    while ($manufacturers = tep_db_fetch_array($manufacturers_query)) {
      $manufacturers_array[] = array('id' => $manufacturers['manufacturers_id'],
                                    'text' => $manufacturers['manufacturers_name']);
    }

    $tax_class_array = array(array('id' => '0', 'text' => TEXT_NONE));
    $tax_class_query = tep_db_query("SELECT tax_class_id, tax_class_title from " . TABLE_TAX_CLASS . " order by tax_class_title");
    while ($tax_class = tep_db_fetch_array($tax_class_query)) {
      $tax_class_array[] = array('id' => $tax_class['tax_class_id'],
                                'text' => $tax_class['tax_class_title']);
    }

    $languages = tep_get_languages();

    if (!isset($pInfo->products_status)) $pInfo->products_status = '1';
    switch ($pInfo->products_status) {
      case '0': $in_status = false; $out_status = true; break;
      case '1':
      default: $in_status = true; $out_status = false;
    }
    if (!isset($pInfo->products_featured)) $pInfo->products_featured = '1';
    switch ($pInfo->products_featured) {
      case '0': $in_status = false; $out_status = true; break;
      case '1':
      default: $in_status = true; $out_status = false;
    }

?>
<link rel="stylesheet" type="text/css" href="includes/javascript/spiffyCal/spiffyCal_v2_1.css">
<script language="JavaScript" src="includes/javascript/spiffyCal/spiffyCal_v2_1.js"></script>
<script language="JavaScript"><!--
  var dateAvailable = new ctlSpiffyCalendarBox("dateAvailable", "new_product", "products_date_available","btnDate1","<?php echo $pInfo->products_date_available; ?>", scBTNMODE_CUSTOMBLUE);
//--></script>
<script language="javascript"><!--
var tax_rates = new Array();
<?php
    for ($i=0, $n=sizeof($tax_class_array); $i<$n; $i++) {
      if ($tax_class_array[$i]['id'] > 0) {
        echo 'tax_rates["' . $tax_class_array[$i]['id'] . '"] = ' . tep_get_tax_rate_value($tax_class_array[$i]['id']) . ';' . "\n";
      }
    }
?>

function doRound(x, places) {
  return Math.round(x * Math.pow(10, places)) / Math.pow(10, places);
}

function getTaxRate() {
  var selected_value = document.forms["new_product"].products_tax_class_id.selectedIndex;
  var parameterVal = document.forms["new_product"].products_tax_class_id[selected_value].value;

  if ( (parameterVal > 0) && (tax_rates[parameterVal] > 0) ) {
    return tax_rates[parameterVal];
  } else {
    return 0;
  }
}

function updateGross() {
  var taxRate = getTaxRate();
  var grossValue = document.forms["new_product"].products_price.value;

  if (taxRate > 0) {
    grossValue = grossValue * ((taxRate / 100) + 1);
  }

  document.forms["new_product"].products_price_gross.value = doRound(grossValue, 4);
}

function updateNet() {
  var taxRate = getTaxRate();
  var netValue = document.forms["new_product"].products_price_gross.value;

  if (taxRate > 0) {
    netValue = netValue / ((taxRate / 100) + 1);
  }

  document.forms["new_product"].products_price.value = doRound(netValue, 4);
}
//--></script>
    <?php echo tep_draw_form('new_product', FILENAME_CATEGORIES, 'cPath=' . $cPath . (isset($HTTP_GET_VARS['pID']) ? '&pID=' . $HTTP_GET_VARS['pID'] : '') . '&action=new_product_preview', 'post', 'enctype="multipart/form-data"'); ?>
    <table border="0" width="100%" cellspacing="0" cellpadding="2">
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td class="pageHeading"><?php echo sprintf(TEXT_NEW_PRODUCT, tep_output_generated_category_path($current_category_id)); ?></td>
            <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
      </tr>
      <tr>
        <td><table border="0" cellspacing="0" cellpadding="2">
          <tr>
            <td class="main"><?php echo TEXT_PRODUCTS_STATUS; ?></td>
            <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . tep_draw_radio_field('products_status', '1', $in_status) . '&nbsp;' . TEXT_PRODUCT_AVAILABLE . '&nbsp;' . tep_draw_radio_field('products_status', '0', $out_status) . '&nbsp;' . TEXT_PRODUCT_NOT_AVAILABLE; ?></td>
          </tr>

          <tr>
            <td class="main">Featured<?php echo TEXT_PRODUCTS_STATUS; ?></td>
            <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . tep_draw_radio_field('products_featured', '1', $in_status) . '&nbsp;' . TEXT_PRODUCT_AVAILABLE . '&nbsp;' . tep_draw_radio_field('products_featured', '0', $out_status) . '&nbsp;' . TEXT_PRODUCT_NOT_AVAILABLE; ?></td>
          </tr>
          <tr>
            <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
          </tr>
          <tr>
            <td class="main"><?php echo TEXT_PRODUCTS_DATE_AVAILABLE; ?><br><small>(YYYY-MM-DD)</small></td>
            <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;'; ?><script language="javascript">dateAvailable.writeControl(); dateAvailable.dateFormat="yyyy-MM-dd";</script></td>
          </tr>
          <tr>
            <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
          </tr>
       
         
<?php
    for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
?>
          <tr>
            <td class="main"><?php if ($i == 0) echo TEXT_PRODUCTS_NAME; ?></td>
            <td class="main"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' . tep_draw_input_field('products_name[' . $languages[$i]['id'] . ']', (isset($products_name[$languages[$i]['id']]) ? $products_name[$languages[$i]['id']] : tep_get_products_name($pInfo->products_id, $languages[$i]['id']))); ?></td>
          </tr>
<?php
    }
?>
          <tr>
            <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
          </tr>
         
          <tr bgcolor="#ebebff">
            <td class="main"><?php echo TEXT_PRODUCTS_PRICE_NET; ?></td>
            <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . tep_draw_input_field('products_price', $pInfo->products_price, 'onKeyUp="updateGross()"'); ?></td>
          </tr>
       
<script language="javascript"><!--
updateGross();
//--></script>


<?php
    for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
?>
          <tr>
            <td class="main" valign="top"><?php if ($i == 0) echo TEXT_PRODUCTS_DESCRIPTION; ?></td>
            <td><table border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td class="main" valign="top"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']); ?>&nbsp;</td>
                <td class="main"><?php echo tep_draw_textarea_field('products_description[' . $languages[$i]['id'] . ']', 'soft', '70', '15', (isset($products_description[$languages[$i]['id']]) ? $products_description[$languages[$i]['id']] : tep_get_products_description($pInfo->products_id, $languages[$i]['id']))); ?></td>
              </tr>
            </table></td>
          </tr>
<?php
    }
?>
          <tr>
            <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
          </tr>
          <tr>
            <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
          </tr>
        <tr>
            <td class="main"><?php echo TEXT_PRODUCTS_IMAGE; ?></td>
        <?php if (HTML_AREA_WYSIWYG_DISABLE == 'Disable') { ?>
            <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . tep_draw_file_field('products_image') . '<br>' . tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . $pInfo->products_image . tep_draw_hidden_field('products_previous_image', $pInfo->products_image); ?></td>
        <?php }else{ ?>
            <td class="main"><?php echo '<table border="0" cellspacing="0" cellpadding="0"><tr><td class="main">' . tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp; </td><td class="main">' . tep_draw_textarea_field('products_image', 'soft', '70', '2', $pInfo->products_image) . tep_draw_hidden_field('products_previous_image', $pInfo->products_image) . '</td></tr></table>'; ?></td>
        <?php } ?>
          </tr>
          <tr>
            <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
          </tr>
          <tr>
            <td class="main"><?php echo 'ISBN-Nummer:'; ?></td>
            <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . tep_draw_input_field('products_isbn', $pInfo->products_isbn); ?></td>
          </tr>
          <tr>
            <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
          </tr>   
   
            <tr>
            <td class="main"><?php echo 'Autor'; ?></td>
            <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . tep_draw_input_field('products_autor', $pInfo->products_autor); ?></td>
          </tr>
          <tr>
            <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
          </tr> 
            <tr>
            <td class="main"><?php echo 'Verlag:'; ?></td>
            <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . tep_draw_input_field('products_verlag', $pInfo->products_verlag); ?></td>
          </tr>
          <tr>
            <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
          </tr> 
            <tr>
            <td class="main"><?php echo 'Auflage:'; ?></td>
            <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . tep_draw_input_field('products_auflage', $pInfo->products_auflage); ?></td>
          </tr>
          <tr>
            <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
          </tr> 
   
            <tr>
            <td class="main"><?php echo 'Sonstiges'; ?></td>
            <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . tep_draw_input_field('products_sonstiges', $pInfo->products_sonstiges); ?></td>
          </tr>
          <tr>
            <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
          </tr> 
   
            <tr>
            <td class="main"><?php echo 'Versandfertig:'; ?></td>
            <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . tep_draw_input_field('products_versandfertig', $pInfo->products_versandfertig); ?></td>
          </tr>
          <tr>
            <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
          </tr> 
   
   
   
   
   
   
   
   
              <tr>
            <td class="main"><?php echo TEXT_PRODUCTS_WEIGHT; ?></td>
            <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . tep_draw_input_field('products_weight', $pInfo->products_weight); ?></td>
          </tr>
    <tr>
            <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
          </tr> 
    <tr>
            <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
          </tr> 
   
   
    <?php
    for ($i=0, $n=

#32   cdamianou

cdamianou
  • Members
  • 239 posts
  • Real Name:Costas

Posted 19 April 2004 - 12:15

Hi

Is their anyone willing to atempt this instelation for me?

Of course you will be rewarded.

Thanks in advance

#33   lushlongboards

lushlongboards
  • Members
  • 42 posts
  • Real Name:Chris

Posted 20 April 2004 - 08:54

Andreas - can you post your categories.php after you have modified it and I'll see if I can spot anything.

chris

#34   whoiswes

whoiswes
  • Members
  • 12 posts
  • Real Name:Wes

Posted 20 April 2004 - 17:09

Chris (and everyone else)...

I installed the Bundled Products mod two days ago in the hopes it would be the answer to our problem of needing a one to many relationship between components and products.

It has! Although it doesn't do everything we need it to, I have been able to mod our existing scripts so that our system is finally 100% functional.

I had created a script that did basically the same thing that your mod does, but couldn't figure out how to update the shopping cart quantities to accurately reflect the current stock level of a product, based on the subproduct quantities. In other words, we wanted to limit a customer to adding ONLY the number of products we have on hand. Before I looked at your mod, I couldn't get my head wrapped around the problem, and couldn't find a way to keep a running total of what subproducts were in the cart, and the quantity remaining on each.

After having a lightbulb go off, I am using some session variables as temporary containers to keep track of our subproduct quantities during the shopping process. If it sounds complicated it is, and it's taken several days of brain melting to get to this point. The reason I am telling you all of this is because installing your mod gave me the idea and allowed us to finish this particular part of the project.

For that, I am incredibly thankful. My previous solution was almost exactly the same as yours but for some reason, your solution gave me the idea that worked out in the end.

If anyone wants to know more, I will do what I can. Most of you could probably do a much better job than I have - I am not an expert by any means, but am learning more and more every day, even after two years of using PHP almost daily...

Thanks again!!!

Wes

#35   bruyndoncx

bruyndoncx

    osCommerce Teenager

  • Members
  • 3,111 posts
  • Real Name:Carine Bruyndoncx
  • Gender:Female
  • Location:Belgium/ Antwerp/ Turnhout/ Arendonk

Posted 24 April 2004 - 13:59

Great mod. Unfortunately it wont work that good on my side.
every time I set an bundle in the categories.php it don't save any bundle product. The only field which is getting stored is the ("yes" or blank).

Hi,
I installed this mod without too many problems yesterday. The described issue I encountered when I copied an existing bundle, when creating a bundle from scratch I have not encountered this issue.

Additionally, I found the following limitations:
- special prices not taken into account (fixed it)
- no language support (working on this)
Don't just sit there - contribute to the responsive bootstrap community effort !
http://forums.oscomm...iew__getnewpost


Hava a nice day !
Carine Bruyndoncx


Seen anything good relevant on the net about responsive design for ecommerce ?
You might as well post it in my responsive liive shop review thread .

#36   fzx5v0

fzx5v0
  • Members
  • 83 posts
  • Real Name:Grant Lithgow

Posted 25 April 2004 - 19:29

I installed this mod tonight and now can not edit any existing products but can add new get this error when i try to edit a product

can anyone help

Warning: reset(): Passed variable is not an array or object in /data/members/paid/e/a/easyinkz.co.uk/htdocs/www/admin/includes/classes/object_info.php on line 17

Warning: Variable passed to each() is not an array or object in /data/members/paid/e/a/easyinkz.co.uk/htdocs/www/admin/includes/classes/object_info.php on line 18

thanks

#37   langers

langers
  • Members
  • 46 posts
  • Real Name:Richard Lang

Posted 26 April 2004 - 08:09

Installed this with no problems on a heavily modded site.

Only problem for me is that there is no support for attributes /sad.gif' class='bbc_emoticon' alt=':(' />

#38   safoo

safoo
  • Members
  • 514 posts
  • Real Name:Safoo

Posted 26 April 2004 - 12:29

I finally got around to installing this contribution. The instructions are so simple and I had no problems getting this to work without any erros on my heavily modded site.

The only issue I am having is that when I go to 'edit' a bundle product in admin, the java fields for the bundles are empty and I have to re-enter the information. Shouldn't the bundle ='yes' field and the slave products hold their value when I go to edit the bundle? It creates the bundle correctly, the only issue is in editing the product.

Andreas...did you correct your problem?

( I am double checking my categories.php just to make sure I didn't make any errors in copying the code)

Edited by safoo, 26 April 2004 - 12:32.


#39   safoo

safoo
  • Members
  • 514 posts
  • Real Name:Safoo

Posted 26 April 2004 - 12:44

Edit:

Found the problem.

In the categories.php, for the part where I added

$product_query = tep_db_query("select pd.products_name...

I had that line a few lines underneath, and not next line after the IF statement. So the old query was still being used since it was a few lines below..

Andreas, make sure that you do not have the "$product_query = tep_db_query..." twice in your code.

bruyndoncx

Could you share your code to have the savings shown to the customer reflect the sale price of the bundle. It still calculates using the regular price of the slave products and the specials price of the master product correct?

Also, to make the bundles copy over when you duplicate a product could work if you look for the code in categories.php inside the " elseif ($HTTP_POST_VARS['copy_as'] == 'duplicate') " statement.

Thanks in advance.

Edited by safoo, 26 April 2004 - 12:49.


#40   bruyndoncx

bruyndoncx

    osCommerce Teenager

  • Members
  • 3,111 posts
  • Real Name:Carine Bruyndoncx
  • Gender:Female
  • Location:Belgium/ Antwerp/ Turnhout/ Arendonk

Posted 26 April 2004 - 14:20

My bundle code in product_info.php looks now like this - note there are some more cosmetic changes ... but special sections are flagged as "//CB" ...

<!-- 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 = " . tep_get_prid($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>&raquo; <b>" . $bundle_data['subproduct_qty'] . " x " . $bundle_data['products_name'] . "</b>";
    //echo "<br>&raquo; <b> " . $bundle_data['products_name'] . "</b>";

                                        echo '<tr><td valign="top" class="main">&raquo; <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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . $bundle_data_nested['subproduct_qty'] . " x " . $bundle_data_nested['products_name'] . "</i>";
      //echo "<br><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . $bundle_data_nested['products_name'] . "</i>";

                                        echo '<tr><td valign="top" class="main">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<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>&raquo; <b>" . $bundle_data['subproduct_qty'] . " x " . $bundle_data['products_name'] . "</b>";
    //echo "<br>&raquo; <b> " . $bundle_data['products_name'] . "</b>";

                                        echo '<tr><td valign="top" class="main">&raquo; <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 -->


Also internationalized it eg languages/english/product_info.php added:

define('TEXT_BUNDLE_CONTENTS', 'This product contains the following items: ');
define('TEXT_BUNDLE_SUM', 'Cost of separate parts: ');
define('TEXT_BUNDLE_SAVINGS', 'You save: ');


Cheers
Don't just sit there - contribute to the responsive bootstrap community effort !
http://forums.oscomm...iew__getnewpost


Hava a nice day !
Carine Bruyndoncx


Seen anything good relevant on the net about responsive design for ecommerce ?
You might as well post it in my responsive liive shop review thread .