View Single Post
  #6  
Old 06-04-2015, 11:38 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: Math IF/ELSE in version 5

Hello Richard,

Just combine the code provided by Tony with mine

PHP Code:
namespace XLite\Module\[YOUR_DEV_ID]\[YOUR_MODULE_ID]\View\Product\Details\Customer;

abstract class 
Stock  extends \XLite\View\Product\Details\Customer\Stock implements \XLite\Base\IDecorator
{
  protected function 
isItemsAvailableVisible()
  {
    return (
$this->getProduct()->getInventory()->getAvailableAmount() > 10);
  }

  protected function 
getDefaultTemplate()
  {
    return 
'modules/[YOUR_DEV_ID]/[YOUR_MODULE_ID]/product/details/stock/body.tpl';
  }



This way you keep the widget visible (isVisible() is not modified), but use a different template file that hides the portion of the message when isItemsAvailableVisible() method returns FALSE.

Don't forget to add the modified template to your module.
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote