Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2012
    Posts
    412
    Plugin Contributions
    0

    Default Attribute values lost on redirect

    I have a custom form that comes up when "add to cart " on a product info page is clicked. The product info page has several attributes with default values that come up when the product info page first comes up. If the customer forgets to select a value for an attribute option, I want to display an error message and bring the product info page back up, with the attribute values set to the previous values, so the customer doesn't have to start over. In addition, I want this to happen before the custom form is displayed. I have the error message and redirect back to the product info page working, but the option values displayed are the default values, not the previously chosen values.

    How can I redirect back to the product info page from an extra cart action file with the selected option values shown?

    Thanks for any suggestions.

    zc155f

  2. #2
    Join Date
    Jul 2012
    Posts
    16,733
    Plugin Contributions
    17

    Default Re: Attribute values lost on redirect

    Basically need to capture the information that was originally posted, could then store it in a session value or if on this extra page there is a submit button there also, then the posted data could be again stored as post data that can then be processed again. Otherwise would capture the posted data as session data that then could be turned into posted data to be processed by includes/modules/YOUR_TEMPLATE/attributes.php. There is code there that re-selects the options previously chosen when the data is again available for processing.

    Take a look at code sections such as:
    Code:
                          if (!empty($_POST['id']) && is_array($_POST['id'])) {
                            $selected_attribute= false;
                            foreach ($_POST['id'] as $key => $value) {
                              if (($key == $products_options_names->fields['products_options_id'] and $value == $products_options->fields['products_options_values_id'])) {
                                // zen_get_products_name($_POST['products_id']) .
                                $selected_attribute = true;
                                break;
                              }
                            }
                          } else {
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #3
    Join Date
    Jun 2012
    Posts
    412
    Plugin Contributions
    0

    Default Re: Attribute values lost on redirect

    Quote Originally Posted by mc12345678 View Post
    Basically need to capture the information that was originally posted, could then store it in a session value or if on this extra page there is a submit button there also, then the posted data could be again stored as post data that can then be processed again.
    I have saved $_POST in $_SESSION just before the redirect back to the product info page in the extra cart actions file. $_POST is restored at the start of the file the next time through. But no joy.

  4. #4
    Join Date
    Jul 2012
    Posts
    16,733
    Plugin Contributions
    17

    Default Re: Attribute values lost on redirect

    Quote Originally Posted by Dave224 View Post
    I have saved $_POST in $_SESSION just before the redirect back to the product info page in the extra cart actions file. $_POST is restored at the start of the file the next time through. But no joy.
    It needs to be "restored" prior to includes/modules/YOUR_TEMPLATE/attributes.php is executed. This may be best supported as part of the includes/modules/pages/YOUR_PAGE load process either using an observer or adding an additional file for variables or the like...
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

 

 

Similar Threads

  1. v155 Attribute controller - error message when adding attribute values
    By rustwood in forum General Questions
    Replies: 8
    Last Post: 11 Jul 2016, 10:26 PM
  2. Copy attribute values to a different attribute name
    By pageblair in forum Setting Up Categories, Products, Attributes
    Replies: 1
    Last Post: 12 Jul 2010, 05:24 PM
  3. Linking attribute values to to product values (for custom gift baskets)
    By peaceviddie in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 13 Jul 2008, 09:22 PM
  4. Form Values Getting Lost?
    By jamina1 in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 18 Jan 2008, 04:57 PM
  5. v1.3.7 Option Values Manager lost value parts
    By asknight in forum Bug Reports
    Replies: 1
    Last Post: 10 Jan 2007, 07:57 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR