Hi we're trying to check the value of multiple attributes before showing some text... I have made sure that each attribute is set with the option "Visible on Product View Page on Front-end" set to YES.
I also made sure my test product has all the following attributes with the following values set
- damage_front = FRONT: No damage
- damage_right = RIGHT SIDE: No damage
- damage_left = LEFT SIDE: No damage
- damage_back = BACK: No damage
- damage_handles = HANDLES: No damage
I then added the below code to my product view page...
<?php if ($_product->getAttributeText('damage_front') == "FRONT: No damage" && $_product->getAttributeText('damage_back') == "Back: No damage" && $_product->getAttributeText('damage_right') == "RIGHT SIDE: No damage" && $_product->getAttributeText('damage_left') == "LEFT SIDE: No damage" && $_product->getAttributeText('damage_top') == "TOP: No damage" && $_product->getAttributeText('damage_handles') == "HANDLES: No damage"): ?>
{
echo "<div style ='color:#ffffff'><b>This Product is Box Damaged Only</b></div>";
}
<?php endif; ?>
Unfortunatly this does not show any text output, so just to test further i reduced the statement to just check one attribute...
<?php if ($_product->getAttributeText('damage_front') == "FRONT: No damage") : ?>
{
<?php echo "<div style ='color:#ffffff'><b>This Product is Box Damaged Only</b></div>"; ?>
}
<?php endif; ?>
This still doesnt show the required Box Damaged only text.
Finally just to test, i removed the whole IF statment and added
<?php echo "<div style ='color:#ffffff'><b>This Product is Box Damaged Only</b></div>"; ?>
As expected this does show the text in the correct position on the product view page, can anyone please show me where i'm going wrong to check all the attribute values and show text if they match?
edit: since checking another similar post i have also tried the following...
<?php if ($_product->getData('damage_front') == "FRONT: No damage" && $_product->getData('damage_back') == "Back: No damage" && $_product->getData('damage_right') == "RIGHT SIDE: No damage" && $_product->getData('damage_left') == "LEFT SIDE: No damage" && $_product->getData('damage_top') == "TOP: No damage" && $_product->getData('damage_handles') == "HANDLES: No damage"): ?>
The suggested answers here do not rectify this issue.
EDIT: Ok I've managed to fix my own problem and here's how i did it...
<?php
if ($_product->getData('damage_front') == "FRONT: No damage" && ($_product->getData('damage_back') == "BACK: No damage" && ($_product->getData('damage_right') == "RIGHT SIDE: No damage" && ($_product->getData('damage_left') == "LEFT SIDE: No damage" && ($_product->getData('damage_top') == "TOP: No damage" && ($_product->getData('damage_handles') == "HANDLES: No damage")))))):
?>
<h3>Box Damaged Only.</h3>
<p>
This item is in perfect condition and only has box damage.
</p>
</div>
</div>
<?php endif;?>