Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Issue with Buy Now Button dumping user / session


NodsDorf

Recommended Posts

Searched Google, and Forums didn't see this discussed.

 

The Buy Now button on generated in the product listing is logging users out and/ or starting a new session and leaving their cart empty.

Basically it ain't workin'

 

Background

Running

RC2

STS

Min Order Qty

Qty Price Breaks

 

If you add a product from the product page to the cart it works fine, but if you try to use the Buy Now button you're hosed.

 

I have tried everything I can think of but can't get the button to function correctly.

 

Does anybody have any thoughts at all what could be causing the issue on this particular page?

 

Example of Problem: HERE

Example of Button working correctly HERE

 

 

I think the functions are called from the applicationtop.php here is the code I think that pertains to this issue.

 

// customer adds a product from the products page
     case 'add_product' :    if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) {
                               //BOF qpbpp
                               $cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id']))+1, $HTTP_POST_VARS['id']);
                              // $cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id'])) + $HTTP_POST_VARS['cart_quantity'], $HTTP_POST_VARS['id']);
//EOF qpbpp
                             }
                             tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
                             break;
     // performed by the 'buy now' button in product listings and review page
     case 'buy_now' :        if (isset($HTTP_GET_VARS['products_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_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id'])) + $HTTP_POST_VARS['cart_quantity'], $HTTP_POST_VARS['id']);
							}
                             }
                             tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
                             break;
     case 'notify' :         if (tep_session_is_registered('customer_id')) {
                               if (isset($HTTP_GET_VARS['products_id'])) {
                                 $notify = $HTTP_GET_VARS['products_id'];
                               } elseif (isset($HTTP_GET_VARS['notify'])) {
                                 $notify = $HTTP_GET_VARS['notify'];
                               } elseif (isset($HTTP_POST_VARS['notify'])) {
                                 $notify = $HTTP_POST_VARS['notify'];
                               } else {
                                 tep_redirect(tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action', 'notify'))));
                               }
                               if (!is_array($notify)) $notify = array($notify);
                               for ($i=0, $n=sizeof($notify); $i<$n; $i++) {
                                 $check_query = tep_db_query("select count(*) as count from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $notify[$i] . "' and customers_id = '" . $customer_id . "'");
                                 $check = tep_db_fetch_array($check_query);
                                 if ($check['count'] < 1) {
                                   tep_db_query("insert into " . TABLE_PRODUCTS_NOTIFICATIONS . " (products_id, customers_id, date_added) values ('" . $notify[$i] . "', '" . $customer_id . "', now())");
                                 }
                               }
                               tep_redirect(tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action', 'notify'))));
                             } else {
                               $navigation->set_snapshot();
                               tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
                             }
                             break;
     case 'notify_remove' :  if (tep_session_is_registered('customer_id') && isset($HTTP_GET_VARS['products_id'])) {
                               $check_query = tep_db_query("select count(*) as count from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $HTTP_GET_VARS['products_id'] . "' and customers_id = '" . $customer_id . "'");
                               $check = tep_db_fetch_array($check_query);
                               if ($check['count'] > 0) {
                                 tep_db_query("delete from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $HTTP_GET_VARS['products_id'] . "' and customers_id = '" . $customer_id . "'");
                               }
                               tep_redirect(tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action'))));
                             } else {
                               $navigation->set_snapshot();
                               tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
                             }
                             break;
     case 'cust_order' :     if (tep_session_is_registered('customer_id') && isset($HTTP_GET_VARS['pid'])) {
                               if (tep_has_product_attributes($HTTP_GET_VARS['pid'])) {
                                 tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['pid']));
                               } else {
                                 $cart->add_cart($HTTP_GET_VARS['pid'], $cart->get_quantity($HTTP_GET_VARS['pid'])+1);
                               }
                             }
                             tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
                             break;
   }
 }

Link to comment
Share on other sites

The Buy Now button on generated in the product listing is logging users out and/ or starting a new session and leaving their cart empty.

Basically it ain't workin'

I do notice the "old" session_id being in the url in shopping_cart.php with an incorrect format:

http://rubberstore.com/catalog/shopping_cart.php?sort=2a&osCsid=cac....etcetera

The & amp; can be in the link on pages but not in the url itself like this.... (I assume it should be possible to have the session id out of the url after a few clicks but that doesn't seem to happen either).

Link to comment
Share on other sites

I do notice the "old" session_id being in the url in shopping_cart.php with an incorrect format:

http://rubberstore.com/catalog/shopping_cart.php?sort=2a&osCsid=cac....etcetera

The & amp; can be in the link on pages but not in the url itself like this.... (I assume it should be possible to have the session id out of the url after a few clicks but that doesn't seem to happen either).

 

 

Ya I noticed that too, it seems the button trys to perform a Sort Order operation which I'm not sure where that is coming from.

 

You can disable the redirect to the shopping cart via the admin panel, but if you do that then the button just refreshes the page. Something weird is going on with it and I can't seem to pin point the issue.

Link to comment
Share on other sites

Ya I noticed that too, it seems the button trys to perform a Sort Order operation which I'm not sure where that is coming from.

That's not really a problem. However the & amp; thing will be. IMHO the code will see there is now a GET variable that is not osCsid but amp;osCsid. So no osCsid: a new one is generated...

Link to comment
Share on other sites

That's not really a problem. However the & amp; thing will be. IMHO the code will see there is now a GET variable that is not osCsid but amp;osCsid. So no osCsid: a new one is generated...

To improve is to change; to be perfect is to change often.

 

Link to comment
Share on other sites

Hi

not sure if this will help you but seems to me you are missing a bit of code I also have the qpbpp installed Rc2a this section of code by me looks like below can not remember any other addons that I have that might have change it!!!

Well you could try comparing and see what happens

 

 

// customer adds a product from the products page

case 'add_product' : if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) {

//BOF qpbpp

//$cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id']))+1, $HTTP_POST_VARS['id']);

$cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id'])) + $HTTP_POST_VARS['cart_quantity'], $HTTP_POST_VARS['id']);

//EOF qpbpp

 

}

tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));

break;

case 'buy_now_form' : if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) {

$cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id']))+($HTTP_POST_VARS['cart_quantity']), $HTTP_POST_VARS['id']);

// replace quantities $cart->get_quantity($HTTP_POST_VARS['products_id'])-($cart->get_quantity($HTTP_POST_VARS['products_id']))+($HTTP_POST_VARS['cart_quantity']), $HTTP_POST_VARS['id']);

}

tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));

break;

// customer adds multiple products from the products_listing page

case 'add_multiple' :

while ( list( $key, $val ) = each( $HTTP_POST_VARS ) )

{

if (substr($key,0,11) == "Qty_ProdId_" || substr($key,0,11) == "Qty_NPrdId_")

{

$prodId = substr($key, 11);

$qty = $val;

if ($qty <= 0 ) continue;

if(isset($HTTP_POST_VARS["id_$prodId"]) && is_array($HTTP_POST_VARS["id_$prodId"])) {

// We have attributes

$cart->add_cart($prodId, $cart->get_quantity(tep_get_uprid($prodId,$HTTP_POST_VARS["id_$prodId"]))+$qty, $HTTP_POST_VARS["id_$prodId"]);

} else {

// No attributes

$cart->add_cart($prodId, $cart->get_quantity($prodId)+$qty);

}

}

}

tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));

break;

//------------------------------------------------------------------------------------------------

// performed by the 'buy now' button in product listings and review page

case 'buy_now' : if (isset($HTTP_GET_VARS['products_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);

}

}

tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));

break;

case 'notify' : if (tep_session_is_registered('customer_id')) {

if (isset($HTTP_GET_VARS['products_id'])) {

To improve is to change; to be perfect is to change often.

 

Link to comment
Share on other sites

Thanks for the reply,

 

I tried to updated the code (now that I'm at work)

 

My Previous Code: from the applicationtop.php was

 // performed by the 'buy now' button in product listings and review page
     case 'buy_now' :        if (isset($HTTP_GET_VARS['products_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_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id'])) + $HTTP_POST_VARS['cart_quantity'], $HTTP_POST_VARS['id']);
                                                               }
                             }
                             tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));

 

Your code was:

