1

I have created one module for hide price and replace button, with add to cart in product view page,

enter image description here

For this module I created 4 files:

  • system.xml
  • adminhtml.xml
  • config.xml
  • data.php

but, where to write logic for the hide price, I don't understand.

Any tips on how to get that working? Thanks! pls, help me..

This is my addtocart.phtml file. in this file i have used the condition user logged or not and if user not logged then price not display.

But how can set condition if user also logged in but price not display.

<?php
    //condition to check user is loggedin or not
    if(!Mage::getSingleton('customer/session')->isLoggedIn() AND Mage::getStoreConfig('sigma1_product/sigma1_group/price_enable')):
    echo '<span class="login_for_price"><b>'.Mage::getStoreConfig('sigma1_product/sigma1_group/cart_text').'</b></span><br>';
    return;
    endif;
?>
<?php $_product = $this->getProduct(); ?>
    <?php $buttonTitle = $this->__('Add to Cart'); ?>
        <?php if($_product->isSaleable()): ?>
            <div class="add-to-cart">
                <?php if(!$_product->isGrouped()): ?>
                    <label for="qty"><?php echo $this->__('Qty:') ?></label>
                    <input type="text" name="qty" id="qty" maxlength="12" value="<?php echo $this->getProductDefaultQty() * 1 ?>" title="<?php echo $this->__('Qty') ?>" class="input-text qty" />
        <?php endif; ?>
        <button type="button" title="<?php echo $buttonTitle ?>" id="product-addtocart-button" class="button btn-cart" onclick="productAddToCartForm.submit(this)"><span><span><?php echo $buttonTitle ?></span></span></button>
        <?php echo $this->getChildHtml('', true, true) ?>
            </div>
        <?php endif; ?>

1 Answer 1

1

You can try this, it may help you.

If you only want to hide price then:

Open app/design/frontend/base/default/template/catalog/product/ folder and copy price.phtml file to the app/design/frontend/base/template/themeXXX/catalog/product/ folder, where XXX is the number of your theme, and then place the following code on top of it:

<?php
if(!Mage::getSingleton('customer/session')->isLoggedIn()){
echo '<span class="login_for_price"><strong>Login to See Price (you can show your text by getting from config field)</strong>    </span><br>';
return;
}
?>

If you want to hide add to cart button from product detail:

app/design/frontend/default/themeXXX/template/catalog/product/view/addtocart.phtml file. Add the following code on top of it:

<?php
if(!Mage::getSingleton('customer/session')->isLoggedIn()){
echo '<span class="login_for_details" style="float:left"><strong>Login to     Add to Cart</strong></span>';
return;
}
?>
8
  • this code can I use with my custom module? as i said above ? u can see my image as i uploaded. Feb 22, 2017 at 6:36
  • I think you can use this code along with the isLoggedIn() condition, you can use your modules fields also like if its enabled then only it will work. You can also get your config fields value like Message to show custom message Feb 22, 2017 at 6:56
  • i have used the condition user logged or not and if user not logged then price not display. But how can set condition if user also logged in but price not display. in this current file Feb 22, 2017 at 11:33
  • so you don't want to show price for both logged and non logged in user right? Feb 22, 2017 at 13:07
  • yes i don't want to show price for both logged and non logged in user Feb 23, 2017 at 4:05

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.