Skip to content
  • Recent
  • Tags
  • Popular
  • Users
  • Search
Skins
  • Light
  • 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 79 Views
  • 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 Offline
    T Offline
    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 Offline
      RichardR Offline
      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 Offline
        T Offline
        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 Offline
          RichardR Offline
          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 Offline
            T Offline
            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 Offline
              RichardR Offline
              Richard
              Global Moderator
              wrote on last edited by
              #6

              Happy to help @TYLM have a great day ✨

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              I also code custom websites or custom Lay features.
              💿 Email me here: 💿
              info@laytheme.com

              Before you post:
              1. When using a WordPress Cache plugin, disable it or clear your cache.
              2. Update Lay Theme and all Lay Theme Addons
              3. Disable all Plugins
              4. Go to Lay Options → Custom CSS & HTML, click "Turn Off All Custom Code", click "Save Changes"

              This often solves issues you might run into

              When you post:
              1. Post a link to where the problem is
              2. Does the problem happen on Chrome, Firefox, Safari or iPhone or Android?
              3. If the problem is difficult to explain, post screenshots / link to a video to explain it
              Online Users
              K
              Kai Schecker
              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