Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Can't add products to shopping cart - clean osC v2.3.4 install


jjlyman

Recommended Posts

SHOPPING CART “add products” problem :

 

ENVIRONMENT – OsCommerce v2.3.4 clean install (no add-ons or modifications) using the installation's standard sample database. Have tried multiple installs via dowload of osC zipped system to local, local unzip, and FTP upload to server...longtime, experienced osC user.  Here are my configurations on a new test installation ( "xxxxxx" here replaces my actual private values ) :

 

…/catalog/includes/configure.php

 

<?php

define('HTTP_SERVER', 'http://xxxxx.com');

define('HTTPS_SERVER', 'https://xxxxx.com');

define('ENABLE_SSL', true);

define('HTTP_COOKIE_DOMAIN', '');

define('HTTPS_COOKIE_DOMAIN', '');

define('HTTP_COOKIE_PATH', '/osCommerce/catalog/');

define('HTTPS_COOKIE_PATH', '/osCommerce/catalog/');

define('DIR_WS_HTTP_CATALOG', '/osCommerce/catalog/');

define('DIR_WS_HTTPS_CATALOG', '/osCommerce/catalog/');

define('DIR_WS_IMAGES', 'images/');

define('DIR_WS_ICONS', DIR_WS_IMAGES . 'icons/');

define('DIR_WS_INCLUDES', 'includes/');

define('DIR_WS_FUNCTIONS', DIR_WS_INCLUDES . 'functions/');

define('DIR_WS_CLASSES', DIR_WS_INCLUDES . 'classes/');

define('DIR_WS_MODULES', DIR_WS_INCLUDES . 'modules/');

define('DIR_WS_LANGUAGES', DIR_WS_INCLUDES . 'languages/');

 

define('DIR_WS_DOWNLOAD_PUBLIC', 'pub/');

define('DIR_FS_CATALOG', '/hermes/bosnaweb18a/b2055/ipw.xxxxx /public_html/osCommerce/catalog/');

define('DIR_FS_DOWNLOAD', DIR_FS_CATALOG . 'download/');

define('DIR_FS_DOWNLOAD_PUBLIC', DIR_FS_CATALOG . 'pub/');

 

define('DB_SERVER', 'xxxxx .ipowermysql.com');

define('DB_SERVER_USERNAME', 'xxxxx');

define('DB_SERVER_PASSWORD', 'xxxxx');

define('DB_DATABASE', 'xxxxx');

define('USE_PCONNECT', 'false');

define('STORE_SESSIONS', 'mysql');

define('CFG_TIME_ZONE', 'America/Chicago');

?>

 

 

…/catalog/admin/includes/catalog.php

 

<?php

define('HTTP_SERVER', 'http://xxxxx.com');

define('HTTPS_SERVER', 'https://xxxxx.com');

define('ENABLE_SSL', true);

define('HTTP_COOKIE_DOMAIN', '');

define('HTTPS_COOKIE_DOMAIN', '');

define('HTTP_COOKIE_PATH', '/osCommerce/catalog/admin');

define('HTTPS_COOKIE_PATH', '/osCommerce/catalog/admin');

define('HTTP_CATALOG_SERVER', 'http://xxxxx.com');

define('HTTPS_CATALOG_SERVER', 'https://xxxxx.com');

define('ENABLE_SSL_CATALOG', 'true');

define('DIR_FS_DOCUMENT_ROOT', '/hermes/bosnaweb18a/b2055/ipw.xxxxx/public_html/osCommerce/catalog/');

define('DIR_WS_ADMIN', '/osCommerce/catalog/admin/');

define('DIR_WS_HTTPS_ADMIN', '/osCommerce/catalog/admin/');

define('DIR_FS_ADMIN', '/hermes/bosnaweb18a/b2055/ipw.xxxxx/public_html/osCommerce/catalog/admin/');

define('DIR_WS_CATALOG', '/osCommerce/catalog/');

