0

In my store i have a group called "loyal customers" This group of customers gets a special price which i can set in the backend under product-> prices-> group prices. Is there a way of the products with these special group prices to display a lil image in the corner of the product image (like some sites do with products on sale) but the image should of display if the customer is logged in and is within the "loyal customer" group??

Thank you for your help if you can.

<?php
$_helper = $this->helper('catalog/output');
$_product = $this->getProduct();
$enable_upsell =  Mage::getStoreConfig('midmedssettings/labels/enable_upsell');
$replace_upsell =  Mage::getStoreConfig('midmedssettings/labels/replace_upsell');

$helper = $this->helper('midmedssettings/image');
list($defaultImgX, $defaultImgY) = $helper->getDefaultSize();
list($imgX, $imgY) = $helper->getMainSize();
if ( $imgX > 800 ) {
    $imgX = 800;
    $imgY = $helper->calculateHeight($imgX);
}

$product_img_box_width = $defaultImgX;
if ( $defaultImgX != $imgX ) {
    $product_img_box_width = $imgX;
}
//add image border
$product_img_box_width += 18;
?>
<script type="text/javascript">
    var optionsPrice = new Product.OptionsPrice(<?php echo $this->getJsonConfig() ?>);
</script>
<?php echo $this->getChildHtml('global_messages') ?>
<div id="messages_product_view"><?php echo $this->getMessagesBlock()->getGroupedHtml() ?></div>
<div class="product-view">

<div class="rcolumn"> 

<div class="additionaldata">
   <ul>
   <li class="freedelivery"><strong>FREE!!</strong> Delivery over £75 exc VAT<br><span style="color:#666666">more information on delivery</span></li>
    <?php   
                        $_direct_delivery_product = $this->htmlEscape($_product->getdirect_delivery_product());
                        if ($_direct_delivery_product == 1){
                        ?>
                       <li class="deliverytime">Direct Delivery Item - delivery may take longer than usual</li>
                            <?php
} else {
?>                           <li class="nextday">Next Day Delivery Available<br>Standard Delivery 1 - 5 working days</li>
                          <?php
}
?>
<li class="globe">International Delivery Available</li>
<li class="pricebeat">Seen this cheaper elsewhere? Fill out our simple <strong><A HREF="javascript:popUp('http://www.midmeds.com/tinc?key=VlYdESS9&formname=pricematch')">Pricematch Form</A></strong> and we will beat the price by 3%*</li>
<li class="bulk">Buying in larger quantities?
Phone for a quote - <br> 0845 00 34 212</li>
<li class="paymentoptions"> Payment and Security </li>
<div class="credit"> 30 days credit account </div>
<div class="nhs">We accept NHS purchase orders </div>
<div class="clear"></div>
<div class="paymentoptionsdcc">Credit Cards Accepted </div> 
</ul>
    </div>
