Forums / Bug Reports / Redirect Issue in Shopping Cart Class When Overriding Shopping Cart Page

Redirect Issue in Shopping Cart Class When Overriding Shopping Cart Page

Started by numinix on 22 Dec 2014, 7:51 PM · Views: 1,910

Results 1 to 2 of 2
22 Dec 2014, 7:51 PM
#1
numinix avatar

numinix

Totally Zenned

Join Date:
Apr 2007
Location:
Vancouver, Canada
Posts:
1,568
Plugin Contributions:
59

Redirect Issue in Shopping Cart Class When Overriding Shopping Cart Page

In includes/classes/shopping_cart.php on line 1812 there is this code:

          if ((DISPLAY_CART == 'false' && $_GET['main_page'] != FILENAME_SHOPPING_CART) && $messageStack->size('shopping_cart') == 0) {
            $messageStack->add_session('header', ($this->display_debug_messages ? 'FUNCTION ' . __FUNCTION__ . ': ' : '') . SUCCESS_ADDED_TO_CART_PRODUCTS, 'success');
          } else {
            if ($_GET['main_page'] != FILENAME_SHOPPING_CART) {
              zen_redirect(zen_href_link(FILENAME_SHOPPING_CART));
            }
          }

This is inside a product loop and will redirect to the shopping cart page if the current page is not the shopping cart. The problem is that the redirect should actually be outside of the product loop and should only happen after all of the products have been updated. This doesn't happen in normal Zen Cart but becomes a bug if you try to override the shopping cart page and has DISPLAY_CART == 'true'. Only the first product in the loop will get updated.

Will changing the code to following cause any issues (just removing the else statement entirely)?

          if ((DISPLAY_CART == 'false' && $_GET['main_page'] != FILENAME_SHOPPING_CART) && $messageStack->size('shopping_cart') == 0) {
            $messageStack->add_session('header', ($this->display_debug_messages ? 'FUNCTION ' . __FUNCTION__ . ': ' : '') . SUCCESS_ADDED_TO_CART_PRODUCTS, 'success');
          }

It seems redundant to have that redirect since the last line of the function, outside of the loop is:

zen_redirect(zen_href_link($goto, zen_get_all_get_params($parameters))); 
22 Dec 2014, 7:55 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: Redirect Issue in Shopping Cart Class When Overriding Shopping Cart Page

numinix:

This doesn't happen in normal Zen Cart but becomes a bug if you try to override the shopping cart page
Please explain the bigger picture. You used the word "override", but then quoted code from a class, for which there are no "overrides" as far as the ZC definition of "overrides" goes (ie: template-specific override folders).

How can I re-create this scenario starting from a fresh brand new installation?

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.