0

I add three text field attribute in my product view.phtml, but i want to hide one text above only if none of that attributes have value.

This is my work but, "PURCHASE FROM THESE RETAILERS" is still in page, if i remove all attributes value in admin from (amazon_com_link, amazon_com_link, amazon_ca_link).

<?php if(in_array($_product->getAmazon_com_link) && ($_product->getAmazon_co_uk_link) && ($_product->getAmazon_ca_link) ) ?>

            <a style="font-size:20px;letter-spacing: normal;font-style: italic;font-weight: bolder;color: #fda221;"> PURCHASE FROM THESE RETAILERS 
            </a>

            <div class="buy-from">
                <?php if($_product->getAmazon_com_link()): ?>
                    <a href="<?php echo ($_product->getAmazon_com_link()) ?>"><img src="<?php $this->getSkinUrl(); ?>/amazonus-logo.jpg" alt="Buy from Amazon.com"></a>
                <?php endif ?>
                <?php if($_product->getAmazon_com_link()): ?>
                    <a href="<?php echo ($_product->getAmazon_co_uk_link()) ?>">
                        <img src="<?php $this->getSkinUrl(); ?>/amazonuk-logo.jpg" alt="Buy from Amazon.co.uk">
                    </a>
                <?php endif ?>
                <?php if($_product->getAmazon_ca_link()): ?>
                    <a href="<?php echo ($_product->getAmazon_ca_link()) ?>">
                        <img src="<?php $this->getSkinUrl(); ?>/amazonca-logo.jpg" alt="Buy from Amazon.ca">
                    </a>

            </div>

        <?php endif ?>

I want to show off text inside <a></a> if none of that three attributes have values.

1 Answer 1

0

Replace your code with mine:

<?php if($_product->getAmazonComLink() && $_product->getAmazonCoUkLink() && $_product->getAmazonCaLink()) ?>

            <a style="font-size:20px;letter-spacing: normal;font-style: italic;font-weight: bolder;color: #fda221;"> PURCHASE FROM THESE RETAILERS 
            </a>

            <div class="buy-from">
                <?php if($_product->getAmazonComLink()): ?>
                    <a href="<?php echo $_product->getAmazonComLink(); ?>"><img src="<?php $this->getSkinUrl(); ?>/amazonus-logo.jpg" alt="Buy from Amazon.com"></a>
                <?php endif ?>
                <?php if($_product->getAmazonComLink()): ?>
                    <a href="<?php echo $_product->getAmazonComLink(); ?>">
                        <img src="<?php $this->getSkinUrl(); ?>/amazonuk-logo.jpg" alt="Buy from Amazon.co.uk">
                    </a>
                <?php endif ?>
                <?php if($_product->getAmazonCaLink()): ?>
                    <a href="<?php echo $_product->getAmazonCaLink(); ?>">
                        <img src="<?php $this->getSkinUrl(); ?>/amazonca-logo.jpg" alt="Buy from Amazon.ca">
                    </a>

            </div>

        <?php endif ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.