Forum

Thread tagged as: Question, Problem, Shop

Shop products not showing up (404)

I have Perch Shop working on a site with Perch Runway and right now my ~perch_shop_products~ page is linking to what I believe are the correct URLs, but they are resulting in 404 errors. I have a master page set for the individual product pages ("product-detail.html"). Here's how my templates are set up right now...

Product List / "Products" master page template (https://138.197.208.91/shop/):

<?php perch_shop_products([
'category' => 'products/olive-oil'
]);
?>

When the links on the Products page are clicked, I get a 404.

Inside the dashboard the products are set up and appear to be working correctly. Is this routing I have set up incorrectly?

Lindsay Masten

Lindsay Masten 0 points

  • 3 years ago

Yes, this is likely to be a routing issue since you get 404. What do you have set in the location tab, and advanced page settings tab for routes. Where is the actual master page at, and what is the structure of the site from root.

Lindsay,

I think the route is

products/[slug:product]

Then you access with perch_get(‘product’)

Hi Robert,

Where is the location tab? Settings product URL: /shop/products/{slug}

The master page is in templates/pages/ (at least, that is where I want it to be, it does not seem to be working that way now...)

The structure of the site is [root]/templates/pages/[master pages] with the shop templates located at [root]/templates/shop/[various shop folders]

Location tab is when looking at the page in admin, should be one of the available tabs.

Robert Ketter said:

Location tab is when looking at the page in admin, should be one of the available tabs.

I have /shop/products/{slug} for location. I also tried putting in the template name (products-list.html) and products/[slug:product] (just now).

Thanks for your help, as always, I think I'm woefully misunderstanding this... I thought Runway would link to the products 'out of the box' so to speak.

/shop/products/{slug} for location will not work, you must use routes to handle defining the slug which is why I have told you the route

location should be /shop/products pointed at your master page in settings with a route of products/[slug:product] OR shop/products/[slug:product] available by perch_get('product')

Lindsay, just to clean things up here, now that I am at my computer...

If your shop is at www . my_super_great_domain . com/shop

/shop

location = /shop
method = perch_shop_products(['category' => 'products/olive-oil'])
links = shop/products/the-slug-of-your-product

/shop/products

location = /shop/products
route = shop/products/[slug:product]
method = perch_shop_product(perch_get('product'));

Thank you so much Robert, that got the links from the products() page to the individual product() pages working!

Now though I am also getting a 404 when I click "Add to Cart". Do I need to change this route somewhere in the CMS as well...? I am just testing with the basic product.html template still, here is the code for the Add to Cart button:

<perch:form id="add_to_cart" app="perch_shop" action="/shop/cart"> <perch:input id="product" type="hidden" env-autofill="false" value="<perch:shop id="productID" type="hidden" env-autofill="false" />" /> <perch:input type="submit" value="Add to cart" /> </perch:form>

Ignore that last post, I figured it out! I had a typo in my cart master page.

Thanks again Robert (and Drew) for all the help.