Announcement

Collapse
No announcement yet.

Checkbox prompt to prevent/allow add to cart

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

    Checkbox prompt to prevent/allow add to cart

    Good afternoon everyone,

    I have searched the forum, KB, AUG, Help files, but haven't found the solution yet. I'm sure there's something on this, but I can't bloody find it.

    Basically, one of my clients has a product that, due to export restrictions, cannot be shipped outside of the UK.

    I have tried restrict this using the shipping tables, but messes too much with the postage costs for multiple products, so I decided that I'd put a checkbox at product level saying "I live within the UK", hoping to highlight this point and deter foreign orders.

    However, I'm not sure how to combine that with the Add to Cart Button. Can anyone help.

    Many thanks,

    Rich

    P.S. My enter/return button only seems to work when the shift key is held down, does anyone know what I've done to the keyboard?

    Army Gore-tex
    Winter Climbing Mitts
    webD's Blog: Website design, SEO and other ramblings…
    Twitter LinkedIN

    If you think a post is good, rate it!

    Find the answers in the Knowledge Base | Have you read the User Guides


    #2
    Have you tried putting some javascript into the tick box / drop down which inserts some CSS to show the add to cart button (set it to hide for this product using a UDV)?

    ps - you have been hitting the keyboard too hard.


    Bikster
    SellerDeck Designs and Responsive Themes

    Comment


      #3
      Originally posted by jont View Post
      Have you tried putting some javascript into the tick box / drop down which inserts some CSS to show the add to cart button (set it to hide for this product using a UDV)?
      In the immortal words of Darren... WOOOOOOSSSSSHHHHH LOL

      Originally posted by jont View Post
      ps - you have been hitting the keyboard too hard.
      I don't think so. My first thought was that the key was knackered, but it does work when shift is used.

      I wondered if I'd fallen asleep on the keyboard and entered some obscure keystoke thats made the enter key redundant.

      Army Gore-tex
      Winter Climbing Mitts
      webD's Blog: Website design, SEO and other ramblings…
      Twitter LinkedIN

      If you think a post is good, rate it!

      Find the answers in the Knowledge Base | Have you read the User Guides

      Comment


        #4
        Originally posted by webD View Post

        P.S. My enter/return button only seems to work when the shift key is held down, does anyone know what I've done to the keyboard?
        just on the forum or in general?
        which shift key are you using? Maybe there's something stuck under it that is dislodged slightly when you use the shift key too?
        Tracey

        Comment


          #5
          Originally posted by webD View Post
          I wondered if I'd fallen asleep on the keyboard
          Most likely dribble... wreaks havoc with electrical contacts. If you have a big square indentation in your forehead that is the clue!


          Bikster
          SellerDeck Designs and Responsive Themes

          Comment


            #6
            Originally posted by jont View Post
            Have you tried putting some javascript into the tick box / drop down which inserts some CSS to show the add to cart button (set it to hide for this product using a UDV)?
            Happy New Year to you all. I hope everyone is recharged and refreshed?

            I decide to pick this up again and seem to be having an issue with the check box code and thought you guys may be able to help.

            To recap I'm trying to hide the Add to Cart Button unless the customer clicks the check box, confirming that this item is to be shipped to a UK address.

            This is what I have so far:

            Code:
            <input type="checkbox" NAME="switchBox" onClick="showhideText(this,'UKonly)">
            			 This Item is to be delivered to a UK addres</p>
                     <div style="float: right;">
                     <div id="UKonly" style="display:none">
                     <actinic:block if="%3cactinic%3avariable%20name%3d%22IsAddToCartButtonShown%22%20%2f%3e%20AND%20%0d%28%3cactinic%3avariable%20name%3d%22NumberAttributesInPushButtonGrid%22%20%2f%3e%20%3d%3d%200%29" >
                        <actinic:variable name="AddToCartButton" />
                     </actinic:block>
                     </div>
            However, Actinic seems to have an issue with the onClick element:

            A Javascript error has been found on the page ('Unterminated string constant')
            I have this working in DW, so I'm hoping it's a simple fix. I'll continue searching in the meantime.

            Army Gore-tex
            Winter Climbing Mitts
            webD's Blog: Website design, SEO and other ramblings…
            Twitter LinkedIN

            If you think a post is good, rate it!

            Find the answers in the Knowledge Base | Have you read the User Guides

            Comment


              #7
              Scrath that. I was missing a ' after the UKonly.

              Sorry

              Correct code should look like this:

              Code:
              <input type="checkbox" NAME="switchBox" onClick="showhideText(this,'UKonly')">
              			 This Item is to be delivered to a UK addres</p>
                       <div style="float: right;">
                       <div id="UKonly" style="display:none">
                       <actinic:block if="%3cactinic%3avariable%20name%3d%22IsAddToCartButtonShown%22%20%2f%3e%20AND%20%0d%28%3cactinic%3avariable%20name%3d%22NumberAttributesInPushButtonGrid%22%20%2f%3e%20%3d%3d%200%29" >
                          <actinic:variable name="AddToCartButton" />
                       </actinic:block>
                       </div>
              With this above </head>:

              Code:
              <script language="JavaScript" type="text/JavaScript">
              function showhideText(box,id)  
              { 
               var elm = document.getElementById(id) 
               elm.style.display = box.checked? "inline":"none" 
              }
              </script>

              Army Gore-tex
              Winter Climbing Mitts
              webD's Blog: Website design, SEO and other ramblings…
              Twitter LinkedIN

              If you think a post is good, rate it!

              Find the answers in the Knowledge Base | Have you read the User Guides

              Comment


                #8
                Sorry to butt in but I've a feeling that the customer may still be able to add to cart by hitting the Return key while the cursor is in the Quantity box (or any other text fields).

                My suggestion would be to check the form submission.

                Use a checkbox like this:
                Code:
                <input type="checkbox" id="UK_<actinic:variable name="ProductID" />" />
                In the product layouts <FORM ... > tag add:
                Code:
                onsubmit="return checkUK('UK_<actinic:variable name="ProductID" />')"
                and the HEAD area JavaScript:
                Code:
                <script language="JavaScript" type="text/JavaScript">
                function checkUK(id) { 
                 if (document.getElementById(id).checked) return true; 
                 alert('This product is for UK supply only');
                 return false; 
                }
                </script>
                You could combine this with your hide / show of the cart button.

                I've used the ProductID as this will make the code work for both single and multiple product per page sites (in case others use it in the future).
                Norman - www.drillpine.biz
                Edinburgh, U K / Bitez, Turkey

                Comment


                  #9
                  Oooooohhhhhhhhhhh...

                  Butt in by all means. I've done that as you have suggested, but the Button is not displaying now.

                  I'll have another look at it.

                  Thanks again, it didn't occur to me to hit the enter button

                  Army Gore-tex
                  Winter Climbing Mitts
                  webD's Blog: Website design, SEO and other ramblings…
                  Twitter LinkedIN

                  If you think a post is good, rate it!

                  Find the answers in the Knowledge Base | Have you read the User Guides

                  Comment


                    #10
                    Probably a typo that's broken the checkbox tag.

                    If you want to merge the two then just edit your existing checkbox tag and add

                    id="UK_<actinic:variable name="ProductID" />"
                    Norman - www.drillpine.biz
                    Edinburgh, U K / Bitez, Turkey

                    Comment


                      #11
                      I think you must have been right. I couldn't remedy the problem, so I started from scratch and it works great in online and off line preview.

                      I'm uploading now.

                      Thanks very much for your help.

                      Army Gore-tex
                      Winter Climbing Mitts
                      webD's Blog: Website design, SEO and other ramblings…
                      Twitter LinkedIN

                      If you think a post is good, rate it!

                      Find the answers in the Knowledge Base | Have you read the User Guides

                      Comment

                      Working...
                      X