Forum

Thread tagged as: Question, Addons, Add-on-development

Product page in new Shop App

I've been able to create a nice product listing by filtering perch_shop_products(); on SKU, so that I can have certain products appearing in various sections of my main shop page.

I'm ready to move on to the next step of creating a product page that displays the detail of each product, variants, add-to-cart button etc.

I'm hitting a mental block when it comes to linking up the product listing with the actual product page.

in list.html we have:

<a href="/shop/products/<perch:shop id="slug" type="slug" />/">
        <perch:shop id="title" type="text" />
    </a>

So with a click I'm taken to localhost/shop/products/my-slug which does not exist...not surprised, but I feel like I'm missing something very obvious.

I tried a workaround just to get something on the products.php page I created. I changed the link to:

<a href="products.php?slug=<perch:shop id="slug" type="slug" />/"> </a>

If this is the preferred way to go about this (which I doubt), how would I get the products to display based on their slugs?

I've tried a few functions with no success:

perch_shop_product(perch_get('slug'));

perch_shop_product(perch_get('s'));

perch_shop_product('');

php perch_shop_product([ 

    'filter' => 'slug',
    'match' => 'eq',
    'value' => perch_get('slug'),
]);

 perch_content_custom(array(
        "page"     => "/products.php",
        "template" => "product.html",
        "filter"   => "slug",
        "match"    => "eq",
        "value"    => perch_get('item'),
    ));

Thank you so much, I really appreciate the help

Olympia Kyriakides

Olympia Kyriakides 1 points

  • 5 years ago

Olympia,

I am not sure but looking at the code you posted should

