Zen Cart Logo
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

Views: 1,903

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,566
Plugin Contributions:
58

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,513
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?