Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Buy_Two_Module


Guest

Recommended Posts

Hi,

 

Still nothing appears.

 

No errors  whatsoever.

 

1. What php file is showing in the browser bar when the blank sreen appears ?

 

2. After the line of code I suggested add a phpinfo() like this:

 

if (function_exists('ini_set')) @ini_set('display_errors', 'On');
phpinfo();

 

3. When the blank page appears, what are the contents of a "view/source' ??

 

Peter

Edited by peterr
Link to comment
Share on other sites

  • Replies 179
  • Created
  • Last Reply

Top Posters In This Topic

Hi Kai,

 

Can you please advise about a stylesheet class called "ProductInfoImage" ??

 

It is referenced in /catalog/includes/modules/buy_two_module.php , however isn't in the stylesheet, or the stlesheet mods ?

 

Thanks,

 

Peter

 

 

Here is the code for ProductInfoImage

 

 

A.ProductInfoImage {
 font-family: Verdana, Arial, sans-serif;
 font-size: 10px;
 color: Maroon;
 text-decoration: none;
}

A.ProductInfoImage:hover {
 font-family: Verdana, Arial, sans-serif;
 font-size: 10px;
 color: #000000;
 text-decoration: underline;
}

Link to comment
Share on other sites

Here is the link of the Blank Page

 

 

http://localhost/sec/product_info.php?perfume-oil=Oudh&products_id=95&action=buy_tinn&buy_tinn_add=105&osCsid=0fdb1c7f2cbefd9776664b3c81c965ae&auroranien=http://www.auroranien.de

 

 

And when i Viewed the source of that blank page.

 

Is was empty.

Link to comment
Share on other sites

Hi,

 

I'm using version 1.08 of this contribution, and today, trying to track down some other errors (i.e. not this contrib.), I turned on error logging, and when I clicked the 'buy now' of the bundled discount, got the following warning message:

 

Warning: Missing argument 4 for add_cart() in /includes/classes/shopping_cart.php on line 79

 

Warning: Cannot modify header information - headers already sent by (output started at /includes/classes/shopping_cart.php:79) in /includes/functions/general.php on line 78

 

After looking at /includes/application_top.php , and how other 'case' statements called the add_cart() function, I modified the code for the 'buy_tinn' , tested an order that had a bundle in it, and no warning message, the order went through successfully. Here is the modified code for /includes/application_top.php

 

                            // Total-Inn Buy_two_module (2155) begin
     case 'buy_tinn' :       if (isset($HTTP_GET_VARS['products_id'])) {
                               if (BUY_TWO_DISCOUNT_BUNDLE == 'normal') {
                                 if ($HTTP_GET_VARS['buy_tinn_add']) {
                                    $cart->add_cart($HTTP_GET_VARS['buy_tinn_add'],  $cart->get_quantity($HTTP_GET_VARS['buy_tinn_add']) +1,'',$HTTP_GET_VARS['category_id']);
                                 }
                                 if (tep_has_product_attributes($HTTP_GET_VARS['products_id'])) {
                                    tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' .$HTTP_GET_VARS['products_id']));
                                 } else {
                                    $cart->add_cart($HTTP_GET_VARS['products_id'], $cart->get_quantity($HTTP_GET_VARS['products_id']) +1,'',$HTTP_GET_VARS['category_id']);
                                 }
                               } elseif (BUY_TWO_DISCOUNT_BUNDLE =='discount') {
                                   $bundle_products_id = tep_set_bundle($HTTP_GET_VARS['products_id'],$HTTP_GET_VARS['buy_tinn_add'],BUY_TWO_BUNDLE_DISCOUNT_RATE);
                                   $cart->add_cart($bundle_products_id, $cart->get_quantity($bundle_products_id) +1,'',$HTTP_GET_VARS['category_id']);
                               }
                             }
                             tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
                             break;
                             // Total-Inn Buy_two_module (2155) end

 

Hope that helps,

 

Peter

Link to comment
Share on other sites

  • 2 weeks later...

How to avoid bundling a bundle?

 

I'm getting bundles that include bundles, with compounded discounts. Is there somewhere in the BUY_TWO_MODULE that turns off the bundle feature when viewing a bundle?

 

