Announcement

Collapse
No announcement yet.

mandatory tick box?

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

    mandatory tick box?

    Does anyone know if it’s possible to make a component or attribute to a product mandatory?

    Basically I need to ensure that the person has read and agree to some conditions before they order a specific item. I’d ideally like it to be a tick box that basically they need to tick to buy the product..if they don’t..they cant.

    Any ideas anyone?

    Cheers v much

    Andy

    #2
    You could try replacing the Add to Cart button with some code that checks whether a T&C field has been checked and if not inhibits the form being submitted.


    i.e. Copy your usual Product Template to a new file and in that file replace NETQUOTEVAR:ADDTOCARTBUTTON with

    Code:
    NETQUOTEVAR:VARIANTS<!-- NETQUOTEVAR:VARIANTADDTOCARTBUTTON -->
    			<input type=checkbox name="TAC_NETQUOTEVAR:PRODUCTREFERENCE">I have read the terms and conditions
    			<INPUT TYPE="IMAGE" SRC="add_to_basket.gif" NAME="_NETQUOTEVAR:PRODUCTREFERENCE" WIDTH="80" HEIGHT="22" BORDER="0" 
                                   onclick="if (TAC_NETQUOTEVAR:PRODUCTREFERENCE.checked) {return true} 
                                              else {alert('You must agree to the Terms'); return false;}">
    This isn't 100% foolproof as it doesn't intercept the Enter key being used to submit the product.

    Norman
    Norman - www.drillpine.biz
    Edinburgh, U K / Bitez, Turkey

    Comment


      #3
      thanks v much for that, i shall give it a go!

      a quickie...forgive the possible ignorance of a novice, but would this apply this conditional check to all products?..or only ones that had the 'i have read the t & c' check box on it? I presume its only for products that have this box, however I am not exactly a code bod so thought id best ask!

      many thanks

      Andy

      Comment


        #4
        You copy your usual Product Template to a new file, which you then patch as above. You then select that Template only for the products that need this checkbox.

        Also you don't need to create a Component, the checkbox is created for you in the template.

        If you'd rather create a component then use the following instead.

        Code:
        Create a component called Terms Read.   
        Make it Optional.
        Set it's HTML for name to be   I have read the Terms......
        Place this component at the end of any other Attributes or Components.
        
        Again make a new Product Template to and in that file replace NETQUOTEVAR:ADDTOCARTBUTTON with
        
        			NETQUOTEVAR:VARIANTS<!-- NETQUOTEVAR:VARIANTADDTOCARTBUTTON -->
        			<INPUT TYPE="IMAGE" SRC="add_to_basket.gif" NAME="_NETQUOTEVAR:PRODUCTREFERENCE" WIDTH="80" HEIGHT="22" BORDER="0" 
                                       onclick="if (getElementById('v_' + 'NETQUOTEVAR:PRODUCTREFERENCE' + '_1').checked) {return true} 
                                                else {alert('You must agree to the Terms'); return false;}">
        Note the _1 above. That refers to the sequence of the variants (Checkboxes, Radio Button Sets, Select boxes). Use _1 if you only have one Component. Use _2 if you have 2. Basically locate that Terms component last and use the correct sequence number for it.

        Norman
        Norman - www.drillpine.biz
        Edinburgh, U K / Bitez, Turkey

        Comment


          #5
          Fab

          i shall try both and see how i get on...could take me a while I'm not that great at this sort of thing!

          Many thanks again for the help t..its much appreciated

          Andy

          Comment


            #6
            Andy,

            Ignore the above.

            Here's a much better patch that allows you to vary the displayed message and warning and also works with all browsers (well at least all I've tested with - Netscape, IE and Opera). It also gets around the Enter key bypassing the warning.

            Code:
            Adding compulsory Terms and Conditions checkbox to a Product.
            This patch will add a checkbox to the product that must be checked 
            before the product can be added to the cart.  
            A warning message will be displayed if it's not checked.
            
            
            INSTALLATION
            
            In Act_Primary.html, just above the </HEAD> tag add the following
            
            
            <script language=JavaScript>
            <!-- Form Field helper files
            var docform;
            function formfieldbyid(fname){		// return the form field id "fname"
              var df = document.forms;
              var i = df.length - 1;
              for ( var j = 0; j <= i; j++ )
                {
                var k = df[j].length - 1; 
                for ( var l = 0; l <= k; l++ )
                  {
                  if ( df[j].elements[l].id == (fname) ) return df[j].elements[l];
                  }
                }
              // shouldn't get here but...
              alert('Cannot find form element' + fname);
              return false;
            }
            
            function formbyfieldid(fname){		// return the form that contains unique field "fname"
              var tf = -1;
              var te = 0;
              var df = document.forms;
              var i = df.length - 1;
              for ( var j = 0; j <= i; j++ )
                {
                var k = df[j].length - 1; 
                for ( var l = 0; l <= k; l++ )
                  {
                  if ( df[j].elements[l].id == (fname) ) return df[j];
                  }
                }
              // shouldn't get here but...
              alert('Cannot find form element' + fname);
              return false;
            }
            // -->
            </script>
            
            
            
            Copy Act_ProductLine.html to a new file (say TandC-Act_productLine.html)
            Edit TandC-Act_productLine.html and replace the fragment
            
            			NETQUOTEVAR:ADDTOCARTBUTTON
            
            with
            
            
            
            <!-- Terms and conditions patch -->
            NETQUOTEVAR:VARIANTS<!-- NETQUOTEVAR:VARIANTADDTOCARTBUTTON -->
            <input type=checkbox id="TAC_NETQUOTEVAR:PRODUCTREFERENCE"> CUSTOMVAR:TERMSTEXT 
            <INPUT TYPE="IMAGE" SRC="add_to_basket.gif" NAME="_NETQUOTEVAR:PRODUCTREFERENCE" WIDTH="80" HEIGHT="22" BORDER="0">
            <script language=JavaScript>
            <!-- 
            var thisform = formbyfieldid('TAC_NETQUOTEVAR:PRODUCTREFERENCE');
            if (thisform){ thisform.onsubmit = function(){if (formfieldbyid('TAC_NETQUOTEVAR:PRODUCTREFERENCE').checked) {return true;} else {alert('CUSTOMVAR:TERMSWARNING');return false}}};
            // -->
            </script>
            
            
            In Actinic go to Advanced / Custom Properties and create 2 Custom Properties
            called TERMSTEXT and TERMSWARNING.
            
            Go to Design / Options / Site Defaults / Properties.
            Click the "+" sign and select TERMSTEXT
            Enter the text to display on the product page against the checkbox,
             e.g. "I have read the terms and conditions".  Do not use the single quote character ( ' )in this text.
             You can put HTML linking or popping up your actual terms page here if you like.
            (if using Business clear Searchable and check "Use as Customvar".
            
            Click the "+" sign and select TERMSWARNING
            Enter the text to display on the product page against the warning if they don't check the above,
             e.g. "You must agree to the terms and conditions".  Do not use the single quote character ( ' )in this text.
            (if using Business clear Searchable and check "Use as Customvar".
            
            That's Installation done.  
            
            
            OPERATION
            
            
            For products that require this warning simply select TandC-Act_productLine.html for your Product Template.
            
            Optionally, and recommended, if you want to carry a note that the box has been clicked onto the Cart 
            and Order then do the following:-
            
            In the Product dialogue create a Component called "Terms Read" or "Terms and Conditions Accepted", etc.
            In the Component Details, uncheck "Is Optional".
            In HTML for name field, clear the entry.
            
            Finally, you can vary the Custom Properties TERMSTEXT and TERMSWARNING at the product level if you like.

            Norman
            Norman - www.drillpine.biz
            Edinburgh, U K / Bitez, Turkey

            Comment


              #7
              Ooops. I forgot to mention:-

              The above patch is intended for "Quantity on Product Page" type sections (without the single "Add to Cart" button).

              Norman
              Norman - www.drillpine.biz
              Edinburgh, U K / Bitez, Turkey

              Comment


                #8
                Thanks for this Norman - I need the same thing, where certain items have their own terms and conditions. So this should do the trick.

                Comment


                  #9
                  A timely post. I need something similar and I'd forgotten that I'd already done this myself

                  Norman
                  Norman - www.drillpine.biz
                  Edinburgh, U K / Bitez, Turkey

                  Comment

                  Working...
                  X