define('DIR_WS_HTTPS_CATALOG', '/osCommerce/catalog/');

define('DIR_FS_CATALOG', '/hermes/bosnaweb18a/b2055/ipw.xxxxx/public_html/osCommerce/catalog/');

define('DIR_WS_IMAGES', 'images/');

define('DIR_WS_ICONS', DIR_WS_IMAGES . 'icons/');

define('DIR_WS_CATALOG_IMAGES', DIR_WS_CATALOG . 'images/');

define('DIR_WS_INCLUDES', 'includes/');

define('DIR_WS_BOXES', DIR_WS_INCLUDES . 'boxes/');

define('DIR_WS_FUNCTIONS', DIR_WS_INCLUDES . 'functions/');

define('DIR_WS_CLASSES', DIR_WS_INCLUDES . 'classes/');

define('DIR_WS_MODULES', DIR_WS_INCLUDES . 'modules/');

define('DIR_WS_LANGUAGES', DIR_WS_INCLUDES . 'languages/');

define('DIR_WS_CATALOG_LANGUAGES', DIR_WS_CATALOG . 'includes/languages/');

define('DIR_FS_CATALOG_LANGUAGES', DIR_FS_CATALOG . 'includes/languages/');

define('DIR_FS_CATALOG_IMAGES', DIR_FS_CATALOG . 'images/');

define('DIR_FS_CATALOG_MODULES', DIR_FS_CATALOG . 'includes/modules/');

define('DIR_FS_BACKUP', DIR_FS_ADMIN . 'backups/');

define('DIR_FS_DOWNLOAD', DIR_FS_CATALOG . 'download/');

define('DIR_FS_DOWNLOAD_PUBLIC', DIR_FS_CATALOG . 'pub/');

 

define('DB_SERVER', 'xxxxx.ipowermysql.com');

define('DB_SERVER_USERNAME', 'xxxxx');

define('DB_SERVER_PASSWORD', 'xxxxx');

define('DB_DATABASE', 'xxxxx');

define('USE_PCONNECT', 'false');

define('STORE_SESSIONS', 'mysql');

define('CFG_TIME_ZONE', 'America/Chicago');

?>

 

PROBLEM BEHAVIORS in shopping cart :

 

  • while we can add product without attributes (e.g., sample item “printer”) the "add" function works only from the category list, and not from the item detail page

  • cannot add any item that has attributes

  • cannot update cart with a manual change of quanity + “update” button

note that cart “remove” works fine with the only item that I've been able to add (“printer”)

 

Hosting Server Support at iPower.com says that their shared server cannot handle “flower brackets” { }, says that these show up in product URL's with attributes. But I do not see these URL's with flower brackets (am I missing something ?  ...where to look ?).  Could other special characters (e.g., “copyright”) also cause problems ?

 

SUMMARY – can't get a clean install of osC v2.3.4, with its sample database, to work on iPower.com server. Prior osC versions of osC were working on iPower.com, even with add-ons QPBPP (now outdated for v2.3.4) and Manual Order Entry/Edit, as I had configured a store for my regular business. Now my regular business store as updated osC v2.3.4 with those add-ons has these same shopping cart problems, so I'm trying to solve them in a clean install of osC before I try to fix my customized store.

 

Are the configurations correct for SSL, cookie handling, cache, etc. ? Where does a clean install of osC v2.3.4 actually work without these shopping cart problems ?  What does my Host Server need to know ?

Link to comment
Share on other sites

See post 1884 and some after in this thread. Apparently It is a new security option some hosts are using.

 

I suggest you also switch to the Bootstrap version. It won't fix the problem you are having but will give you the latest, and better, version of oscommerce. See this thread here for links.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

All of My Addons

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

My host iPower had confirmed that their shared server won't process links that include "flower brackets"  {  }, which are part of the product descriptions in the database CUSTOMER_BASKET file.

 

