Announcement

Collapse
No announcement yet.

Edit Attributes on Basket

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Edit Attributes on Basket

    We put together a tutorial on how to implement this feature without a module. Attached is a pdf with step by step instructions. We've used this feature with a couple websites and it works well so we wanted to share it with the community.
    Attached Files
    Brennan Heyde
    VP Product
    Miva, Inc.
    [email protected]
    https://www.miva.com

    #2
    Re: Edit Attributes on Basket

    Brenan,

    I followed the manual and got this to working. Just one little thing I want to know, is there any way to pre-populate those options from the choices that user filled when he added the product to cart. Right now, a POST request is all I can think about, is there any other way to get those values pre-filled ?
    Rajnish Sinha
    ---------------------
    https://twitter.com/rajnishsi

    Comment


      #3
      Re: Edit Attributes on Basket

      When you do the ajax call to get the attributes you can pass in the current attributes as name, value pairs and it will set those values when it loads.
      Brennan Heyde
      VP Product
      Miva, Inc.
      [email protected]
      https://www.miva.com

      Comment


        #4
        Re: Edit Attributes on Basket

        No, they are not being set when I pass them as name-value pairs, I don't see any code in PROD Attribute Template to do that either. I tried with option:attr_code=option:data pairs, is anything wrong with those pairs ?
        Rajnish Sinha
        ---------------------
        https://twitter.com/rajnishsi

        Comment


          #5
          Re: Edit Attributes on Basket

          Brennan,

          Just following to see if you have any help for this ?
          Rajnish Sinha
          ---------------------
          https://twitter.com/rajnishsi

          Comment


            #6
            Re: Edit Attributes on Basket

            The best thing to do is on the product page, choose the attributes and change the form form POST to GET. This will show you the correct name value pairs you need to pass when passing attributes.
            Brennan Heyde
            VP Product
            Miva, Inc.
            [email protected]
            https://www.miva.com

            Comment


              #7
              Re: Edit Attributes on Basket

              Hit a wall again, not sure why, but l.settings:option:index variable keeps returning blank value. Is there any other way to keep track of option index or did I do something obviously wrong here ,
              Code:
              <mvt:assign name="l.settings:pairstring" value="''" />
              <mvt:foreach iterator="option" array="group:options">
                   <mvt:assign name="l.settings:pairstring" value="(  l.settings:pairstring $ 'Product_Attributes[' $ l.settings:option:index $  ']:code=' $ l.settings:option:attr_code $ '&')" />
                  <mvt:if expr="l.settings:option:option_id">
                       <mvt:assign name="l.settings:pairstring" value="(  l.settings:pairstring $ 'Product_Attributes[' $ l.settings:option:index $  ']:value=' $ l.settings:option:opt_prompt $ '&')" />
                  <mvt:elseif expr="NOT ISNULL l.settings:option:data">
                       <mvt:assign name="l.settings:pairstring" value="(  l.settings:pairstring $ 'Product_Attributes[' $ l.settings:option:index $  ']:value=' $ l.settings:option:data $ '&')" />
                  <mvt:elseif expr="NOT ISNULL l.settings:option:data_logn">
                       <mvt:assign name="l.settings:pairstring" value="(  l.settings:pairstring $ 'Product_Attributes[' $ l.settings:option:index $  ']:value=' $ l.settings:option:data_logn $ '&')" />
                  </mvt:if>
              </mvt:foreach>
              Rajnish Sinha
              ---------------------
              https://twitter.com/rajnishsi

              Comment


                #8
                Re: Edit Attributes on Basket

                I don't believe l.settings:option:index is set in that array.

                I think the issue is you're translate the options in the basket back into Attribute/Options of the products page. The basket page is not going to have the Product_Attribute index you need.

                You may have to do something different. Instead of passing the name value pairs in the format Miva expects just pass the attribute code and value like this:

                &mvt:option:attr_code;=&mvt:option:opt_code;

                Then on your product attribute template check to see if those values are set and if they are, output the correct attribute as selected.
                Brennan Heyde
                VP Product
                Miva, Inc.
                [email protected]
                https://www.miva.com

                Comment


                  #9
                  Re: Edit Attributes on Basket

                  I have this set up on a dev site. It used to work, and it did pull the pre-selected item options into the modal to be edited, (or so I thought). Now the modal opens with everything set to default values.

                  My main reason for abandoning this in the beginning was because I couldn't get it working if there were multiple items in the cart with attribute options.

                  Maybe one of the Miva core updates broke this function/procedure somehow? It did work as long as I had only one item in the cart with attributes.
                  Last edited by Ron Frigon; 09-30-15, 03:18 PM.
                  Ron Frigon
                  Jedi Webmaster Obi-Ron Kenobi

                  Comment


                    #10
                    Re: Edit Attributes on Basket

                    Originally posted by Brennan View Post
                    I don't believe l.settings:option:index is set in that array.

                    I think the issue is you're translate the options in the basket back into Attribute/Options of the products page. The basket page is not going to have the Product_Attribute index you need.

                    You may have to do something different. Instead of passing the name value pairs in the format Miva expects just pass the attribute code and value like this:

                    &mvt:option:attr_code;=&mvt:option:opt_code;

                    Then on your product attribute template check to see if those values are set and if they are, output the correct attribute as selected.
                    When I saw the token list and there was l.settings:option:index, so I thought it would be somehow identical to l.settings:attribute:index from PROD page. I guess I was wrong.

                    I'll try to create conditionals for &mvt:option:attr_code;=&mvt:option:opt_code; pairs in Attribute Template. Hoping I succeed this time.
                    Rajnish Sinha
                    ---------------------
                    https://twitter.com/rajnishsi

                    Comment


                      #11
                      Re: Edit Attributes on Basket

                      Brennan,

                      Hit a wall again,

                      When you said "Then on your product attribute template check to see if those values are set and if they are, output the correct attribute as selected." I thought that is going to be very easy, I just have to get the values set in GET parameters.

                      But, now, I'm not even able to get those values. Only method I know to receive GET/POST parameters is with g.Paramname, but how can I receive those parameters when they are getting set dynamically, I don't have access to their names in advance. I can't recall the method to receive this kind of request. Am I missing something ?

                      Is there anything I can do to receive all GET parameters in a single structure or array irrespective of their names?
                      Rajnish Sinha
                      ---------------------
                      https://twitter.com/rajnishsi

                      Comment


                        #12
                        Re: Edit Attributes on Basket

                        I think you need to set the name pairs when you call the 'edit basket' function.

                        So, for example (simplified)

                        <a href="~/merchant.mvc?Screen=EATP&Product_Code=fooballs&Att ribute=&mvt:attr:code;_&mvt:opt:code">Edit Attributes</a>

                        So, now, when you call the Edit Attribute function, you have a variable containing the attribute code and its selected option, so you can run conditionals like


                        <mvt:if expr="attribute_code EQ gettoken(g.attribute, '_', 1)">

                        <mvt:if expr="option_code EQ gettoken(g.attribute, '_', 2)">


                        (Sorry for potato code, busy morning.)
                        Bruce Golub
                        Phosphor Media - "Your Success is our Business"

                        Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
                        phosphormedia.com

                        Comment


                          #13
                          Re: Edit Attributes on Basket

                          Thanks Bruce, that did what I wanted, although I am feeling a little dumb right now. All that time I wasted to read parameters dynamically, and all I had to do was wrap them up in a single name !
                          Rajnish Sinha
                          ---------------------
                          https://twitter.com/rajnishsi

                          Comment


                            #14
                            Re: Edit Attributes on Basket

                            Rajnishsi, overthinking is a common malady of software development :)
                            Bruce Golub
                            Phosphor Media - "Your Success is our Business"

                            Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
                            phosphormedia.com

                            Comment


                              #15
                              Does this work with Levels Readytheme?

                              Comment

                              Working...
                              X