We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum

Forum

Thread tagged as: Shop

Because you are outputting it as text in the final line of your template.

NB You can change the product template to suit your own needs. The supplied template is just an example.

Jonathan Elliman said:

Because you are outputting it as text in the final line of your template.

NB You can change the product template to suit your own needs. The supplied template is just an example.

Sorry, I don't see where in the template I could be doing that?

You've posted the template a few posts ago! The image template tag is repeated twice.

<a href="/shop/products/<perch:shop id="slug" type="slug" />/" data-ix="blog-interaction" class="blog-link w-inline-block"> <div class="shop-list-img-wrapper"><img src="<perch:shop type="image" id="prodImage1" />" class="blog-list-image"></div> <perch:shop id="title" type="text" /> <perch:shop id="prodImage1" type="Image" />  </a>

Gotcha! :) You've been a huge help so far Jonathan.... The listings page is as good as working.

Can you provide some assistance in getting my categories functioning? Question; do we just need perch_categories() or perch_shop_categories() When I call using perch_shop_categories(), it seems to break the listings that were there. I have setup all 5 categories I want to use in Perch Shop and have the set the category template as 'category'.

On the shop/index.php page I am calling the following:

<?php perch_shop_categories([
                'template' => 'product_category_link.html',
          ]
            ); ?>

and the template looks like this

<perch:categories id="category" set="products" label="Category">

    <perch:before> <ul class="catlist"></perch:before>
    <li class="cat-list"><a href="category.php?cat=<perch:shop id="categorySlug" />"><perch:shop id="categoryTitle" /></a></li>
    <perch:after></ul></perch:after>


</perch:categories>

You're welcome.

It depends on how your ui works. How are you using categories? At the moment you are just going to list out the categories. Are you hoping to have separate pages for each product category?

I have a shop landing page with a lefthand column listing the various categories and they're each listed on the righthand side. I'll basically have; All Products | Product A | Product B | Product C | Seasonal I don't need new pages for categories, just for them to list on the same shop landing page if that's possible?

Anything's possible!

If you click the categories surely you will display a new listing page showing products in that category?

So effectively you will have a url like /shop/category-slug/product-slug/

If so, you'll need to change the product list function to filter by the category slug in the url (if it exists).

category' => 'shop/'.perch_get('category'),

Have a search in the forum as there are examples.

Jon

Cool, I have all that working but how can I assign each of my listed product SKUs to their categories? I would have thought this was done via Perch Admin or do I need to pass extra arguments through the categories array??

You assign each product to a category (or more) in Perch Shop Admin. I think categories are in the default template. Just change the set name to match your own category set and the categories will display in the UI field on the edit page.

I'm not sure what I'm doing wrong. I have the category links working (per say) and can set different categories for each of my products, however when I click on any of the category links; all products display to the page irrespective of what I click!!

If you've got another page template – which I assume you now have as per "category.php" in your example above – then that page needs to filter products based upon the category slug in the url. e.g. the ?cat=<perch:shop id="categorySlug" /> bit.

Hi Jon, I'm a little bit confused by the above and categories is still not behaving for me. Any ideas what might be the issue from reviewing the below?

My shop landing page looks like this :

<div class="w-col w-col-3">

            <?php perch_categories([
                'template' => 'category.html',
                'category' => 'shop/'.perch_get('category'),
          ]
            ); ?>
          </ul>
        </div>

My category.html template:

<perch:before><ul class="catlist"></perch:before>
<li class="cat-list" style="margin-left: <perch:category id="catDepth" type="hidden" />0px;">
    <a class="cat-link" href="?cat=<perch:shop id="categorySlug" />"><perch:shop id="categoryTitle" />
    <h4><perch:category id="catTitle" type="smarttext" label="Title" required="true" /></h4>
    <perch:category id="catSlug" type="slug" for="catTitle" suppress="true" />
    <perch:category id="desc" type="textarea" label="Description" editor="markitup" markdown="true" size="s" />
</a></li>
<perch:after></ul></perch:after>

And within the product template I've match the category ID to be;

<perch:categories id="shop" set="shop" label="Category">
    <perch:category id="categorySlug" />
</perch:categories>

Hi

You are already displaying your categories. You want to filter the product list by category. So your basic set up is something like:

  1. Display a list of categories on a page with category ids in the links (currently your product list page)
  2. The links take you to a new page which contains the category as a query in the URL.
  3. The page filters the products by category in that URL.
  4. If there isn't a category in the URL then display all the products.

If you are still struggling after this, then may I suggest you contact someone in the registered developer list? Or join the Perch Slack channel and see if there's anyone there who might trade skills?

Jon

Jonathan Elliman said:

Hi

You are already displaying your categories. You want to filter the product list by category. So your basic set up is something like:

  1. Display a list of categories on a page with category ids in the links (currently your product list page)
  2. The links take you to a new page which contains the category as a query in the URL.
  3. The page filters the products by category in that URL.
  4. If there isn't a category in the URL then display all the products.

If you are still struggling after this, then may I suggest you contact someone in the registered developer list? Or join the Perch Slack channel and see if there's anyone there who might trade skills?

Jon

Thanks very much for your help to date Jonathan.