This is serious... I want to offer 10% off a bundle, but when they bundle a bundle, they get 18% off the combination... not good.

Link to comment
Share on other sites

Hi,

 

We are getting some serious "database bloat" since using this contribution. The table "customers_basket" has over 28,000 rows, the bulk of those rows added in the last 2 weeks.

 

The row content is:

 

customer_id 0

customer_basket_quantity 0

final_price 0.0000

category_id NULL

 

We are using version 1.08, no doubt I should check out version 1.09

 

Thanks,

 

Peter

Link to comment
Share on other sites

Hi,

 

peter, its the same here

 

The bundles are being added at a very fast pace.

 

They are all being added to the product table

 

is there a fix for this.

 

Actually, the problem I mentioned was for the "customers_basket" table, however I just ran this sql query:

 

SELECT products_model FROM `products` ORDER BY products_model;

 

.. and yes, there are bundled products there, I can see quite a few duplicate product model numbers, and by the number of rows, something is up ??

 

I will try and have a look at it, for now though, I'm more concerned about the db bloat, the total size has jumped by quite a few Mb in just a week or so. :(

 

Peter

Link to comment
Share on other sites

Hi,

 

Lines 451 to 457 of /catalog/includes/functions/buy_two_func.php , would do it, as follows:

 

if (BUY_TWO_BIG_IMAGE == 'yes'){
$bundle_sql_insert_image = 'products_image, products_bimage';
tep_db_query("insert into " . TABLE_PRODUCTS . " (products_quantity, products_model, ".$bundle_sql_insert_image.", products_price, products_date_added, products_date_available, products_weight, products_status, products_tax_class_id, manufacturers_id".$bundle_custom_extensions.", products_bundle_status) values ('".BUY_TWO_BUNDLE_QUANTITY."','".$bundle_model_name."','".$bundle_image_name."','".$bundle_image_name_large."','".$bundle_normal_price."', now(),'".$bundle_products_a['products_date_available']."','". $bundle_weight."', '0','". $bundle_products_a['products_tax_class_id']."','".$bundle_manufacturer.$bundle_custom_extensions_value."', '1')");
} elseif (BUY_TWO_BIG_IMAGE == 'no') {
$bundle_sql_insert_image = 'products_image';
tep_db_query("insert into " . TABLE_PRODUCTS . " (products_quantity, products_model, ".$bundle_sql_insert_image.", products_price, products_date_added, products_date_available, products_weight, products_status, products_tax_class_id, manufacturers_id".$bundle_custom_extensions.", products_bundle_status) values ('".BUY_TWO_BUNDLE_QUANTITY."','".$bundle_model_name."','".$bundle_image_name."','".$bundle_normal_price."', now(),'".$bundle_products_a['products_date_available']."','". $bundle_weight."', '0','". $bundle_products_a['products_tax_class_id']."','".$bundle_manufacturer.$bundle_custom_extensions_value."', '1')");
}

 

To my thinking, only 'admin' should ever add a row to products table.

 

Peter

Link to comment
Share on other sites

Hi,

 

Looking at this code block in /catalog/includes/classes/shopping_cart.php

 

// insert current cart contents in database
     if (is_array($this->contents)) {
       reset($this->contents);
       while (list($products_id, ) = each($this->contents)) {
         $qty = $this->contents[$products_id]['qty'];
   $cat = $this->contents[$products_id]['cat'];
         $product_query = tep_db_query("select products_id from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . $customer_id . "' and products_id = '" . $products_id . "'");
         if (!tep_db_num_rows($product_query)) {
           tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added, category_id) values ('" . $customer_id . "', '" . $products_id . "', '" . $qty . "', '" . date('Ymd') . "','" . $cat . "')");
           if (isset($this->contents[$products_id]['attributes'])) {
             reset($this->contents[$products_id]['attributes']);
             while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
               tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id) values ('" . $customer_id . "', '" . $products_id . "', '" . $option . "', '" . $value . "')");
             }
           }
         } else {
           tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set category_id = '". $cat ."', customers_basket_quantity = '" . $qty . "' where customers_id = '" . $customer_id . "' and products_id = '" . $products_id . "'");
   }
       }

 

