Announcement

Collapse
No announcement yet.

Make attributes mutually exclusive

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

    Make attributes mutually exclusive

    Is it possible to have 3 attributes, each with its own set of choices where the attributes can be made mutually exclusive - say with radio buttons?

    I want to offer sizes for a product based on USA, UK or European sizes, each of which is mutually exclusive.

    TIA, Ken

    #2
    You have the ability to set as "optional" and you could also set the first choice to n/a, none etc


    Bikster
    SellerDeck Designs and Responsive Themes

    Comment


      #3
      Will these be the only Attributes on these products?
      Norman - www.drillpine.biz
      Edinburgh, U K / Bitez, Turkey

      Comment


        #4
        Yes, these will be the only 3 attributes (each with a range of choices) on these products. What I want to avoid is someone clicking on a USA choice and a UK or European one (or all 3). If that happened we wouldn't know which size was being ordered.

        Ken

        Comment


          #5
          Originally posted by jont View Post
          You have the ability to set as "optional" and you could also set the first choice to n/a, none etc
          Where does one set 'optional' for attributes - I'm afraid I can't see it?

          Comment


            #6
            'optional' is set at component level so you would need to put each attribute within a component to make each one optional.
            Have a play with the component settings and see which gives you the best result.
            Tracey

            Comment


              #7
              Would it not be a better idea to offer the 3 sizes together?

              ie UK8/US10/EU41 as ONE choice?

              I'm not sure there will be an easy way to prevent a customer clicking on a choice from more than one list otherwise?
              Tracey

              Comment


                #8
                I'd go with Tracey's suggestion, but if you'd rather have 3 lists, here's how to do it.

                This is a way to make a set of drop-downs mutually exclusive and also to prevent Add to Cart unless one is set.

                This works if you use simple Attributes for each Choice and set the first Choice to be "---" (without the quotes).

                Make a file "mutuallyexclusivechoices.js" in your Site folder from the following:

                Code:
                // mutually exclusive choices
                function exclusivechange(sel){		// called when drop-down changes - set other drop-downs to --- if appropriate
                	if ( sel.options[0].text != '---' ) return;			// ignore if this isn't an exclusive attribute
                	var thisname = sel.name;
                	var rootname = thisname.replace(/(v_.*_).*/, "$1");		// the basic variant name
                	for (i=1; i<6; i++)
                		{
                		var variant = document.getElementById(rootname + i);	// look for up to 6 variants
                		if ( variant )
                			{
                			if ( variant.type == "select-one" && (variant.name != thisname) )		// don't reset the current select
                				{
                				if ( variant.options[0].text == '---' )	variant.selectedIndex = 0;	// set other valid variants back to empty
                				}
                			}
                		}
                }
                
                function checksizeset(prodid){		// check that at least one of drop-down sets that start with --- have been set
                	var exclusiveitems = false;
                	var nosizeset = true;
                	for (i=1; i<6; i++)
                		{
                		var variant = document.getElementById('v_' + prodid + '_' + i);	// check up to 6 variants
                		if ( variant )
                			{
                			if ( (variant.type == "select-one") && (variant.options[0].text == '---') )	// is it a variant with --- entry
                				{
                				exclusiveitems = true;							// flag that we've some such items
                				if ( variant.selectedIndex != 0 ) nosizeset = false;			// if valid choice set, remember it
                				}
                			}
                		}
                	if ( exclusiveitems && nosizeset)				// warn if all --- choices undefined
                		{
                		alert('No size selected');
                		return false;
                		}
                	return true;
                }
                Edit your Overall Layout and place the following just above the "</head>" line (NB not the <head> line near the top):
                Code:
                	<script language="javascript" type="text/javascript" src="mutuallyexclusivechoices.js"></script>
                Edit your Product Layout(s) and look for the line
                Code:
                      <form method="post" action="<actinic:variable name="OnlineScriptURL" value="Shopping Cart Script URL" />">
                Change it to be
                Code:
                      <form method="post" action="<actinic:variable name="OnlineScriptURL" value="Shopping Cart Script URL" />"
                			onsubmit="return checksizeset('<actinic:variable name="ProductID" />');">
                Go to Design / Library / Layouts / Choice List / Drop Down Choice List / Click here to edit list layout settings.
                Replace Start of List with:
                Code:
                <select onchange="exclusivechange(this);"  id="<Actinic:Variable Name="UIWidgetName"/>" name="<Actinic:Variable Name="UIWidgetName"/>" class="form_input_general">
                That's it.

                OPERATION

                If you have Attributes using drop-down choices and you want to make them mutually exclusive, then make sure the first Choice is called "---" (without the quotes).

                Attributes using drop-downs that don't have the first Choice set to "---" will operate as usual.

                The above will work with upto 6 Attributes per product.
                Norman - www.drillpine.biz
                Edinburgh, U K / Bitez, Turkey

                Comment


                  #9
                  Originally posted by TraceyHand View Post
                  Would it not be a better idea to offer the 3 sizes together?

                  ie UK8/US10/EU41 as ONE choice?

                  I'm not sure there will be an easy way to prevent a customer clicking on a choice from more than one list otherwise?
                  Thanks Tracey. However, we have 12 UK sizes, 18 USA and 14 European. In a single list that makes it rather difficult as the sizes do not correspond exactly. Also, having tried it making small compromises on sizes, it doesn't look very elegant.

                  Ken

                  Comment


                    #10
                    Originally posted by NormanRouxel View Post
                    I'd go with Tracey's suggestion, but if you'd rather have 3 lists, here's how to do it..............
                    Thanks Norman - I'll give that a go later today.

                    Ken

                    Comment


                      #11
                      Originally posted by NormanRouxel View Post
                      Edit your Overall Layout and place the following just above the "</head>" line (NB not the <head> line near the top):
                      Code:
                      	<script language="javascript" type="text/javascript" src="mutuallyexclusivechoices.js"></script>
                      Edit your Product Layout(s) and look for the line
                      Code:
                            <form method="post" action="<actinic:variable name="OnlineScriptURL" value="Shopping Cart Script URL" />">
                      Change it to be
                      Code:
                            <form method="post" action="<actinic:variable name="OnlineScriptURL" value="Shopping Cart Script URL" />"
                      			onsubmit="return checksizeset('<actinic:variable name="ProductID" />');">
                      Go to Design / Library / Layouts / Choice List / Drop Down Choice List / Click here to edit list layout settings.
                      Replace Start of List with:
                      Code:
                      <select onchange="exclusivechange(this);"  id="<Actinic:Variable Name="UIWidgetName"/>" name="<Actinic:Variable Name="UIWidgetName"/>" class="form_input_general">
                      That's it.
                      Sorry to be a pain but I'm new to this - just evaluating Actinic V9 so please forgive my elementary questions.

                      1. I assume that 'Overall Layout' is called 'Outer Layout' in Actinic?

                      2. I'm sorry, but I can't identify the Product Layout(s) and a search for the expression actinic:variable name="OnlineScriptURL" doesn't seem to find anything.

                      Should I be editing this in Actinic or Dreamweaver (I have the plug-in installed)?

                      TIA, Ken

                      Comment


                        #12
                        Do everything in the Design tab in Actinic (except where told to go to Design / Library).

                        As for the questions.

                        1) Get a product showing in the Design Tab, click somewhere within it and click the up arrow until you can't go any further. Then look in the code display for the </head> line.

                        2) Simlarly click within a product and then look in the code display for the <form ...> line. If you can't see it, the up arrow until you're in the right place.

                        Backup and Snapshot first!!!

                        If you can't understand the above then follow one of the tutorials that takes you through editing a layout.
                        Norman - www.drillpine.biz
                        Edinburgh, U K / Bitez, Turkey

                        Comment


                          #13
                          Thanks very much indeed. I have no trouble finding the </head> part of the code.

                          However, I can't find the line:
                          <form method="post" action="<actinic:variable name="OnlineScriptURL" value="Shopping Cart Script URL" />"

                          The only <form...... line I can find is:
                          <form method="post" action="Shopping Cart Script URL" />"

                          In other words, there is no mention of 'actinic:variable name......'

                          It's weird though, because when I copy that line then paste it into my code editor the line appears exactly as you defined it! Does the Actinic code editor hide variables or something?

                          Later:
                          I assumed that the lines I found were the ones you intended and made the changes. It works brilliantly! I can't thank you enough.

                          Kindest regards, Ken
                          Last edited by oldcelt; 12-May-2008, 04:24 PM. Reason: Worked it out

                          Comment


                            #14
                            Actinic displays two alternative views in the Code window.

                            One shows the variable names in short form and the other shows what's really there.

                            You toggle between them by clicking the [><] icon that's in the top-left of the Layout Code window.
                            Norman - www.drillpine.biz
                            Edinburgh, U K / Bitez, Turkey

                            Comment


                              #15
                              Originally posted by NormanRouxel View Post
                              Actinic displays two alternative views in the Code window.

                              One shows the variable names in short form and the other shows what's really there.

                              You toggle between them by clicking the [><] icon that's in the top-left of the Layout Code window.
                              Ah, thanks a million. Takes a little while to work through the many permutations of Actinic. Javascript has never been my language but it doen't look too different from C or C++ so looks like I'll have to get down to it.

                              Again, many thanks for your patience and help.

                              Ken

                              Comment

                              Working...
                              X