The BS ("bootstrap") version of osC v2.3.4 will require some time and effort to understand (why use it?) and implement.  One concern is how manual code edits for required add-ons will work in the BS version (or not ? -- can I simply copy over to BS the added and modified files from the non-BS version of osC v2.3.4 ?).  Since I seem to have made progress with non-BS version here, and my store seems to function at least well enough for customer use, I won't chase the BS install immediately.

 

Here is what I seem to have accomplished so far in trying to fix common Shopping_Cart problems (subject to further testing).  I also posted to forum for Shopping_Cart REMOVE problem. 

 

My basic environment :  osC v2.3.4 with latest mods for QPBPP, Order Entry (Manual + Edits), host is iPower.com.

 

Changing the ..catalog/includes/configure.php setting :

 

       define('HTTP_SERVER', 'http://jlyman.com');

         to

       define('HTTP_SERVER', 'https://jlyman.com');

 

seems to have these positive effects ...

1) allowing addition to cart of items with and without attributes

2) allowing update of item quantities (attributes or not)

3) allowing REMOVE of just an item without attributes, but will remove all cart contents when REMOVE is clicked for any one item with attributes

 

Also, clicking on the item descriptions in the cart has these effects :

1) shows proper item page if no attributes

2) goes to store page if click on item with attributes

 

Any fixes that are more complete ?  Are there issues that might be related to other configure.php settings (for cookies, cache, sessions) ?

Link to comment
Share on other sites

First, an update to my reported “fix” above about ADD PRODUCT with attributes : while this configure setting (for SSL) seems to work on my Host to allow ADD products with attributes, it DOES NOT, in fact, REMOVE products with attributes. Attempting to remove products with attributes simply shows a blank cart page with user logged out (but click “back” button returns to the logged-in cart with original items). Removal of products without attributes DOES work.

 

