A product catalogue: sorting, cards and prices
The WooCommerce shop page in your design: a heading and a couple of lines at the top, then sorting and product cards with prices. New products appear in the catalogue by themselves.
What you get
<body wp-fields-group="Shop">
<header class="shop-hero">
<h1 wp="post-title">Beans</h1>
<p class="shop-hero__lead" fld-area="Shop lead">Roasted on Mondays, shipped on Tuesdays.</p>
</header>
<form class="sort" wp="sort">
<select class="sort__select" wp="orderby">
<option value="menu_order">Default</option>
<option value="price">Price: low to high</option>
</select>
</form>
<div class="beans" wp="products">
<div class="bean-card">
<a href="#" wp="post-link"><img src="images/bean.jpg" alt="" wp="post-image"></a>
<h3><a href="#" wp="post-title-link">Ethiopia Yirgacheffe</a></h3>
<div class="bean-card__prices">
<span wp="product-price">$14.00</span>
<span wp="product-price-sale">$12.00</span>
<span class="is--old" wp="product-price-regular">$14.00</span>
</div>
</div>
</div>
<div class="beans__empty" wp="no-results">No beans match.</div>
<div class="pagination" wp-paginate="mid_size=1"></div>
</body>- Title: Beans
- WooCommerce → Settings → Products → Shop page: Beans
- Ethiopia Yirgacheffe — $14.00
- Colombia Huila — $13.00
- Brazil Cerrado — $11.00
- House blend “Warm” — $12.00
Roasted on Mondays, shipped on Tuesdays.
Price: low to highA customer picked “Price: low to high”, and the cards were sorted again.
Step by step
Heading and intro
wp="post-title" and fld-area above the cards read the shop page, the one chosen in WooCommerce → Settings → Products. The client edits it like any page.
<h1 wp="post-title">Beans</h1> <p class="shop-hero__lead" fld-area="Shop lead">Roasted on Mondays, shipped on Tuesdays.</p>
Sorting
<form wp="sort">with a<select wp="orderby">inside. The option values are WooCommerce sort orders:menu_order,price,price-desc,date,popularity,rating.<form class="sort" wp="sort"> <select class="sort__select" wp="orderby"> <option value="menu_order">Default</option> <option value="price">Price: low to high</option> </select> </form>
Product cards
wp="products" on the grid; the first card is the sample. Inside are the link, image, name and three price blocks: the theme hides the ones that do not apply. Next to it,
wp="no-results".<div class="beans" wp="products"> <div class="bean-card"> <a href="#" wp="post-link"><img src="images/bean.jpg" alt="" wp="post-image"></a> <h3><a href="#" wp="post-title-link">Ethiopia Yirgacheffe</a></h3> <div class="bean-card__prices"> <span wp="product-price">$14.00</span> <span wp="product-price-sale">$12.00</span> <span class="is--old" wp="product-price-regular">$14.00</span> </div> </div> </div> <div class="beans__empty" wp="no-results">No beans match.</div>
Page numbers
wp-paginate on an empty block after the grid.
<div class="pagination" wp-paginate="mid_size=1"></div>
What matters
- Needs WooCommerce.
- Without a separate
taxonomy-product-cat.html, product categories open with this same template, andwp="products"shows the products of the open category. - Products on another page, such as the home page, come from
wp-product-query.
Common mistakes
The build log is the “Logs” tab of your project on themeforge.pro; the free markup check shows the same notes.
<div class="beans" wp-query="'post_type'=>'product','posts_per_page'=>12">
<div class="bean-card">
<h3 wp="post-title">Ethiopia Yirgacheffe</h3>
</div>
</div>wp-query instead of wp="products" shows a selection of its own: sorting and product categories do not affect it. The log stays silent.
<div class="beans" wp="products">
<div class="bean-card">
<h3 wp="post-title">Ethiopia Yirgacheffe</h3>
</div>
</div>wp="products" shows the products WooCommerce picked for this page.
<select class="sort__select" wp="orderby">
<option value="price">Price: low to high</option>
</select>A sort list without its form: the build notes the attribute in the log, and it does nothing.
<form class="sort" wp="sort">
<select class="sort__select" wp="orderby">
<option value="price">Price: low to high</option>
</select>
</form>The list goes inside <form wp="sort">.