</div> 
    <div class="product-essential">
    <form action="<?php echo $this->getSubmitUrl($_product) ?>" method="post" id="product_addtocart_form"<?php if($_product->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>
        <div class="no-display">
            <input type="hidden" name="product" value="<?php echo $_product->getId() ?>" />
            <input type="hidden" name="related_product" id="related-products-field" value="" />
        </div>

        <div class="product-img-box" style="width:<?php echo $product_img_box_width; ?>px">
            <?php echo $this->helper('midmedssettings')->getLabel($_product);  ?>
            <?php echo $this->getChildHtml('media') ?>
            <?php       
        $_isLoggedIn = $this->helper('customer')->isLoggedIn();
        if($_isLoggedIn == true){
        $_myGroupId = Mage::getSingleton('customer/session')->getCustomerGroupId();          
        if($_myGroupId == 4){
        echo '<img style="float: left; margin: 2px;" src="/media/catalog/category/LMC-img.gif">';
                }
            }
            ?>
        </div>
        <div class="product-shop"> 
            <div class="product-shop-info">

<?php
if($_product->isSaleable())
{
$quote = Mage::getModel('sales/quote');
$quote->getShippingAddress()->setCountryId('*');
$quote->addProduct($_product);
$quote->getShippingAddress()->collectTotals();
$quote->getShippingAddress()->setCollectShippingRates(true);
$quote->getShippingAddress()->collectShippingRates();
$rates = $quote->getShippingAddress()->getShippingRatesCollection();

foreach ($rates as $rate)
{
echo $rate->getPrice();
}
}
?>  
                <div class="product-name">
                    <h1><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></h1>
                </div>
                <?php if ($this->hasOptions()):?>

                <?php endif; ?>
                <?php echo $this->getReviewsSummaryHtml($_product, false, true)?>

                <?php echo $this->getChildHtml('alert_urls') ?>
                <?php if(!$_product->getAWDisableOutOfStock()): ?>      
   <?php echo $this->getChildHtml('product_type_data') ?>
<?php else: ?>
    <div class="aw-cat-perm-notify"><?php echo Mage::getStoreConfig('catalogpermissions/general/product_notice'); ?></div>
<?php endif; ?>

                <?php echo $this->getTierPriceHtml() ?>
                <?php echo $this->getChildHtml('extrahint') ?>
                <?php echo $this->getChildHtml('other');?>
         <?php if (!$this->hasOptions()):?>

                        <?php if($_product->isSaleable()): ?>
                                <!-- RELATED -->
    <?php echo $this->getChildHtml('content_related2') ?>
        <!-- RELATED -->
                            <?php echo $this->getChildHtml('addtocart') ?>
         <?php endif; ?>

                    <?php echo $this->getChildHtml('extra_buttons') ?>
                <?php endif; ?>

                <?php if ($_product->isSaleable() && $this->hasOptions()):?>
                    <?php echo $this->getChildChildHtml('container1', '', true, true) ?>
                <?php endif;?>
 <?php if ($_product->isSaleable() && $this->hasOptions()):?>
            <?php echo $this->getChildChildHtml('container2', '', true, true) ?>
        <?php endif;?>
                <div class="clear"></div>
                </div>
        <div class="clearer"></div></div>

    </form>
2
  • Did you get a chance try out the code I provided? – SR_Magento Jun 12 '14 at 10:38
  • just about to, will let you know how it goes – Adam Allen Jun 12 '14 at 13:39
1

You will need to implement this code on the product view and adjust as needed. Change the value #4 to the Group ID of your "loyal customers".

<?php       
        $_isLoggedIn = $this->helper('customer')->isLoggedIn();
        if($_isLoggedIn == true){
        $_myGroupId = Mage::getSingleton('customer/session')->getCustomerGroupId();          
        if($_myGroupId == 4){
        echo '<img style="float: left; margin: 2px;" src="/path-to-image/loyal.jpg' alt="'loay customner'">';

                }
            }
            ?>

I use this code to show me cost pricing of my products on the fly when browsing to do some spot checking.

7
  • no its not working... i think it is because of where i am adding the code. im adding it to where my image is created on my product page (media.phtml) is that wrong? and if it is could u give me a better idea of where to put it, cos in my "view.phtml" there is no image being created?? im rather new at this so sorry for the questions lol – Adam Allen Jun 12 '14 at 14:01
  • @Adam Allen - start simple. Get the code working on the product view first. Then get fancy and implement it with the media.phtml file. :) I'd have to see your view.phtml file to give you a better idea of where to put it but it should be appearing pretty much anywhere you place it. – SR_Magento Jun 12 '14 at 14:39
  • ok dokie, i will keep messing around with ti and if i am still having trouble tomoz i will show you my view.phtml. Thank you – Adam Allen Jun 12 '14 at 15:03
  • What are you using for the path to your image? Make sure you can display the image correctly outside of the code I provided and then bring it in. Also be sure that you have the correct ID for your loyal customer group. Let me know. SR – SR_Magento Jun 12 '14 at 15:26
  • im getting this error Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/senorehe/public_html/app/design/frontend/midmeds/default/template/catalog/product/view.phtml on line 125 The line is echo '<img style="float: left; margin: 2px;" src="/path-to-image/loyal.jpg" alt="'loay customner'">'; obviously i did change the img src but just copy and pasted yours to make it easier lol – Adam Allen Jun 12 '14 at 15:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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