Forum

Thread tagged as: Shop

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
Cormac Kerrigan

Cormac Kerrigan 0 points

  • 2 years ago

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:

<a href="/products/<perch:shop id="slug" type="slug">/">Link to product</a>

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:

perch_shop_product(perch_get('product'),[
            'template' => 'products/product_detail.html',
            'filter' => 'slug',
            'match' => 'eq',
            'value' => perch_get('product')
        ]);

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.

        <div class="w-col w-col-4">
          <?php perch_shop_products(); ?>
        </div>

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?

    <div data-ix="popup" class="shop-listing">
            <a href="#" data-ix="blog-interaction" class="blog-link w-inline-block">
              <div class="shop-list-img-wrapper"><img src="../images/sample10.png" class="blog-list-image"></div>
            </a>
            <div class="listing-wrapper">
              <h3 class="listing">The Discovery Collection</h3>
            </div><a href="#" class="button shop-button w-button">find out more</a>
          </div>

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!!

Debug Message - Perch Runway 3.1.2
[1] SELECT u.*, r.* FROM perch3_users u, perch3_user_roles r WHERE u.roleID=r.roleID AND u.userEnabled=1 AND u.userID=1 AND u.userHash='1b495e9013196049537212fc0c623ae3' LIMIT 1
UPDATE perch3_users SET userHash='687869c2a8d8657099d0f4dfa28516e8' WHERE userID='1'
[46] SELECT settingID, settingValue, userID FROM perch3_settings WHERE userID=1 OR userID=0 ORDER BY userID ASC
[12] SELECT itemValue FROM perch3_menu_items WHERE itemType='app'
[1] SELECT SQL_CALC_FOUND_ROWS DISTINCT * FROM perch3_shop_products WHERE parentID IS NULL AND productDeleted IS NULL ORDER BY title ASC LIMIT 0, 24
[1] SELECT FOUND_ROWS() AS `count`
[1] SELECT mi.*, p.privKey FROM perch3_menu_items mi LEFT JOIN perch3_user_privileges p ON mi.privID=p.privID WHERE mi.itemActive=1 AND mi.parentID=0 ORDER BY itemOrder ASC LIMIT 0, 1
[7] SELECT mi.*, p.privKey FROM perch3_menu_items mi LEFT JOIN perch3_user_privileges p ON mi.privID=p.privID WHERE mi.itemActive=1 AND mi.parentID=1 ORDER BY mi.itemOrder ASC
[1] SELECT itemTitle FROM perch3_menu_items WHERE itemType='app' AND itemValue='perch_shop_products' LIMIT 1
[1] SELECT mi.*, p.privKey FROM perch3_menu_items mi LEFT JOIN perch3_user_privileges p ON mi.privID=p.privID WHERE mi.itemActive=1 AND mi.parentID=0 ORDER BY itemOrder ASC LIMIT 1, 10
[2] SELECT mi.*, p.privKey FROM perch3_menu_items mi LEFT JOIN perch3_user_privileges p ON mi.privID=p.privID WHERE mi.itemActive=1 AND mi.parentID=2 ORDER BY mi.itemOrder ASC
File: /addons/apps/perch_shop_products/modes/products.list.post.php
Looking up missing property price
[1] SELECT * FROM perch3_shop_currencies WHERE currencyID=44 LIMIT 1
Mode: products.list
Queries: 13
Memory: 2.5419

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?

<perch:before>
        <div data-ix="popup" class="shop-listing">
</perch:before>
    <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:content type="image" id="image1" />" class="blog-list-image"></div>
              <perch:shop id="title" type="text" />
            </a>

       <div class="listing-wrapper">
              <h3 class="listing">LIR - The Discovery Collection</h3>
            </div><a href="#" />/" class="button shop-button w-button">find out more</a>



<perch:after>
        </div>
</perch:after>

also, on my /shop/index.php page when I call the listings is the below sufficient to point to the above template?

<div class="w-col w-col-4">
          <?php perch_shop_products([
                'template' => 'list.html',
                'count' => 10,
          ]); ?>
        </div>

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;

Debug Message - Perch Runway 3.1.2
[1] SELECT u.*, r.* FROM perch3_users u, perch3_user_roles r WHERE u.roleID=r.roleID AND u.userEnabled=1 AND u.userID=1 AND u.userHash='6fc0bb74478a37cc879ec7fd990ee4e1' LIMIT 1
UPDATE perch3_users SET userHash='9b87caeb197b7d8a961b359cfaca3f70' WHERE userID='1'
[46] SELECT settingID, settingValue, userID FROM perch3_settings WHERE userID=1 OR userID=0 ORDER BY userID ASC
[12] SELECT itemValue FROM perch3_menu_items WHERE itemType='app'
[1] SELECT SQL_CALC_FOUND_ROWS DISTINCT * FROM perch3_shop_products WHERE parentID IS NULL AND productDeleted IS NULL ORDER BY title ASC LIMIT 0, 24
[1] SELECT FOUND_ROWS() AS `count`
[1] SELECT mi.*, p.privKey FROM perch3_menu_items mi LEFT JOIN perch3_user_privileges p ON mi.privID=p.privID WHERE mi.itemActive=1 AND mi.parentID=0 ORDER BY itemOrder ASC LIMIT 0, 1
[7] SELECT mi.*, p.privKey FROM perch3_menu_items mi LEFT JOIN perch3_user_privileges p ON mi.privID=p.privID WHERE mi.itemActive=1 AND mi.parentID=1 ORDER BY mi.itemOrder ASC
[1] SELECT itemTitle FROM perch3_menu_items WHERE itemType='app' AND itemValue='perch_shop_products' LIMIT 1
[1] SELECT mi.*, p.privKey FROM perch3_menu_items mi LEFT JOIN perch3_user_privileges p ON mi.privID=p.privID WHERE mi.itemActive=1 AND mi.parentID=0 ORDER BY itemOrder ASC LIMIT 1, 10
[2] SELECT mi.*, p.privKey FROM perch3_menu_items mi LEFT JOIN perch3_user_privileges p ON mi.privID=p.privID WHERE mi.itemActive=1 AND mi.parentID=2 ORDER BY mi.itemOrder ASC
File: /addons/apps/perch_shop_products/modes/products.list.post.php
Looking up missing property price
[1] SELECT * FROM perch3_shop_currencies WHERE currencyID=44 LIMIT 1
Mode: products.list
Queries: 13
Memory: 2.5419

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?

Hussein Al Hammad

Hussein Al Hammad 105 points
Registered Developer

Hello Cormac,

also, on my /shop/index.php page when I call the listings is the below sufficient to point to the above template?

If your template is in perch/templates/shop/list.html, your code is pointing to the file correctly. If it's inside a sub-folder perch/templates/shop/products/list.html, you need to include the sub-folder in the path:

perch_shop_products([
'template' => 'products/list.html',
]);

Jonathan Elliman said:

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?

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.

 <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>

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.

Jonathan Elliman said:

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?