// performed by the 'buy now' button in product listings and review page
     case 'buy_now' :        if (isset($HTTP_GET_VARS['products_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_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id'])) + $HTTP_POST_VARS['cart_quantity'], $HTTP_POST_VARS['id']);
							}
                             }
                             tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));

 

Result is the same, I'm still getting dumped and the &amp sign is appended to the prefix of the osCsid

I've installed this contribution before on a shop without STS and did not have the problem. I am currently at a lose on how to fix this.

 

Any further input would greatly be appreciated.

 

Thank you,

Don

Link to comment
Share on other sites

I just went through the complete installation again.

 

I did not find any errors in the install based of the creator's directions.

 

I did notice this however:

 

There are some changes to the PRODUCT_LIST_BUY_NOW call in the cat\includes\modlues\product_listing.php file

 

The directions are as follows:

Find (around line 90-135{124-169}):

        switch ($column_list[$col]) {
         case 'PRODUCT_LIST_MODEL':
           $lc_align = '';
           $lc_text = ' ' . $listing['products_model'] . ' ';
           break;
         case 'PRODUCT_LIST_NAME':
.
.
.
.
.
.
         case 'PRODUCT_LIST_BUY_NOW':
           $lc_align = 'center';
           $lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a> ';
           break;
       }

 

Replace with:

        switch ($column_list[$col]) {
         case 'PRODUCT_LIST_MODEL':
           $lc_align = '';
           $lc_text = ' ' . $listing[$x]['products_model'] . ' ';
           break;
         case 'PRODUCT_LIST_NAME':
           $lc_align = '';
           if (isset($HTTP_GET_VARS['manufacturers_id'])) {
             $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing[$x]['products_id']) . '">' . $listing[$x]['products_name'] . '</a>';
           } else {
             $lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing[$x]['products_id']) . '">' . $listing[$x]['products_name'] . '</a> ';
           }
           break;
         case 'PRODUCT_LIST_MANUFACTURER':
           $lc_align = '';
           $lc_text = ' <a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing[$x]['manufacturers_id']) . '">' . $listing[$x]['manufacturers_name'] . '</a> ';
           break;
         case 'PRODUCT_LIST_PRICE':
           $lc_align = 'right';
           $price_breaks_from_listing = array();
           if (isset($price_breaks_array[$listing[$x]['products_id']])) {
             $price_breaks_from_listing = $price_breaks_array[$listing[$x]['products_id']];
           }
           $pf->loadProduct($listing[$x]['products_id'], $languages_id, $listing[$x], $price_breaks_from_listing);
           $lc_text = $pf->getPriceStringShort();
           break;
         case 'PRODUCT_LIST_QUANTITY':
           $lc_align = 'right';
           $lc_text = ' ' . $listing[$x]['products_quantity'] . ' ';
           break;
         case 'PRODUCT_LIST_WEIGHT':
           $lc_align = 'right';
           $lc_text = ' ' . $listing[$x]['products_weight'] . ' ';
           break;
         case 'PRODUCT_LIST_IMAGE':
           $lc_align = 'center';
           if (isset($HTTP_GET_VARS['manufacturers_id'])) {
             $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing[$x]['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing[$x]['products_image'], $listing[$x]['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>';
           } else {
             $lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing[$x]['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing[$x]['products_image'], $listing[$x]['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a> ';
           }
           break;
         case 'PRODUCT_LIST_BUY_NOW':
           $lc_align = 'center';
           $lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing[$x]['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a> ';
           break;
       }
// EOF qpbpp

Developer notes:

Note that apart from the obvious changes in case 'PRODUCT_LIST_PRICE': every instance of $listing['field_name'] has been changed to $listing[$x]['field_name'] in the code above!

 

 

Does anybody see anything that could be causing the oscSid to act like it does on my pages?

 

I'm really at a lose here.

 

Thanks for any help.

 

Don

Link to comment
Share on other sites

You might look at my post in this thread: http://forums.oscomm...howtopic=334008

 

That would be a possible solution if it's the W3C URLs in Ultimate SEO URLs (or a similar setting in another contribution) that is causing the issue.

 

Thank you, this was very helpful. Turned off W3C URL's and all is fine.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...