it is quite obvious that the 'buy_two_module' is not getting the customer_id on the INSERT, and thereby when the delete is attempted in /buy_two_func.php

 

function tep_delete_bundle_cart($bundle_product_kill) {
   tep_db_query("delete from ".TABLE_CUSTOMERS_BASKET." where products_id='".$bundle_product_kill."'");
}

 

the row doesn't get deleted, because the product_id doesn't exist. The product_id's used for the BUY_TWO_BUNDLES table, in our site, has product_id's that do not even exist in the CUSTOMERS_BASKET table, therefore the wrong product_id is also being used on the insert.

 

In summary, 2 inserts are being done, and no deletes are being done, hence so many rows are being inserted. Here is the code from the 'buy_two' for the 2 inserst and the 1 delete:

 

tep_cart_re_bundle($bundle_product_a, $bundle_customer_id, $bundle_products_quantity);
tep_cart_re_bundle($bundle_product_b, $bundle_customer_id, $bundle_products_quantity);
	 
tep_delete_bundle_cart($bundle_cart['products_id']);

 

The 2 inserts are being done, with some garbage data being passed:

 

1. Customer_id = 0

2. product_id - incorrect

3. No category_id added

 

and then the delete is attempted, by using the product_id, of course, it cannot be found, so no delete. The delete should be by customer_no, as the code in /catalog/includes/classes/shopping_cart.php does it.

 

Also, this qry in the following function:

 

function tep_bundle_cart() {
   $bundle_cart_query = tep_db_query("select b.products_id, b.bundle_product_a, b.bundle_product_b, b.bundle_cart, c.customers_id, c.customers_basket_id, c.customers_basket_quantity, c.products_id from " . TABLE_BUY_TWO_BUNDLES . " b left join ".TABLE_CUSTOMERS_BASKET." c on b.products_id = c.products_id where b.bundle_active = '0'");

 

.. needs to select on customer_id also.

 

Hope that helps,

 

Peter

Link to comment
Share on other sites

Hi,

 

Comparing version 1.08 to 1.09a, there are two new functions:

 

* tep_lookup_the_catagory_id

* tep_first_product_check

 

No doubt it woud be best to update to version 1.09a, the first function mentioned:

 

* tep_lookup_the_catagory_id

 

is not in version 1.09, although no mention here , for version 1.09a ?

 

Peter

Link to comment
Share on other sites

  • 2 weeks later...

Hi,

 

We now have nearly 70,000 rows in the "customers_basket" table, from memory, this is a bug from the 'buy_two_module' ??

 

It looks like all the (garbage) rows have the following attributes:

 

customers_id = 0

customers_basket_quantity = 0

category_id = NULL (default)

 

Possibly a quick method to clean up your database for now, until the contribution has this bug fixed:

 

DELETE FROM customers_basket WHERE customers_id = '0' AND customers_basket_quantity = '0';

 

but do a select/qry first to make sure, or add in 'category_id' qualifier as well. :D

 

Don't forget to backup either the whole db, or just the table prior to this also.

 

Peter

Edited by peterr
Link to comment
Share on other sites

Hi,

 

peterr, truly this mod has caused a huge database build up.

 

I had to manuallly delete the bundles since i had some orders through them.

 

As I understand it, there are 2 problems.

 

1. 'Bundled products' are being added to the products/products_description tables,etc,

 

2. The 'customers_basket' table is being added to, for our site, at an alarming rate.

 

I haven't had time to 'dig deep' into the code, but I think problem 1 is happening from product_info.php , and products should only ever be added, of course, via admin, not via 'catalog'.

 

The problem #2 also I do not know exactly how/where, but my suspicions are also in product_info.php, in fact, with so many rows in such a short time interval, I feel rows are being added to the 'customers_basket' table, even when products are being viewed, whereas they should only be added when a visitor clicks 'add to cart' or 'buy now', etc.

 

There should be a permanent fix for this.

 

Yes, agreed, but it is up to other people, like you and me, to help the author find the bugs. :)

 

