Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

How to get a global attribute and handle its value

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 06-06-2016, 11:55 AM
 
FactorInteractivo FactorInteractivo is offline
 

Advanced Member
  
Join Date: Oct 2007
Posts: 44
 

Default How to get a global attribute and handle its value

We are working on a module in X-Cart 5 which according to the value of a global attribute must show an Icon next to a product in the "On sale" products list.

In the route classes/xlite/module/developerID/moduleID/view/price.php we have the following code

Code:
/** * Return sale participation flag * * @return boolean */ protected function participateSale() { return $this->getProduct()->getParticipateSale(); }

and my product TPL is like the following:

Code:
{* vim: set ts=2 sw=2 sts=2 et: *} {** * Product price value * * @author Qualiteam software Ltd <info@x-cart.com> * @copyright Copyright (c) 2011-2015 Qualiteam software Ltd <info@x-cart.com>. All rights reserved * @license http://www.x-cart.com/license-agreement.html X-Cart 5 License Agreement * @link http://www.x-cart.com/ * * @ListChild (list="product.plain_price", weight="10") *} <li IF="participateSale()" class="sale-banner"> <div class="sale-banner-block"> <div class="text">{t(#sale#)}</div> <div class="percent">{t(#percent X off#,_ARRAY_(#percent#^getSalePercent())):h}</div> </div> </li>

At the same time, we have a Global Attribute called "sale" which contains a value of 0 or 1.

I need the function "participateSale" to return "True" if the "sale" attribute value for a product is 1.

My problem is that I don´t know how to access to that attribute from the current folder I´m working.

Any ideas ? Thanks in advance !!

X-Cart 5.2.15
__________________
X-Carting since 2006
Reply With Quote
  #2  
Old 06-07-2016, 11:38 AM
 
FactorInteractivo FactorInteractivo is offline
 

Advanced Member
  
Join Date: Oct 2007
Posts: 44
 

Default Re: How to get a global attribute and handle its value

I have advanced with this problem, now i created a new file in "XLite\Module\DeveloperID\ModuleID\View\Product\De tails\Customer" called "Atribute.php"

have the following code:

Code:
<?php // vim: set ts=4 sw=4 sts=4 et: namespace XLite\Module\FactorInteractivo\FooterCasaJorge\View\Product\Details\Customer; /** * Product attributes */ abstract class Attributes extends \XLite\View\Product\Details\Customer\Attributes implements \XLite\Base\IDecorator { public static function getAttrBullet() { $attributes = parent::getAttrList(); $return= false; foreach($attributes as $attr){ if(strtoupper($attr['name']) == "SALE" && $attr['value'] == '1'){ $return= true; } } return $retorno; } }

In my file Price.php (XLite\Module\FactorInteractivo\FooterCasaJorge\Vi ew) I use this function and call it:

Code:
protected function participateSale() { $atr = Details\Customer\Attributes::getAttrBullet(); return $atr; }

But this return an error related with the use of $this when is not a object.

¿They understand my objetive? I need a urgent answer
__________________
X-Carting since 2006
Reply With Quote
  #3  
Old 06-13-2016, 07:51 AM
 
FactorInteractivo FactorInteractivo is offline
 

Advanced Member
  
Join Date: Oct 2007
Posts: 44
 

Default Re: How to get a global attribute and handle its value

Anybody any clue on this subject, or is this a "Top secret" subject
__________________
X-Carting since 2006
Reply With Quote
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 02:46 AM.

   

 
X-Cart forums © 2001-2020