App reviews, troubleshooting, and recommendations
hi
this is my store url : https://tortoise.net.in
where in backpack i want to show only that product which first inventory is not equal to 0
but still product is visible on listing page and when click to go product page other variant is selected which have inventory.
Hello @tortoise
To show only the products in your Backpack store which have inventory greater than zero, you can use a filter on the "Product" model in your backpack's product controller.
Here's an example code snippet that you can add to your product controller:
public function index()
{
$this->crud->addClause('where', 'inventory', '>', 0);
return parent::index();
}
This code will filter out all products with an inventory of zero or less, and only display products with an inventory greater than zero.
However, keep in mind that this will only affect the products displayed on the listing page. If a customer clicks on a product that has a variant with zero inventory, they may still be able to see that variant on the product page.
To prevent this, you can modify your product page template to only display variants with inventory greater than zero. You can do this by adding an additional filter to the variant loop in your product view template:
@foreach($product->variants->where('inventory', '>', 0) as $variant)
// display variant information here
@endforeach
This code will only display variants with inventory greater than zero on the product page.
I hope this helps!
Hi @tortoise
You have to modify the card-product.liquid to achieve this and can be done using custom code in your theme.
Let me know if you still want to implement this.
Discover how to increase customer engagement on your store with articles from Shopify A...
By Jacqui Apr 23, 2025Hey Community 👋 Did you know that March 15th is National Everything You Think Is W...
By JasonH Apr 1, 2025Discover how to increase the efficiency of commerce operations with Shopify Academy's l...
By Jacqui Mar 26, 2025