Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Cart Emptying Each Click


elogicmedia

Recommended Posts

Hi, I am currently using this contribution: http://www.oscommerce.com/community/contributions,1444

 

to display the shopping cart outside of the oscommerce folder. Anyway it seems to be working ok however it seems to empty the carts contents each time I click back to the page outside of the cart.

 

You can view this with the links below:

 

The Page outside of OS with the contribution installed.. (cart contents)

 

 

The shopping cart page

 

You can view this by adding a product from the first link which will take you to the second link, then click continue shopping which brings you back to the first and the cart is empty.

 

Any reason why this might be happening?

 

The coding on the product page (with the contribution) is as follows:

 

 

AT START OF THE PAGE:

<?php
//saves current working directory for later return
$cwd=getcwd();

//changes current working directory to osc root install directory; something like: /home/david/public_html/catalog/ but not DIR_FS_CATALOG
chdir('/home/virtual/site25/fst/var/www/html/catalog/'); 

//need all of application_top's configurations and includes; NO OUTPUT ABOVE THIS POINT!
include('includes/application_top.php');
?>

 

 

WHERE THE CART BOX NEEDS TO BE:

<?php
/********************************************************
CONTENT OUTSIDE OF OSC V1.1       

Author: David Vance  == Adapted for MS2 by Anthony
Date: 20. 11, 2004

OSC 2.2 MS2
PHP Version 4.3.2

This snippet is an example of placing osCommerce
 content on your site outside of the OSC 
 directory structure.
 
 It allows you to display the products_new table.

********************************************************/


 //need the language file
 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_SHOPPING_CART);
 
 //start buffering
ob_start(); 

/* BEGIN: From the products_new.php page: */

 $info_box_contents = array();
 $info_box_contents[] = array('text' => BOX_HEADING_SHOPPING_CART);

 //new infoBoxHeading($info_box_contents, false, true, tep_href_link(FILENAME_SHOPPING_CART));

 $cart_contents_string = '';
 if ($cart->count_contents() > 0) {
   $cart_contents_string = '<table border="0" width="100%" cellspacing="0" cellpadding="0">';
   $products = $cart->get_products();
   for ($i=0, $n=sizeof($products); $i<$n; $i++) {
     $cart_contents_string .= '<tr><td align="right" valign="top">';

     if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]['id'])) {
       $cart_contents_string .= '<span class="newItemInCart">';
     } else {
       $cart_contents_string .= '<span class="infoBoxContents">';
     }

     $cart_contents_string .= $products[$i]['quantity'] . ' x </span></td><td valign="top" ><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '">';

     if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]['id'])) {
       $cart_contents_string .= '<span class="newItemInCart">';
     } else {
       $cart_contents_string .= '<span class="infoBoxContents">';
     }

     $cart_contents_string .= $products[$i]['name'] . '</span></a></td></tr>';

     if ((tep_session_is_registered('new_products_id_in_cart')) && ($new_products_id_in_cart == $products[$i]['id'])) {
       tep_session_unregister('new_products_id_in_cart');
     }
   }
   $cart_contents_string .= '</table>';
 } else {
   $cart_contents_string .= BOX_SHOPPING_CART_EMPTY;
 }

 $info_box_contents = array();
 $info_box_contents[] = array('text' => $cart_contents_string);

 if ($cart->count_contents() > 0) {
   $info_box_contents[] = array('text' => tep_draw_separator());
   $info_box_contents[] = array('align' => 'right',
                                'text' => $currencies->format($cart->show_total()));
 }

 new infoBox($info_box_contents);
?>


<?php

/* END: From the products_new.php page */

 //save it in a variable for later use
 $newProductsTable = ob_get_contents();

 //stop buffering
 ob_end_clean();

 //replace relative image paths with absolute urls (you may not need this. i did.)
$newProductsTable=str_replace('src="', 'src="http://www.profilehealthservices.com/catalog/',$newProductsTable);
 
 //change back to original working directory
chdir($cwd);


//********* COPY THE CODE ABOVE TO THE TOP OF THE FILE YOU WANT YOUR BOX IN *******\\
?>

 

and

 

<?php 
echo $newProductsTable; //output your table here (or wherever)
?>

 

 

Anyone able to help me out to see why the cart keeps becoming empty when I click out of the os folders...?

 

Thanks

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