Peter

Link to comment
Share on other sites

Hi

 

on my very first impression: I can not follow, because ?n my case, the bundles are automatically deleted after e.g one day. Bundles in carts are rebundled - means the a+b item will get an a-item and a b-item.

 

I do not have a senseless growing db, because it is cleanund automatically and frequently. (but you have to set it in admin to on!) - also you may want to set if delete or archive ....

 

somebody there to post the admin settings? maybe as screenshot?

 

Kai

Link to comment
Share on other sites

Hi Kai,

 

on my very first impression: I can not follow, because ?n my case, the bundles are automatically deleted after e.g one day. Bundles in carts are rebundled - means the a+b item will get an a-item and a b-item.

 

I do not have a senseless growing db, because it is cleaned automatically and frequently. (but you have to set it in admin to on!) - also you may want to set if delete or archive ....

 

The data (rows) being added to the table 'customers_basket' is, for our site, "garbage data" and it started happening after the buy_two_module was installed.

 

Please see my previous post/s, where I have explained what is happening:

 

customers_id = 0

customers_basket_quantity = 0

category_id = NULL (default)

 

therefore, even though , for you, your bundles are automatically deleted every day, you are in fact, simply deleting the garbage data. My other posts explain how this is happening, the customers_id and category_id , for one, are not being passed before the INSERT.

 

The other problems is that 'Bundled products' are being added to the products/products_description tables,etc ??

 

That is, an INSERT is being done, not from "admin", but from either the buy_two_module scripts, or the mods made to other files> I'll have a quick look, yes, here it is, in the /includes/functions_buy_two_func.php , lines 451 to 457

 

if (BUY_TWO_BIG_IMAGE == 'yes'){
$bundle_sql_insert_image = 'products_image, products_bimage';
tep_db_query("insert into " . TABLE_PRODUCTS . " (products_quantity, products_model, ".$bundle_sql_insert_image.", products_price, products_date_added, products_date_available, products_weight, products_status, products_tax_class_id, manufacturers_id".$bundle_custom_extensions.", products_bundle_status) values ('".BUY_TWO_BUNDLE_QUANTITY."','".$bundle_model_name."','".$bundle_image_name."','".$bundle_image_name_large."','".$bundle_normal_price."', now(),'".$bundle_products_a['products_date_available']."','". $bundle_weight."', '0','". $bundle_products_a['products_tax_class_id']."','".$bundle_manufacturer.$bundle_custom_extensions_value."', '1')");
} elseif (BUY_TWO_BIG_IMAGE == 'no') {
$bundle_sql_insert_image = 'products_image';
tep_db_query("insert into " . TABLE_PRODUCTS . " (products_quantity, products_model, ".$bundle_sql_insert_image.", products_price, products_date_added, products_date_available, products_weight, products_status, products_tax_class_id, manufacturers_id".$bundle_custom_extensions.", products_bundle_status) values ('".BUY_TWO_BUNDLE_QUANTITY."','".$bundle_model_name."','".$bundle_image_name."','".$bundle_normal_price."', now(),'".$bundle_products_a['products_date_available']."','". $bundle_weight."', '0','". $bundle_products_a['products_tax_class_id']."','".$bundle_manufacturer.$bundle_custom_extensions_value."', '1')");
}

 

and then the other 4 tables as follows ...........

 

$bundle_products_id = tep_db_insert_id();
tep_db_query("insert into " . TABLE_PRODUCTS_DESCRIPTION . " (products_id, language_id, products_name, products_description) values ('".$bundle_products_id."','". $languages_id ."','".$bundle_name."','".$bundle_description."')");

tep_db_query("insert into " . TABLE_SPECIALS . " (products_id, specials_new_products_price, status) values ('".$bundle_products_id."','".$bundle_specials_price."','1')");

