Question

Je voudrais montrer aux visiteurs sur mon site une économie instantanée en soustrayant 2 attributs costnopromo et coût .

Si les attributs sont les mêmes, alors je ne veux pas afficher le texte, « Enregistrer »

Je sais que je peux le faire avec une instruction if, mais je ne sais pas comment soustraire les 2 attributs.

Comment peut réaliser les objectifs suivants:

costnopromo - coût = savings_value

NOTE: J'ai recherché et est tombé sur la méthode pour montrer une économie sur la base PDSF et prix, mais cela ne répond pas à mes exigences que le costnopromo est une valeur personnalisée

.
Était-ce utile?

La solution

The product collection output get from,

$_helper = $this->helper('catalog/output');
$_product = $this->getProduct();

to get the costnopromo and cost values by,

echo $_product->getCostnopromo();
echo $_product->getCost();

To substract,

$savings_value = intval($_product->getCostnopromo()) - intval($_product->getCost());

by checking the condition,

 if($savings_value >= 0){
    echo 'save :'.$savings_value;
 }

this may help you

Autres conseils

Assuming $_product is a valid product object...

$savingValue = $_product->getCostnopromo() - $_product->getCost();

if ($savingValue >= 0) {
    echo "Save: " . $savingValue;
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à magento.stackexchange
scroll top