Regarding ShaGGy's fix for “the two functions (remove from cart and product link in cart)” as referenced in above post, I had seen it a while ago. I didn't try it because 1) not sure if it relates to BS version or not (as I'm not on BS), and 2) I was confused by author's comment “this seems to be working...” but two posts later that “...it breaks on my host and possibly others. “

 

Thanks for your above response, @@dan_Cole.

 

Regarding ShaGGy's fix that you reference above, there are 3 files in v2.3.4 (non-BS) named shopping_cart.php .  Now searching on my current (non-BS, add-on modified) site I do not find the fix search strings in any of those files. Nor could I find those search strings in an original v2.3.4 non-BS version. So I wouldn't know where to make the code changes – in what specific file, at what line, etc. – if those code changes can be done at all, as written, on my osC. But it looks like there might be a scheme for fixing this, if it can be adapted to non-BS v2.3.4.  So it would be helpful to have clarity on these questions, or perhaps a more explicit code fix for non-BS v2.3.4 .

 

My most important add-ons are the QPBPP (price breaks by quantity) and the 2 Order Entry/Edit mods. I can't use osC without those mods. While QPBPP is years outdated (last rel. June 5, 2011 for v2.3.1) and its manual code change instructions are extremely buggy, it seems to work well with v2.3.4 (if you can actually figure out how to install it).

 

Considering my uncertainty about whether these add-ons can work with the current BS version or upcoming osC updates (v2.4 etc.), or whether the BS version or planned osC upgrades will incorporate those add-on functions internally (as they should, and when they might be released), I am in no rush to change my osC away from non-BS v2.3.4 . I simply want to get a store version running now, after many months of disfunction. Seems that I'm almost there...

 

Wading through a lot of forums chatter about Hosting problems with regard to handling “flower brackets” { }, (seems related to certain shared servers hosting ?) and the fundamental problem that this can cause with the osC shopping cart, I have to guess that this would be a problem for a lot of osC users. I earlier mentioned my Host as iPower.com, and their nearly verbatim response about brackets as reported by ShaGGy (using the same host?). From what I read in these forums, this would seem to be a core flaw of current osC. My Host suggests migrating to a dedicated server, but the cost are much higher so this largely defeats a purpose of osC. I understand that I might change Hosts, but there are other costs/difficulties associated with this which make that an unattractive alternative.

 

Before someone again recommends changing to the BS version, I would have to understand how that could accommodate my essential add-ons (i.e., how applicable would those add-ons' manual code changes be to the core code in the BS version?) before I would launch such a store re-build project.  Then there's the above comment by @@Jack_mcs that "it won't fix the problem", anyway.

 

In sum, I and probably many others would appreciate a clear fix for the shopping cart “remove” and “update” problems that are caused by “flower brackets” handling on some servers. If a clear fix has been posted, I haven't found it.

 

I also posted this here on forum “Remove product shopping cart.php issue 2.3.4”.

Link to comment
Share on other sites

@@jjlyman I'm running on the BS version with the modular shopping cart installed so my code will be a lot different so I'm not sure I can help but why don't you post your shopping_cart.php file here...I'll be the one in your catalogue root and maybe @@ShaGGy or someone can help you with the code that needs changing.  

 

It looks like a pretty simple fix.

 

Dan

Link to comment
Share on other sites

Thanks for your attention, @@dan_Cole.  Here's my root  ..catalog/shopping_cart.php file.  Its should be the original v2.3.4 code, so a fix should help the multitudes.  Another version the file at .../catalog/includes/classes/shopping_cart.php, as well as .../catalog/includes/application_top.php, have coding mods from QPBPP add-on (as do many other files).

 

_________________________________

 

<?php
/*
  $Id$

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

  Copyright © 2010 osCommerce

  Released under the GNU General Public License
*/

  require("includes/application_top.php");

  if ($cart->count_contents() > 0) {
    include(DIR_WS_CLASSES . 'payment.php');
    $payment_modules = new payment;
  }

  require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_SHOPPING_CART);

  $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_SHOPPING_CART));

  require(DIR_WS_INCLUDES . 'template_top.php');
?>

<h1><?php echo HEADING_TITLE; ?></h1>

