Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

call special price? 
 
DrBillNye
Sr. Member
 
Avatar
Total Posts:  96
Joined:  2009-02-07
Boulder, CO
 

I’ve created a featured product tool that selects a random product then displays it.  I wanted the price to display a little bigger and everything looked good with this code -

<?php if($_product->getPrice() > 0): ?> <span class="price"><span class="price-super">$</span<?str_replace(',''<span class="price-dec">'number_format($_product->getPrice(), 2',','')); ?>  </span></span<?php endif ?>

The only problem is I don’t know how to call the special price.  So if I change the price on something, only the normal price is returned here.  Anyone know the syntax for grabbing the special price if there is one?

Thanks,
Al

 
Magento Community Magento Community
Magento Community
Magento Community
 
dhoover
Jr. Member
 
Total Posts:  27
Joined:  2009-02-23
 

I get did a find/grep for specialprice in the codebase and it looks like the call on a product would be $_product->getSpecialPrice()

Try that… I need it too but have a stack of other things to hit first. Let me know if it works.

Dean

 
Magento Community Magento Community
Magento Community
Magento Community
 
DrBillNye
Sr. Member
 
Avatar
Total Posts:  96
Joined:  2009-02-07
Boulder, CO
 

Yeah, that worked great, thanks for digging that out for me.

The snippet I ended up doing (and I’m sure there’s more efficient ways to pull this off but it works is -

<?php if($_product->getSpecialPrice() == 0): ?>
   <?php 
if($_product->getPrice() > 0): ?> <span class="price"><span class="price-super">$</span<?str_replace(',''<span class="price-dec">'number_format($_product->getPrice(), 2',','')); ?>  </span></span<?php endif ?>
   <?php 
else: ?>
   <?php 
if($_product->getSpecialPrice()): ?> <span class="price"><span class="price-super">$</span<?str_replace(',''<span class="price-dec">'number_format($_product->getSpecialPrice(), 2',','')); ?>  </span></span<?php endif ?>
   <?php 
endif ?>
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top