• Using the twenty twelve theme on a base wordpress install and only the wc plugin, I noticed some problems with the base shop page and am not sure if this is by design but think it can cause some confusion with setting the meta, seo, and custom themes that have added functions to wp pages.

    I did some testing and this appears to be a bug, maybe I’m wrong though.

    In the theme’s footer.php I called “echo get_the_title()” expecting the result to be “shop” when I open my shop page but it was not. The result was “Hello World” – which is the default first post on a base install of wordpress. Also, the meta was from that post as well, not the shop pages meta???

    Since I didn’t have any products yet, I went ahead created one really quick and named it “A1 Steak Sauce” and then went back to the shop page and refreshed…yep, you guessed it, I now had a tasty meat sauce title in the footer of my page.

    I then added a few more products to see what would happen and the result is always the title of the first alphabetically titled product.

    Shouldn’t I be getting the “shop” page title and meta? What other things are missing I wondered…so I added and activated another theme that I know adds some custom functions to the pages and sure enough the result was layouts, templates, custom fields, slugs, etc. are all the result of whatever post or product-post is first in line alphabetically.

    So, basically, it appears that the shop page is not being treated like a page but rather a post archive. Is this the best way to get the products listed and paginated in this cart? It seems like maybe some more thought should go into refining how this works but I do realize this is a free cart and we can also override all of this via a custom theme. So I’m simply looking for others input on this, am I missing something or should this be fixed?

    Just my two cents I suppose.

    https://www.ads-software.com/extend/plugins/woocommerce/

Viewing 7 replies - 1 through 7 (of 7 total)
  • I did some testing and this appears to be a bug, maybe I’m wrong though.

    In the theme’s footer.php I called “echo get_the_title()” expecting the result to be “shop” when I open my shop page but it was not. The result was “Hello World” – which is the default first post on a base install of wordpress.

    A bug? are you kidding me?
    You need to read the WP codex. this has absolutely nothing to do with woocommerce. You have get_the_title() and get_bloginfo(‘name’) confused.

    https://codex.www.ads-software.com/Function_Reference/get_the_title

    https://codex.www.ads-software.com/Function_Reference/get_bloginfo

    So, basically, it appears that the shop page is not being treated like a page but rather a post archive. Is this the best way to get the products listed and paginated in this cart?

    What else would you expect to see in a “shop” page other than a list of products? If there’s anything worth complaining about the shop page, it’s that changing the number of columns is neither easy nor simple.

    Thread Starter pingram

    (@pingram3541)

    First, don’t be a [ unnecessary personal comment redacted ] when its not necessary. I wasn’t complaining about anything nor was I being mean about it, if you take the time to read closer I was asking if this is intentional or not. It definitely makes styling the shop page a bit difficult, especially if you use a framework that adds custom hooks to the pages, like templates and layouts that are assigned to the pages.

    Second, know what you’re talking about before you start a flame, the get_bloginfo(‘name’) gets the title of the site/blog, this would return the same result across all pages/posts which is not what I was even looking for in my tests, I wanted to retrieve my actual page’s title, i.e. Cart/My Account/Shop/Contact etc.

    The shop page’s “title” was just an example, I tried many other tests as well, i.e. $post->ID; or the_meta(); and each was as I suspected, the result being the data of the first matching post/product, not the actual pages title, id or custom fields. Yes, I fully understand and desire that a default shop page SHOULD pull a list of products, that was not what I was questioning at all, however I DO think it is useful to be able to add custom fields on the “shop” page and have them returned for actual use. This is not the case currently.

    i.e.

    • color:yellow was assigned to the “hello world” post, the_meta() returned color:yellow – thumbs up
    • color:red was assigned the “my account” page, the_meta() returned color:red – thumbs up
    • color:blue was assigned to the “shop” page, the_meta() returned color:yellow – thumbs down!!!

    All in all, I had to modify my theme to get around this possibly intentional quirk. In my case, a framework that allows me to choose a layout for each page which assigns the grid, widget placement and custom css. The layout always being returned was always the layout of the first alphabetically listed product, NOT THE ASSIGNED PAGES LAYOUT making the styling of my shop page identical to my products . Building an alternative shop page and hard linking was a pain because the cart and widgets link to the shop page assigned in woocommerce settings, so that doesn’t work. Finally I found the right hook, woocommerce_get_page_id(‘shop’) and added to my theme:

    if(is_shop()){
    	$posttype='archive';
    	$shop_page_id = woocommerce_get_page_id('shop');
    	$layout =  layoutValid(get_post_meta($shop_page_id, 'framework_layout', true));
    }

    And now I can assign the actual shop page’s layout so my shop page is styled the way I want it…but man, what a pain to have to go through this…maybe 2.0 addresses this?

    Thread Starter pingram

    (@pingram3541)

    p.s. also to add, I changed the default shop page title to “catalog” and confirmed the above code still works.

    If there’s anything worth complaining about the shop page, it’s that changing the number of columns is neither easy nor simple.

    I’m using js for now but will probably just build a child-theme once I have some time to delve into it. Adding random and 3 column instead of 4 by reassigning the first/last classes.

    (function($) {
    $.fn.randomize = function(childElem) {
      return this.each(function() {
          var $this = $(this);
          var elems = $this.children(childElem);
    
          elems.sort(function() { return (Math.round(Math.random())-0.5); });  
    
          $this.remove(childElem);  
    
          for(var i=0; i < elems.length; i++)
            $this.append(elems[i]);      
    
      });
    }
    $("ul.products").randomize("li.product").removeClass('first last');
    $(".product:nth-child(1n)").addClass('first');
    $(".product:nth-child(3n)").addClass('last').removeClass('first');
    $(".product:nth-child(3n)").prev().removeClass('first');
    
    })(jQuery);

    Perhaps I misunderstood the reasoning your confusion over what “get_the_title()” should display.

    Yes, the shop page isn’t a real page. It’s just a placeholder for the products archive (similar to how wordpress allows you to set a “blog” page)

    A page is static content. The shop page is not the place for static content, but for a loop filled with product items.

    though, it appears that you can, in fact access postmeta from a “blog” page. I’m sure this is intentional, as it has been mentioned on github. Not really sure the reasoning behind it, though.

    Thread Starter pingram

    (@pingram3541)

    Yep, that’s all I was trying to point out and ask if this was intentional as there are many frameworks nowadays that promote minimal or even no coding at all, most of which hook their layout or template to the individual page/post and others that even allow assignment to post type, such as products and product-single in case of WC.

    Some consumers might think this will give them control over the shop’s product presentation, and unless the framework developer addresses this directly, this is unlikely and you best purchase a custom wc theme or write your own.

    @pingram3541,

    I agree with you that the shop page is a pain to figure out how to customize if you don’t necessarily want products listed or you want to use a different sidebar than what is used for archive pages. I’ve been struggling with figuring this out for weeks now and haven’t found a solution. It shouldn’t be so difficult to make the shop page different from the other archive pages.

    How exactly did you use the woocommerce_get_page_id('shop') hook? By using this were you able to style your shop page any way you want including adding it’s own sidebar?

    Thanx in advance for any input you might have.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘WC Base Shop Page – Meta/Title/Other issues?’ is closed to new replies.