Announcement

Collapse
No announcement yet.

Cookie Consent bar like one on Miva.com

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

    Cookie Consent bar like one on Miva.com

    I was trying to add a cookie consent bar but I am using jQuery and its not working specially with the mobile menu. The menu won't open at all. I even added jQuery noconflict like below

    Code:
    jQuery.noConflict();
    jQuery(document).ready(function () {
        jQuery(document).gdprCookieLaw({
            moreLinkHref: 'https://your-domain.com/PRPO.html'
        });
    });
    Tried to debug in chrome and its was throwing an error in the theme.js file with this code below

    Code:
    Uncaught TypeError: $.hook(...).transfigureNavigation is not a function
        at theme.js:69
    
    line: 69 is
    
    $.loadScript(theme_path + 'extensions/navigation/transfigure-navigation.js', function () {
                $.hook('has-drop-down').transfigureNavigation();
            });
    What does Miva.com use for their cookie consent bar. Appreciate any input on this

    Thanks
    Keyboard Not Found..... Press F1 to continue

    #2
    If you haven't done so, you can use jQuery throughout your Shadows site so you would not have to worry about the no-conflict. I would try that and pull in the banner code after everything else has loaded. As for what is used on the Miva site, I am unsure.
    Matt Zimmermann

    Miva Web Developer
    Alchemy Web Development
    https://www.alchemywebdev.com
    Site Development - Maintenance - Consultation

    Miva Certified Developer
    Miva Professional Developer

    https://www.dev4web.net | Twitter

    Comment


      #3
      Hi Matt,

      Thanks for replying back. When you say jQuery can be used with Shadows theme, is that means jQuery js file is already loading. I am loading it in the footer after every other script.

      Thanks
      Keyboard Not Found..... Press F1 to continue

      Comment


        #4
        If your version of Shadows is not set for using jQuery, you can update it [ https://www.miva.com/forums/forum/de...ash-for-jquery ].
        Matt Zimmermann

        Miva Web Developer
        Alchemy Web Development
        https://www.alchemywebdev.com
        Site Development - Maintenance - Consultation

        Miva Certified Developer
        Miva Professional Developer

        https://www.dev4web.net | Twitter

        Comment


          #5
          Hi Matt,

          Can you please let me know how to check if my version of Shadows is set for using jQuery or not

          Thanks
          Keyboard Not Found..... Press F1 to continue

          Comment


            #6
            Hi Matt,

            I was able to load jQuery successfully and now the mini basket won't show up when clicked on the basket icon or when a product is added. Below the error I am getting

            Code:
            ajax-add-to-cart.js:15 Uncaught TypeError: Cannot read property 'textContent' of null
                at ajax-add-to-cart.js:15
                at ajax-add-to-cart.js:126
            
            and line 15 is: var purchaseButtonText = purchaseButton.textContent; in the ajax-add-to-cart.js
            Thanks
            Keyboard Not Found..... Press F1 to continue

            Comment


              #7
              You might want to check that your add-to-cart.js file is up to date. You can compare it to the file here: https://github.com/mivaecommerce/rea...add-to-cart.js
              Matt Zimmermann

              Miva Web Developer
              Alchemy Web Development
              https://www.alchemywebdev.com
              Site Development - Maintenance - Consultation

              Miva Certified Developer
              Miva Professional Developer

              https://www.dev4web.net | Twitter

              Comment


                #8
                Hey guys,

                Here is the code for the cookie bar on Miva.com. JQuery is required. It leaves the cookie for a few months, then you must click to agree again.

                JS
                Code:
                function getCookie(cname) {
                    var name = cname + "=";
                    var decodedCookie = decodeURIComponent(document.cookie);
                    var ca = decodedCookie.split(';');
                        for(var i = 0; i <ca.length; i++) {
                            var c = ca[i];
                        while (c.charAt(0) == ' ') {
                            c = c.substring(1);
                        }
                    if (c.indexOf(name) == 0) {
                        return c.substring(name.length, c.length);
                        }
                    }
                return "";
                }
                
                function setCloseCookie() {
                    var expire=new Date();
                    expire=new Date(expire.getTime()+5184000000);
                    document.cookie="cookies_popup=closed; expires=" + expire.toGMTString() + "; path=/;";
                }
                
                var popup_cookie = getCookie('cookies_popup');
                
                if (popup_cookie != 'closed'){
                     $("#cookieWarning").addClass("cookieOpen");
                }    
                
                $("#cookieWarning #cookieAccept").click(function() {
                    setCloseCookie();
                    $("#cookieWarning").addClass("cookieClosed");
                });


                HTML
                Code:
                <div id="cookieWarning">
                  <div id="cookieWrap" class="clearfix">
                    <p>This website uses cookies to identify visitors, track visitors to our website, store login session information and to remember your user preferences. By continuing to use this site you agree to our use of cookies. <a href="https://www.miva.com/privacy">Learn More.</a></p>
                    <a href="javascript:;" id="cookieAccept" class="btnBlueStandard">Accept</a>
                  </div>
                </div>


                CSS
                Code:
                // I removed some Miva-specific CSS here to just get the basic idea across. One class is the code when the cookie bar is displayed, the other is after consent is given.
                
                .cookieOpen {
                    display:block;
                }
                
                .cookieClosed {
                    display:none;
                }
                Last edited by sartaingerous; 04-16-20, 07:11 AM.

                Comment


                  #9
                  Will this work for any ReadyTheme? I think it's time to find a mobile-friendly "Cookie Accept". It would be really cool if this was already included within Miva.
                  Leslie Kirk
                  Miva Certified Developer
                  Miva Merchant Specialist since 1997
                  Previously of Webs Your Way
                  (aka Leslie Nord leslienord)

                  Email me: [email protected]
                  www.lesliekirk.com

                  Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr

                  Comment


                    #10
                    Originally posted by lesliekirk View Post
                    Will this work for any ReadyTheme? I think it's time to find a mobile-friendly "Cookie Accept". It would be really cool if this was already included within Miva.
                    I can't say whether or not this will work on any ReadyTheme, but you could give it a try. I'll see what I can do about creating an extension that would be default in Shadows and easily added to any other ReadyTheme.
                    Matt Zimmermann

                    Miva Web Developer
                    Alchemy Web Development
                    https://www.alchemywebdev.com
                    Site Development - Maintenance - Consultation

                    Miva Certified Developer
                    Miva Professional Developer

                    https://www.dev4web.net | Twitter

                    Comment

                    Working...
                    X