Help needed with list/detail setup for Perch Shop.

  • I'm attempting to build my first shop in Runway (also using for the first time). I can get products listing but can't seem to hook up the product detail. Can anyone point me in the right direction, please.

  • drewm

    Approved the thread.
  • Hi


    Can you share your product page template(s) and a rough idea of how you are planning to structure your pages? i.e. Are the urls going to be segmented by category, brand or will the products just be simply listed on a single list/detail page?

  • Hi,
    The planned structure is 3 main product categories…

    • Fabric
      • Design
      • Design…
    • Wallpaper
      • Design
      • Design…
    • Furnishings
      • Sub Category
        • Design
        • Design…
      • Sub Category
        • Design
        • Design…

    I've created a page called Fabric (list) with a sub page called design (detail) the later has a route that makes the URL fabric/slug.
    To populate the list I'm using

    PHP
    1. <?php     perch_shop_products([     'template' => 'products/fabric_list.html' ]); ?>

    and to populate the detail page

    PHP
    1. <?php perch_shop_product($productSlug, [ 'template' => 'products/fabric_design.html', ]);?>

    The list page is populating how I'd expect showing a thumbnail and design name (with links). However when you click through to the detail page the details of both products are displayed not just the one you clicked. How do I get it to show only the detail of the product I clicked?

  • I guessed that, but its slightly frustrating went someone had asked a question about my initial query and then my respsonse is disabled and the offer of help lost. Also I'm not a new user. I was a user of the old forum and have been using perch since its first release. All that said and done, I totally understand the desire to eliminate spam.

    Any thoughts on why I seeing details of all the products (on the product detail page) when I click through from one product (on the product list page?)

  • I've created 2 pages "Fabric" (List) and Design (Detail). Design is a sub page of Fabric.


    Fabric

    PHP
    1. <?php
    2. perch_shop_products([
    3. 'template' => 'products/fabric_list.html'
    4. ]);
    5. ?>


    Design

    PHP
    1. <?php
    2. perch_shop_product($productSlug, [
    3. 'template' => 'products/fabric_design.html',
    4. ]);
    5. ?>


    Design as a URL pattern… fabric/[slug:product]

    I've set up a test page with two products and when I click through from one of them I get the details of both, however the URL is correct for the item Clicked.

  • Ok, but you're using a variable $productSlug, and I can't see anywhere where you're assigning it a value.


    Perhaps you mean to use perch_get('product') instead? That would grab the slug from the URL based on your route settings.

  • Brilliant. That works a treat.
    One last question for now!
    The shop I'm building plans to sell fabric and wallpapers. So a single product would be a "Design" which the user could order in X sqm and might have say 6 variants (different colours) for £N. However the user could also opt to order samples of any of the colours - for Mp.

    Would it be best/possible to have one product (with variants) or would I have to create another product for the samples (with variants)? and is it possible to form an association between the two so that when clicking through from the list the user has the option to order X sqm of the design in a particular colour or samples of the desisgn in a particular colour.