bigcommerce / bigcommerce-for-wordpress

A headless commerce integration for WordPress, powered by BigCommerce
https://www.bigcommerce.com/wordpress/
GNU General Public License v2.0
109 stars 49 forks source link

Products Shortcode does not allow displaying a single result in the grid template #424

Open corgalore opened 1 year ago

corgalore commented 1 year ago

Expected behavior

Use the Products Shortcode to display a grid of products in a category, rendered using card template, even if there's only one result.

Actual behavior

If only one product is returned in query of Products Shortcode, the result is rendered using the Product_Shortcode_Single template, instead of Product_Shortcode_Grid.

Steps to reproduce behavior

  1. Create a BigCommerce category and add only one product to it. Sync into Wordpress.
  2. Use this shortcode on a page with your category slug: [bigcommerce_product category=my-category order=DESC orderby=date paged=1 per_page=9]

Line causing issue

https://github.com/bigcommerce/bigcommerce-for-wordpress/blob/master/src/BigCommerce/Shortcodes/Products.php#L71