Skip to content
  • Recent
  • Tags
  • Popular
  • Users
  • Search
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

Lay Theme Forum

  1. Home
  2. General Discussion
  3. Custom Jquery for the Shop

Custom Jquery for the Shop

Scheduled Pinned Locked Moved General Discussion
6 Posts 2 Posters 926 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T
    T
    TYLM
    wrote on last edited by
    #1

    Hey y'all

    I would like to know how I can target the Shop (just the main page with all the products) with jQuery, as it apparently does not fall into the “Page” categorie but into the “Archive” categorie? I cannot use the if statement (type == "page" && obj.id == XX) right ??

    Thanks in advance for your answer!

    Théo

    1 Reply Last reply
    0
    • RichardR
      RichardR
      Richard
      Global Moderator
      wrote on last edited by Richard
      #2

      Dear Théo

      @TYLM

      My main shop page is a page is your's not?
      When applying the following code (documentation):

      <script>
      window.laytheme.on("newpageshown", function(layoutObj, type, obj){
      	console.log("layoutObj", layoutObj);
      	console.log("type", type);
      	console.log("obj", obj);
      });
      </script>
      

      I get a console readout:

      obj 
      {id: '11', type: 'page', slug: 'shop', catid: ''}
      catid: ""
      id: "11"
      slug: "shop"
      type: "page"
      [[Prototype]]: Object
      

      Then i can use the following if statement to be sure:

      <script>
      window.laytheme.on("newpageshown", function(layoutObj, type, obj){
      
      	if(type == "page" && obj.id == 11){
      		console.log("fantastic!");
      	}
      });
      </script>
      

      Result:

      Screen Shot 2022-01-13 at 8.20.02 AM.png

      So i know the code that i use within the if statement will be applied to this page.


      Hope this helps & best wishes Théo ✨
      Richard
      T 1 Reply Last reply
      0
      • RichardR Richard

        Dear Théo

        @TYLM

        My main shop page is a page is your's not?
        When applying the following code (documentation):

        <script>
        window.laytheme.on("newpageshown", function(layoutObj, type, obj){
        	console.log("layoutObj", layoutObj);
        	console.log("type", type);
        	console.log("obj", obj);
        });
        </script>
        

        I get a console readout:

        obj 
        {id: '11', type: 'page', slug: 'shop', catid: ''}
        catid: ""
        id: "11"
        slug: "shop"
        type: "page"
        [[Prototype]]: Object
        

        Then i can use the following if statement to be sure:

        <script>
        window.laytheme.on("newpageshown", function(layoutObj, type, obj){
        
        	if(type == "page" && obj.id == 11){
        		console.log("fantastic!");
        	}
        });
        </script>
        

        Result:

        Screen Shot 2022-01-13 at 8.20.02 AM.png

        So i know the code that i use within the if statement will be applied to this page.


        Hope this helps & best wishes Théo ✨
        Richard
        T
        T
        TYLM
        wrote on last edited by
        #3

        @Richard Thanks for your answer

        I don't know why but my shop page is not a page but an archive – it's not supposed to be tho. I applied the code to have the console readout and I get this :

        obj 
        Object { id: "553", type: "archive", slug: "product", catid: "" }
        catid: ""
        id: "553"
        slug: "product"
        type: "archive"
        <prototype>: Object { … }
        

        That's probably why I can't use the if statement correctly.
        It's weird that the slug here is "product" when the actual slug is "shop"…
        And I really don't understand that “Archive” thing.

        1 Reply Last reply
        0
        • RichardR
          RichardR
          Richard
          Global Moderator
          wrote on last edited by
          #4

          Dear Theo

          @TYLM

          Unsure why myself (could be your product page?), but regardless you can still use this information to apply jQuery:

          <script>
          window.laytheme.on("newpageshown", function(layoutObj, type, obj){
          
          	if(type == "archive" && obj.id == 553){
          		console.log("fantastic!");
          	}
          });
          </script>
          

          Best wishes ✨
          Richard
          T 1 Reply Last reply
          0
          • RichardR Richard

            Dear Theo

            @TYLM

            Unsure why myself (could be your product page?), but regardless you can still use this information to apply jQuery:

            <script>
            window.laytheme.on("newpageshown", function(layoutObj, type, obj){
            
            	if(type == "archive" && obj.id == 553){
            		console.log("fantastic!");
            	}
            });
            </script>
            

            Best wishes ✨
            Richard
            T
            T
            TYLM
            wrote on last edited by
            #5

            @Richard

            I will have to check that slug/type situation to be sure to have a clean and functional website in the future… But in the meantime the code you sent works perfectly! Thank you very much! :)

            Best wishes,

            1 Reply Last reply
            0
            • RichardR
              RichardR
              Richard
              Global Moderator
              wrote on last edited by
              #6

              Happy to help @TYLM have a great day ✨

              1 Reply Last reply
              0

              Hello! It looks like you're interested in this conversation, but you don't have an account yet.

              Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

              With your input, this post could be even better 💗

              Register Login
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              Online Users
              L
              lstark
              Forgot your key, lost your files, need a previous Lay Theme or Addon version? Go to www.laykeymanager.com
              laytheme.com
              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Recent
              • Tags
              • Popular
              • Users
              • Search