Perch Shop Help
Starting a new thread for support assistance. I have the Perch shop installed on Perch runway. It's fully configured etc. Now I'm simply trying to link my categories and product listings to templates (whether they be the built in templates or my own) and nothing is outputting to the shop homepage? What am I missing here? What built-in templates from Perch Shop should I be using for these functions? Essentially all I require from Perch Shop is the ability to list SKUs/Products, Categorize them and have a detail page/slug for each listed SKU.
<div class="container toplayer">
<div class="blog-content w-row">
<div class="w-col w-col-4">
<ul class="catlist">
<?php
perch_shop_categories(array(
'template'=>'product_category_link.html'
));
?>
</ul>
</div>
<div class="w-col w-col-4">
<?php perch_shop_product(
['template' => 'product.html',
'count' => 10,]
);?>
</div>
</div>
</div>
category link template
<li class="cat-list"><a href="category.php?cat=<perch:shop id="categorySlug" />"><perch:shop id="categoryTitle" /></a></li>
diagnostics
Perch Runway: 3.1.2, PHP: 7.1.20, MySQL: 5.6.39, with PDO
Server OS: Linux, cgi-fcgi
Installed apps: content (3.1.2), assets (3.1.2), categories (3.1.2), perch_blog (5.6.1), perch_shop_orders (1.2.6), perch_shop_products (1.2.6), chirp_seo (1.2.1), perch_shop (1.2.6), perch_members (1.6.4)
App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_blog', 'perch_members', 'perch_shop', ); ?>
PERCH_LOGINPATH: /perch
PERCH_PATH: /var/www/vhosts/142/1004491/webspace/httpdocs/perch
PERCH_CORE: /var/www/vhosts/142/1004491/webspace/httpdocs/perch/core
PERCH_RESFILEPATH: /var/www/vhosts/142/1004491/webspace/httpdocs/perch/resources
Image manipulation: GD Imagick
PHP limits: Max upload 32M, Max POST 32M, Memory: 256M, Total max file upload: 32M
F1: 3b606135b33e6a102526838f4152a807
Resource folder writeable: Yes
HTTP_HOST: www.lirchocolates.com
DOCUMENT_ROOT: /var/www/vhosts/142/1004491/webspace/httpdocs
REQUEST_URI: /perch/core/settings/diagnostics/
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
When you call perch_shop_product(), you need to be passing a parameter of product slug. Otherwise your not going to get any product output. If you call perch_shop_products() you should get output of all the products in your shop.
Parameters
String Slug of the item to show
Array Options array, see table below
Boolean Set to true to have the value returned instead of echoed.
Hi
You need to use the function
perch_shop_products
to list the products.The product list template will then contain a link to the product details page, which might be something like:
Then on the product details page you should use the function
perch_shop_product
to fetch the product based upon the slug in the url.Which might be something like:
The
product
variable depends on how you've set up your routes on the pages in Runway. Variants and other url slugs (e.g. brand and categories) may complicate matters!Hope this helps.
Jon
Taking this one step at a time... To list all shop products, in my shop home page, in the area where I wish to list all products, I have this simple code not linked to any template.
I have added one product/sku in my shop. When I put this code in my shop page stops loading?!
Have you switched on debug? If your getting a blank page or an error you need to check your logs and root out the errors.
Identify the template that gets loaded into the page with the function – turn on debug to see the templates loaded for that page. If there's a template missing then it will be red.
Sorry Robert - we're answering at the same time. I will defer to you sir!
An obvious question.... If I'm simply calling ~~~<?php perch_shop_products(); ?> ~~~ then it's not using a listing template??!
The below piece of code is the what I want to use to list items, can you tell me how that should look as a listing template?
Jonathan, actually I will defer to you as I am on the road answering from my phone... so my answers are short and sweet, yours are much better and with examples :)
Debug enabled, assuming I review from Products section on Perch Admin? Apologies, I've used Perch for years but clueless when it comes to Perch Shop!!
Have you installed the sample templates from the shop app? Your template is still in the apps folder.
You should copy the app's templates folder into your perch/templates folder and they will give you all the info you need to get started.
You need to edit the file templates/shop/products/list.html or create your own template file and add that to the products function options.
I did, but there's honestly so many I wasn't sure which ones to base my code on! So using the built in list.html template and using my code for a listing + also taking in the fact that I only need to list the SKU; it's name and image and will have a Buy Now button where I can embed Shopify code. Does the below template code look right?
also, on my /shop/index.php page when I call the listings is the below sufficient to point to the above template?
I can't tell you I'm afraid! Is your shop/index.php page outputting the listing template? It should in theory. Even if your perch template tags are wrong it should still be outputting the html.
Debug will tell you which template files are called by functions. If it's wrong or missing then debug will tell you.
NB You will need to change the perch:content to perch:shop to pull the image through.
Hi, the page is loading but it's simply not loading the template. Am I calling it correctly? Does it need to be absolutely linked or does simply calling 'template' => 'list.html', work?
Re Debug, which page within the Perch dashboard should I reviewing debug from to find this info? The below debug is from the Products page, where I have one SKU added;
You need to look at the debug from the listing page - i.e. shop/index.php - that's where your product list function is right?
Hello Cormac,
If your template is in
perch/templates/shop/list.html
, your code is pointing to the file correctly. If it's inside a sub-folderperch/templates/shop/products/list.html
, you need to include the sub-folder in the path:Yes, but my shop index page doesn't show up on Perch as a listed page i.e. within the pages section. So I'm assuming that I would need to debug the products page.
You need to create the page in Perch. Perch Runway isn't like Perch in that it doesn't work with physical files as pages.
Finally, I've managed to get the product listings template functioning! :) Now, is there an easy way I can call the image that has been listed in Perch Admin Product Details to display.
i.e.
Just make sure the id in the listing template matches the one in your product template. i.e. the template you use to edit your product in Perch Admin.
Is
prodImage1
an id in your product template?Putting
<perch:showall/>
in your template will list all the ids available to you.Okay!, that's a cool trick <perch:showall/> :) So it's just working off the built in template (product.html). I've updated the ID here to suit prodImage1 and it works. Only it's passing the value across too, i.e. the image file name is displaying: /perch/resources/sample11.png anyway to disable that?