Author Topic: Out of stock, not showing products, show message  (Read 493 times)

Huubs

  • Jr. Member
  • **
  • Posts: 280
Out of stock, not showing products, show message
« on: November 12, 2020, 09:46:23 am »
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

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3136
    • Kreativ Fotografi
  • VirtueMart Version: 3.4.x
Re: Out of stock, not showing products, show message
« Reply #1 on: November 12, 2020, 09:51:34 am »
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.

Huubs

  • Jr. Member
  • **
  • Posts: 280
Re: Out of stock, not showing products, show message
« Reply #2 on: November 12, 2020, 15:29:04 pm »
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

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 812
    • MiniJoomla
  • Skype Name: support-easysoftware
  • VirtueMart Version: 3
Re: Out of stock, not showing products, show message
« Reply #3 on: November 12, 2020, 15:37:04 pm »
Quote
In 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 from products, orders and database table
Virtuemart Email Manager - customs email templates

Jörgen

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3136
    • Kreativ Fotografi
  • VirtueMart Version: 3.4.x
Re: Out of stock, not showing products, show message
« Reply #4 on: November 12, 2020, 16:03:52 pm »
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.

Huubs

  • Jr. Member
  • **
  • Posts: 280
Re: Out of stock, not showing products, show message
« Reply #5 on: November 13, 2020, 09:03:10 am »
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

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 9901
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.6.8
Re: Out of stock, not showing products, show message
« Reply #6 on: November 13, 2020, 10:28:21 am »
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 http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 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
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Huubs

  • Jr. Member
  • **
  • Posts: 280
Re: Out of stock, not showing products, show message
« Reply #7 on: November 14, 2020, 09:14:50 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

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 812
    • MiniJoomla
  • Skype Name: support-easysoftware
  • VirtueMart Version: 3
Re: Out of stock, not showing products, show message
« Reply #8 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
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds from products, orders and database table
Virtuemart Email Manager - customs email templates

Huubs

  • Jr. Member
  • **
  • Posts: 280
Re: Out of stock, not showing products, show message
« Reply #9 on: November 14, 2020, 13:33:24 pm »
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:

Code: [Select]

$productShow = false;
....

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

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



pinochico

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 812
    • MiniJoomla
  • Skype Name: support-easysoftware
  • VirtueMart Version: 3
Re: Out of stock, not showing products, show message
« Reply #10 on: November 14, 2020, 18:28:11 pm »
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 from products, orders and database table
Virtuemart Email Manager - customs email templates