News:

Looking for documentation? Take a look on our wiki

Main Menu

Out of stock, not showing products, show message

Started by Kuubs, November 12, 2020, 09:46:23 AM

Previous topic - Next topic

Kuubs

Hello,

I have a problem I cannot seem to fix. I have a couple of products which are out of stock, I configured Virtuemart to not show these products in the configuration tab. But now the page is just empty. I'd like to show a message that there are currently no products in stock.

But the products array is still populated, so I cannot use the normal template style in showing a message. Does anyone know how to tackle this problem?

Jörgen

This is very likely a template issue. Test with Protostar.
Jörgen
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

Kuubs

Quote from: Jörgen on November 12, 2020, 09:51:34 AM
This is very likely a template issue. Test with Protostar.
Jörgen

It's not, i tested it with protostar. In the backend you can set the products to not be shown when the stock is empty.

pinochico

QuoteIn the backend you can set the products to not be shown when the stock is empty.

Where?
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds for FB, GMC,.. from products, categories, orders, users, articles, acymailing subscribers and database table
Virtuemart Email Manager - customs email templates
Import products for Virtuemart - from CSV and XML
Rich Snippets - Google Structured Data
VirtueMart Products Extended - Slider with products, show Others bought, Products by CF ID and others filtering products

Jörgen

Then I would look and see how it is handled in the view file.

Jörgen
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

Kuubs

Quote from: Jörgen on November 12, 2020, 16:03:52 PM
Then I would look and see how it is handled in the view file.

Jörgen

Yes I have selected the second option. But the $this->products array is still full of the products. I think it checks at a later stage whether or not to show the product?

Is there some sort of clean and effective option to display the message without looping through all the products to check their stock?

GJC Web Design

where is $this->products populated even though all are out of stock?  at the template/view?
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Kuubs

Quote from: GJC Web Design on November 13, 2020, 10:28:21 AM
where is $this->products populated even though all are out of stock?  at the template/view?

Nope, it only checks if the products array is empty, and if not it displays the products.

This seems Virtuemart behaviour

pinochico

#8
Nope, it only checks if the products array is empty, and if not it displays the products.


Your products array is not empty, you have assigned 2 keys without value.

Array ( [featured] => Array ( ) [products] => Array ( ) )

Then you must use right check in PHP for $this->products:
https://www.google.com/search?client=safari&rls=en&q=php+array+empty&ie=UTF-8&oe=UTF-8


https://joomla3.easy.minion.cz/eshop-virtuemart/headpiece -> NO PRODUCTS IN STOCK FOR HUUBS


If you need show message between different category without products and category without products in stock, you must hack model product and add error message in model where is check for stockhandle
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds for FB, GMC,.. from products, categories, orders, users, articles, acymailing subscribers and database table
Virtuemart Email Manager - customs email templates
Import products for Virtuemart - from CSV and XML
Rich Snippets - Google Structured Data
VirtueMart Products Extended - Slider with products, show Others bought, Products by CF ID and others filtering products

Kuubs

#9
Quote from: pinochico on November 14, 2020, 10:28:53 AM
Nope, it only checks if the products array is empty, and if not it displays the products.


Your products array is not empty, you have assigned 2 keys without value.

Array ( [featured] => Array ( ) [products] => Array ( ) )

Then you must use right check in PHP for $this->products:
https://www.google.com/search?client=safari&rls=en&q=php+array+empty&ie=UTF-8&oe=UTF-8


https://joomla3.easy.minion.cz/eshop-virtuemart/headpiece -> NO PRODUCTS IN STOCK FOR HUUBS


If you need show message between different category without products and category without products in stock, you must hack model product and add error message in model where is check for stockhandle

Ooh, i see i use the third option (can't order show the inform me button)

So that is intended behaviour. I check at the products sublayout if the product is in stock, and if not it skips the product. I am gonna add a variable that if nothing shows there it will display the message. Sorry for the confusion guys.

Code:



$productShow = false;
....

if($product->product_in_stock - $product->product_ordered < 1){
continue;
}
$productShow=true;
.....

if(!$productShow){
  echo 'No Products avaialble';
  }



pinochico

#10
Now you know - if I ask you, then answer me.
Or send all information on start - You will not waste my time and yours

The only text question is not enough.

But great Congratulations


Hmmm, but for child products is other option for ordered... I think
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds for FB, GMC,.. from products, categories, orders, users, articles, acymailing subscribers and database table
Virtuemart Email Manager - customs email templates
Import products for Virtuemart - from CSV and XML
Rich Snippets - Google Structured Data
VirtueMart Products Extended - Slider with products, show Others bought, Products by CF ID and others filtering products