php - Magento - Check if item has specific custom option or not in shopping cart

473

In my shopping cart page i need to be able to check if any added products have a particular custom option set on them - in this case a custom option called 'age_guide'.

If so i need to add a small disclaimer text line. How would i go about doing so?

720

Answer

Solution:

If your custom option set on a product is age_guide, then in your

template/checkout/cart/item/default.phtml

around line 46

<?php echo $this->htmlEscape($_option['label']) ?>

Use below code:

<?php if($_option['label'] =='age_guide'): // or whatever your custom option label ?>
     <div>
       <span><?php echo $this->__('Your Disclaimer Text Goes Here');?></span>
     </div>
<?php endif; ?>

People are also looking for solutions to the problem: php - Product filtering like shopping sites

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.