Okay
  Public Ticket #1935416
popups in Shopify - limit with cookie?
Closed

Comments

  • Jamie started the conversation

    First off...let me preface this with the fact that I'm using the Layerslider-for-jQuery product with my Shopify store, so I cannot take advantage of the targeting and other built-in WP features.  Also, unfortunately, I'm not a coder (although not completely clueless either...as they say - just enough knowledge to be dangerous).  It's time to call in some professionals!

    I have created a Layerslider welcome popup that I'd like to show only once per two days if the user clicks the "don't show again" input (where 2 is linked to their cookie's expiration).

    For example, the old popup on my site used fancybox along with jquery.cookie.js to accomplish this.  I feel like there might be a way to combine the jquery.cookie.js functionality with layerslider (maybe as a binding event?)  This is the original code that I'm trying to tweak to do this:

    • The opening html, and the input at the end linked to the cookie: 


    •  

         
       

         
          
         
      (...)
            don't show again }}
      • The jQuery (note that {{settings.popup_expires}} = 2):
        {{ 'jquery.cookie.js' | asset_url | script_tag }} 

      ...........................

      • So I tried to wrap my new layerslider popup as such: 
          
      • And included the following input: 

        Don't show again

      >>>>But now I'm stuck on how to combine the cookie.js with the js Initializing the slider.  

      (>>>Also - unrelated - but is there a hack to fix the skins path issue that arises if you can't have nested assets - as is the case with Shopify?)

      I hope this made some sense.  Can you help?  

     
  • Jamie replied

    My code is disappearing from the original post....how to include code without it being processed as code?  I attached it as a text file instead.

  • [deleted] replied

    Hello Jamiesirensong,

    Thank you for getting in touch with us. My name is Attila and I'm happy to assist you today.

    I would like to confirm that we have received your message. Due to the nature of the issue you are experiencing, I will have to contact and consult with the development team first. I will get back to you as soon as I can.

    We appreciate your patience while we're working towards your ticket.

  • [deleted] replied

    Thank you for your patience.

    We are sorry, but we cannot write your cookie handling code for you. Unfortunately we cannot help with custom js codes, so this will has to be done by yourself. But once you get the cookie handling to work, then you can easily make the popup slider init to load only when the cookie lets it. All you need is to call the init code inside an IF check.

    Regarding the skin problem. You can use absolute and relative URLs too, both will work. But if you can provide us with further info on this case, or explain the problem in more details, we can help you further with it.

  • Jamie replied

    Attila,

    Thanks for looking into it for me. 

    In case anybody else is trying to do this - after much trial and error, I gave up on the checkbox and instead set it so that the popup won't show until the cookie expires in 24 hours. Here is the code I'm using:

    {{ 'jquery.cookie.js' | asset_url | script_tag }} 
    < script type="text/javascript">
      
      jQuery(document).ready(function(){
              if (!$.cookie('showpop')) {
                $('#slider').layerSlider({
                    createdWith: '6.5.7',
                    sliderVersion: '6.6.4',
                    type: 'popup',
                    skin: 'v6',
                    popupWidth: 760,
                    popupHeight: 600,
                    globalBGImage: '//cdn.shopify.com/s/files/1/1021/4279/files/charliebg.jpg',
                    globalBGSize: 'cover',
                    navPrevNext: false,
                    hoverPrevNext: false,
                    navStartStop: false,
                    navButtons: false,
                    showCircleTimer: false,
                    popupShowOnTimeout: 6,
                    popupShowOnce: true,
                    popupShowCloseButton: true,
                    popupStartSliderImmediately: true,
                    popupTransitionIn: 'slidefrombottom',
                    popupOverlayBackground: 'rgba(0,0,0,.75)',
                    skinsPath: '//cdn.shopify.com/s/files/1/1021/4279/t/46/assets/',
                    plugins: ['popup']
                });
            };
        var date = new Date();
        date.setTime(date.getTime() + 24 * 60 * 60 * 1000);
        $('#slider').on('popupDidClose', function(event, slider) {
        $.cookie('showpop', true, { expires: date});
    });
    });    
    < /script>
    

    Regarding the skins issue - let me try to explain in more detail:

    When the popup initiates, it automatically looks for the skin's css and associated files at a url that combines the name of the specified skin and skinsPath (e.g., it adds '/v6/' to the end of the skinsPath).  Shopify does not allow the creation of folders (e.g., '/v6/'), and thus I get an error. 

    Would it work to just copy the css for the skins directly into the layerslider.popup.css file?  And/or can you explain how I should format my url to clear the error?

    Thanks!

  • [deleted] replied

    Thank you for the feedback.

    That might a problem for skins, but I believe we can work around this Shopify limitation.

    Please extract the attached zip and copy the inside files to: cdn.shopify.com/s/files/1/1021/4279/t/46/assets/

    Then rename skin to assets in the init code. And change the skinsPath to: //cdn.shopify.com/s/files/1/1021/4279/t/46/

    It should be working this way.