php perch_shop_product([

Contain the "php" part?

This may have nothing to do with the problem though.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Are you on Perch or Perch Runway?

I'm on Perch.

Sorry, left out the php parts here...they're there in real life!

Drew McLellan

Drew McLellan 2638 points
Perch Support

So you'll need to add a rewrite rule for shop/products/product-slug to point to your page for showing product details.

So I've come full circle...

I'm on Runway, routed all out, etc. but still can't get a product page to display properly.

My main shop page has links to various products via /shop/[cat]/[subcat]/[slug] When I select one of those products I want to get to the products.php page for that particular slug.

I'm not returning anything from products.php, having tried lots of functions like

<?php perch_shop_product(perch_get('s')); ?>

The page is there. When I key in a particular slug, it returns each variation of that product (using the product.html template).

I knew better than to close this thread! Any direction is much appreciated.

Olympia Kyriakides said:

So I've come full circle...

I'm on Runway, routed all out, etc. but still can't get a product page to display properly.

My main shop page has links to various products via /shop/[cat]/[subcat]/[slug] When I select one of those products I want to get to the products.php page for that particular slug.

I'm not returning anything from products.php, having tried lots of functions like

<?php perch_shop_product(perch_get('s')); ?>

The page is there. When I key in a particular slug, it returns each variation of that product (using the product.html template).

I knew better than to close this thread! Any direction is much appreciated.

perch_get('cat') = [cat] perch_get('subcat') = [subcat] perch_get('slug') = [slug]

route = shop/[cat]/[subcat]/[slug] think of it as shop/[1]/[2]/[3]

without assigning names you need to perch_get() like this...

perch_get([1]); // cat
perch_get([2]); // subcat
perch_get([3]); // slug

otherwise with names... shop/[*:cat]/[*:subcat]/[slug:slug]

Sounds like the key Robert, unfortunately I'm still not returning anything with these..

<?php perch_shop_product(perch_get([3])); ?>

<?php perch_shop_product(perch_get([slug])); ?>

Time Δ Debug Message 0.0874 0 SELECT p.pagePath, pr.routePattern, pr.routeRegExp, p.pageTemplate FROM perch2_pages p LEFT JOIN perch2_page_routes pr ON p.pageID=pr.pageID ORDER BY pr.routeOrder ASC, p.pagePath ASC 0.0914 0.004 Matched route: shop/[slug:cat]/[slug:subcat]/[slug:slug] 0.0916 0.0002 Using master page: /templates/pages/shop/products.php 0.0917 0 Page arguments: Array ( [0] => /shop/wallets/card-wallets/folded-card-case [cat] => wallets [1] => wallets [subcat] => card-wallets [2] => card-wallets [slug] => folded-card-case [3] => folded-card-case ) 0.0943 0.0026 SELECT u.*, r.* FROM perch2_users u, perch2_user_roles r WHERE u.roleID=r.roleID AND u.userEnabled=1 AND u.userID=1 AND u.userHash='dc4236126c4fb0c8167d62022a4707ac' LIMIT 1 0.0949 0.0007 UPDATE perch2_users SET userHash='ce1175e5afeb6327487588a44cf6a591' WHERE userID='1' 0.0952 0.0003 SELECT p.privKey FROM perch2_user_privileges p 0.1054 0.0102 SELECT * FROM perch2_pages WHERE pagePath='/shop/products' LIMIT 1 0.1184 0.013 SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=0 0.1336 0.0151 Using template: /templates/mailchimp/subscribe.offcanvas.html 0.2864 0.1529 SELECT DISTINCT idx.itemID FROM perch2_shop_index idx JOIN perch2_shop_products main ON idx.itemID=main.productID AND idx.itemKey='productID' AND (idx.indexKey='status' AND idx.indexValue='1') GROUP BY idx.itemID HAVING COUNT(idx.itemID)=1 0.2875 0.001 SELECT DISTINCT idx.itemID FROM perch2_shop_index idx JOIN perch2_shop_products main ON idx.itemID=main.productID AND idx.itemKey='productID' AND (idx.indexKey='productDeleted' AND idx.indexValue='') GROUP BY idx.itemID HAVING COUNT(idx.itemID)=1 0.2882 0.0007 SELECT tbl.* FROM ( SELECT idx.itemID, main.*, idx2.indexValue as sortval FROM perch2_shop_index idx JOIN perch2_shop_products main ON idx.itemID=main.productID AND idx.itemKey='productID' JOIN perch2_shop_index idx2 ON idx.itemID=idx2.itemID AND idx.itemKey='productID' AND idx2.indexKey='_id' AND idx.itemID IN ('1', '13', '14', '15', '16', '17', '18', '19', '30', '36') AND idx.itemID IN ('1', '13', '14', '15', '16', '17', '18', '19', '30', '36') WHERE 1=1 AND ((idx.indexKey='slug' AND idx.indexValue='')) AND idx.itemID=idx2.itemID AND idx.itemKey=idx2.itemKey GROUP BY idx.itemID ) as tbl GROUP BY itemID ORDER BY sortval ASC 0.2916 0.0034 Using template: /templates/shop/products/product.html 0.2958 0.0042 Using template: /templates/mailchimp/subscribe.html 0.3002 0.0044 Time: 0.3001 0.3002 0 Memory: 5.4056 0.3002 0 Array ( [type] => 2 [message] => Illegal offset type in isset or empty [file] => /Applications/MAMP/htdocs/om-nyc/perch/core/lib/PerchSystem.class.php [line] => 137 )
Matched route: shop/[slug:cat]/[slug:subcat]/[slug:slug]

0.0917  0   Page arguments:
Array
(
    [0] => /shop/wallets/card-wallets/folded-card-case
    [cat] => wallets
    [1] => wallets
    [subcat] => card-wallets
    [2] => card-wallets
    [slug] => folded-card-case
    [3] => folded-card-case
)

I've not been able to get Perch Shop Beta, I have been told I was on the Beta list, But I have never been delivered the files.

For this reason I have to do a lot of guessing.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Which build are you using? Gamma 6?

eek, not even close. And I'm sorry I see now that I should be discussing these topics in slack. I'm in the general slack but I don't think I'm in the private shop channel. Would you add me please? very sorry Should I re-request slack?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, send me a message there (drewm) and then I'll have your username to add you.

Drew, Any word on when I might get Gamma Access?