<?php
  if ($cart->count_contents() > 0) {
?>

<?php echo tep_draw_form('cart_quantity', tep_href_link(FILENAME_SHOPPING_CART, 'action=update_product')); ?>

<div class="contentContainer">
  <h2><?php echo TABLE_HEADING_PRODUCTS; ?></h2>

  <div class="contentText">

<?php
    $any_out_of_stock = 0;
    $products = $cart->get_products();
    for ($i=0, $n=sizeof($products); $i<$n; $i++) {
// Push all attributes information in an array
      if (isset($products[$i]['attributes']) && is_array($products[$i]['attributes'])) {
        while (list($option, $value) = each($products[$i]['attributes'])) {
          echo tep_draw_hidden_field('id[' . $products[$i]['id'] . '][' . $option . ']', $value);
          $attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix
                                      from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa
                                      where pa.products_id = '" . (int)$products[$i]['id'] . "'
                                       and pa.options_id = '" . (int)$option . "'
                                       and pa.options_id = popt.products_options_id
                                       and pa.options_values_id = '" . (int)$value . "'
                                       and pa.options_values_id = poval.products_options_values_id
                                       and popt.language_id = '" . (int)$languages_id . "'
                                       and poval.language_id = '" . (int)$languages_id . "'");
          $attributes_values = tep_db_fetch_array($attributes);

          $products[$i][$option]['products_options_name'] = $attributes_values['products_options_name'];
          $products[$i][$option]['options_values_id'] = $value;
          $products[$i][$option]['products_options_values_name'] = $attributes_values['products_options_values_name'];
          $products[$i][$option]['options_values_price'] = $attributes_values['options_values_price'];
          $products[$i][$option]['price_prefix'] = $attributes_values['price_prefix'];
        }
      }
    }
?>

    <table border="0" width="100%" cellspacing="0" cellpadding="0">

<?php

    for ($i=0, $n=sizeof($products); $i<$n; $i++) {
      echo '      <tr>';

      $products_name = '<table border="0" cellspacing="2" cellpadding="2">' .
                       '  <tr>' .
                       '    <td align="center"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '">' . tep_image(DIR_WS_IMAGES . $products[$i]['image'], $products[$i]['name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></td>' .
                       '    <td valign="top"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '"><strong>' . $products[$i]['name'] . '</strong></a>';

      if (STOCK_CHECK == 'true') {
        $stock_check = tep_check_stock($products[$i]['id'], $products[$i]['quantity']);
        if (tep_not_null($stock_check)) {
          $any_out_of_stock = 1;

          $products_name .= $stock_check;
        }
      }

      if (isset($products[$i]['attributes']) && is_array($products[$i]['attributes'])) {
        reset($products[$i]['attributes']);
        while (list($option, $value) = each($products[$i]['attributes'])) {
          $products_name .= '<br /><small><i> - ' . $products[$i][$option]['products_options_name'] . ' ' . $products[$i][$option]['products_options_values_name'] . '</i></small>';
        }
      }

      $products_name .= '<br /><br />' . tep_draw_input_field('cart_quantity[]', $products[$i]['quantity'], 'size="4"') . tep_draw_hidden_field('products_id[]', $products[$i]['id']) . tep_draw_button(IMAGE_BUTTON_UPDATE, 'refresh') . '   ' . TEXT_OR . '<a href="' . tep_href_link(FILENAME_SHOPPING_CART, 'products_id=' . $products[$i]['id'] . '&action=remove_product') . '">' . TEXT_REMOVE . '</a>';

      $products_name .= '    </td>' .
                        '  </tr>' .
                        '</table>';

      echo '        <td valign="top">' . $products_name . '</td>' .
           '        <td align="right" valign="top"><strong>' . $currencies->display_price($products[$i]['final_price'], tep_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . '</strong></td>' .
           '      </tr>';
    }
?>

    </table>

    <p align="right"><strong><?php echo SUB_TITLE_SUB_TOTAL; ?> <?php echo $currencies->format($cart->show_total()); ?></strong></p>

<?php
    if ($any_out_of_stock == 1) {
      if (STOCK_ALLOW_CHECKOUT == 'true') {
?>

    <p class="stockWarning" align="center"><?php echo OUT_OF_STOCK_CAN_CHECKOUT; ?></p>

<?php
      } else {
?>

    <p class="stockWarning" align="center"><?php echo OUT_OF_STOCK_CANT_CHECKOUT; ?></p>

<?php
      }
    }
?>

  </div>

  <div class="buttonSet">
    <span class="buttonAction"><?php echo tep_draw_button(IMAGE_BUTTON_CHECKOUT, 'triangle-1-e', tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'), 'primary'); ?></span>
  </div>

<?php
    $initialize_checkout_methods = $payment_modules->checkout_initialization_method();

    if (!empty($initialize_checkout_methods)) {
?>

  <p align="right" style="clear: both; padding: 15px 50px 0 0;"><?php echo TEXT_ALTERNATIVE_CHECKOUT_METHODS; ?></p>

<?php
      reset($initialize_checkout_methods);
      while (list(, $value) = each($initialize_checkout_methods)) {
?>

  <p align="right"><?php echo $value; ?></p>

<?php
      }
    }
?>

</div>

</form>

<?php
  } else {
?>

<div class="contentContainer">
  <div class="contentText">
    <?php echo TEXT_CART_EMPTY; ?>

    <p align="right"><?php echo tep_draw_button(IMAGE_BUTTON_CONTINUE, 'triangle-1-e', tep_href_link(FILENAME_DEFAULT)); ?></p>
  </div>
</div>

<?php
  }

  require(DIR_WS_INCLUDES . 'template_bottom.php');
  require(DIR_WS_INCLUDES . 'application_bottom.php');
?>
 

Link to comment
Share on other sites

@@jjlyman I mentioned switching to the BS version only because your version is not mobile-ready and that will severely hurt it in the search engine rankings.

 

As for whether or not the addons you mention will work with the BS version, yes they will. But if a BS version of the addon is not available, its code may have to be altered to work. It is very, very, unlikely that they will be made part of the core code so that shouldn't be a consideration on whether to upgrade or not.

 

As for the main topic of this thread, the brackets are part of all oscommerce shops. I think Harold said they would look into this so maybe there will be a fix for it. But I would be surprised if there is one. It isn't invalid to use those symbols in a url and json commands use them and may get passed as a url (there are probably other examples too) so adding a fix for oscommerce, where the brackets are only used in attributes (off the top of my head) might break other code that gets added. It would be fixing something that isn't broken. But maybe Harold sees it differently.

 

The reason this is failing is due to your host making a change just for their servers. I suppose it is possible other hosts will do the same but I don't think it will be a common change. They are correct in saying a dedicated server would solve the problem but that is a silly answer, in my opinion. I've seen it made by many hosts for small problems since that is the easy way out for them. I think you will find that the bottom line is that they broke your shop and unless you can patch it to work, you will need to switch hosts. If you do patch it, be watchful for the next change they make since there will probably be others.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

All of My Addons

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

@@jjlyman  The code @@ShaGGy is suggesting that you replace is in the file you posted too.   All he did was to add the "urlencode".   A simple search and replace should accomplish what you want...

 

Find...

'products_id=' . $products[$i]['id'])

 

Replace with...
'products_id=' . urlencode($products[$i]['id']))

 