tep_db_query("insert into " . TABLE_BUY_TWO_BUNDLES . " (products_id, bundle_product_a, bundle_product_b, bundle_date_added, bundle_date_expire, bundle_delflag, bundle_active, bundle_archive, bundle_cart, bundle_normal_price, bundle_price, bundle_discount, bundle_products_model, bundle_products_name, bundle_products_click_count) values ('".$bundle_products_id."','".$bundle_products_a['products_id']."','".$bundle_products_b['products_id']."',now(),'".$bundle_exp_date."','".$bundle_delete_flag."','1','".$bundle_archive_flag."','".$bundle_cart_flag."','".$bundle_normal_price."','".$bundle_specials_price."','".$bundle_discount."','".$bundle_model_name."','".$bundle_name."','1')");

tep_db_query("insert into ". TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id) values ($bundle_products_id,'0')");

 

This code is called by the function "tep_set_bundle", which is in /includes/application_top.php , if the admin setting is 'discount' as follows:

 

} elseif (BUY_TWO_DISCOUNT_BUNDLE =='discount') {
                                   $bundle_products_id = tep_set_bundle($HTTP_GET_VARS['products_id'],$HTTP_GET_VARS['buy_tinn_add'],BUY_TWO_BUNDLE_DISCOUNT_RATE);
                                   $cart->add_cart($bundle_products_id, $cart->get_quantity($bundle_products_id) +1,'',$HTTP_GET_VARS['category_id']);

 

Hope that helps, in summary ...........

 

1. The incorrect paramaters are being passed before the INSERT's to the "customers_basket" table, therefore the DELETE is not possible.

 

2. Only admin should ever add new products, but never 'catalog'.

 

Thanks,

 

Peter

Link to comment
Share on other sites

OK,

 

I will upload Version 1.09b in a few minutes.

 

The problem with the customer basket is gone...

 

In the new 1.09b package you will find a SQL statement to clean the customer_basket table and delete the 0-customers

 

NEXT: bundles will only appear in the customer_basket table if it is a registered customer with a customer_id >0

 

 

Now the point "addind to products table". If you think only admin should add a product to that table then I recommend you to forget buy_two_module. There are good reasons to rather treat a bundle as a normal product within OSC than dealing with new functions, tables and a lot of alterations within the rest of the code. I will not go through it and will not make a study why I decided for that way.

 

If there is anybody there who would like to see another solution she/he have to develop that one (feel free :) )

 

Except the situation with the customer basket rubbage before I can not see any problems with buy_two right now. Is there any other product loss that I am not aware of? Please let me know.

 

Regards

Kai

Link to comment
Share on other sites

Kai

 

Thanks for the look up and solving the problem.

 

Though i do not want to select products through the Admin since this contribution was designed that way. That said, i have had appx. 500 products added to my product table.

 

it seems that the products are getting added when someone views it rather it should be that when someone adds it.

 

Awaiting for the new version : )

Link to comment
Share on other sites

Hi,

 

Though i do not want to select products through the Admin since this contribution was designed that way.

 

osCommerce is designed around a 'model', being that products are added/modified only by admin, via restricted access, and not done by the general 'public', or website visitor to the site.

 

Designing the contribution in contradiction to how the standard/base osCommerce has always been built is neither logical or sensible.

 

it seems that the products are getting added when someone views it rather it should be that when someone adds it.

 

Correct, the 'general public' or website visitors are in fact, by default, "adding products", not something any website owner would want. Yes, it should only be when someone adds a product, and that 'someone' should only ever be a person who has authorised access to admin.

 

I would suggest you simply comment out the code in /includes/functions_buy_two_func.php , so that the INSERT's are not done, that way you fix the bug.

 

Peter

Link to comment
Share on other sites

Hi

 

QUOTE]it seems that the products are getting added when someone views it rather it should be that when someone adds it.

 

Awaiting for the new version : )

 

Well, the products (bundles) are inserted into the table when the visitor adds the product (bundle) to the cart. It is NOT added to the table when just showing up! Did you see the various settings in admin? To decide how long to hold a bundle? What to do when it expires? What happens with bundles in carts? AND so on...

 

:huh: Commenting something out would simply mean you can forget the functionality behind. Things won't work correctly and some mess could happen. Before you decide to comment something out -> do not use buy_two

 

If you are unhappy the way buy_two works in general then - again - I have to recommend you NOT to use it.

 

I am working myself with the contribution and I do not have any bad situations... :thumbsup:

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