There should be two occurrences.

 

After that find...

'products_id=' . $products[$i]['id']

 

and Replace with...
' products_id=' . urlencode($products[$i]['id'])

 

That should do it.  Be sure to do it in this sequence and also keep a copy of your original shopping_cart.php in case you need to revert back to it....I'm using a different version of osC then you are so I can't test it.  If it doesn't work you can revert back to your original file.

 

Good luck...

 

Dan

Link to comment
Share on other sites

@@dan_Cole...thanks.  This fix seems to work !   ...huzzah...a fix (apparently...subject to more thorough testing, customer use) for the dreaded REMOVE products with attributes / "flower brackets" dilemma .  A couple hours ago, I had reduced ShaGGy's fix down to the same short strings that you cite above and posted that to Remove product shopping cart.php issue 2.3.4., but had not yet got 'round to testing it till now.

 

Let's be a bit more clear, here, for the community :  I'm using osC v2.3.4, non-BS.  We're referencing ShaGGy's fix “the two functions (remove from cart and product link in cart)”  which looks good as it basically accomplishes what you write above, except that my attempts to search on ShaGGy's code were not productive for some reason.  Its best, instead, to search only on the two short strings in your above post, in the file from the root directory version ...catalog/shopping_cart.php.  This fix references a file that's unmodified from original v2.3.4.

 

The original problem stems from the way that my host  iPower.com -- and possibly others -- handle the "flower brackets" { }   (restricted for some "security" reason, they say).  These brackets are generated by osC code for URL's of products that are entered with attributes (in your shopping cart, hover over item titles and "REMOVE" button to see the URL's with brackets).  Apparently, other hosts don't create this "brackets" handling problem.

 

Cross-referencing topic Remove product shopping cart.php issue 2.3.4. where this solution should also apply.

 

Earlier above, I also posted a fix for the shopping cart "ADD" products with attrinutes problem (citing a configure.php mod for SSL handling), but this fix may also be specific to the way that my host handles SSL...not sure, but it seems to work in my case.

 

Thanks to all for the help, and I hope that this relieves much grief in others.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...