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

Show “Free Shipping text” when free shipping price rule is enabled
 
Magent0J
Jr. Member
 
Total Posts:  9
Joined:  2012-08-27
 

Already made a script with help from this forum and friends, like:

<?php
     
// Determine if product "free shipping" is true
    
if ($_product->getFreeShipping())
    
{
    
echo '<span class="freeShip">'.$_product->getAttributeText('free_shipping').'</span>';
    
}
    
     
// Determine if product costs more than 65
    
else if ($_specialPrice $_product->getFinalPrice() > 65)
    
{
    
echo '<span class="freeShip">FREE SHIPPING ON THIS PRODUCT!</span>';
    
}
    ?>
This works perfectly, but now I want also to show the “FREE SHIPPING ON THIS PRODUCT” text when a price rule called “Free Shipping Rule” is enabled. This price rule ensures that a selection of products gets free shipping.

Edited the code to below, but still doesn’t work. The code below should check the product for the shipping rate. If that’s 0, it should display “FREE SHIPPING ON THIS PRODUCT!” Looks like the is well, isn’t it?

<?php
     
// Determine if product "free shipping" is true
    
if ($_product->getGratisVerzending())
    
{
    
echo '<span class="freeShip">'.$_product->getAttributeText('gratis_verzending').'</span>';
    
}
    
     
// Determine if product costs more than 65
    
else if ($_specialPrice $_product->getFinalPrice() > 65)
    
{
    
echo '<span class="freeShip">GRATIS VERZONDEN!</span>';
    
}
    
    $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)
    
    
// Determine if shipping is 0
    
else if ($rate->getPrice() == 0)
    
{
    
echo '<span class="freeShip">FREE SHIPPING ON THIS PRODUCT!</span>';
    
}
    
    ?>

Maybe do you see some errors in the code? Or should I search for a code that checks if the price rule is applied for the product?
Thanks!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Magent0J
Jr. Member
 
Total Posts:  9
Joined:  2012-08-27
 

Do you have any idea guys? Can’t get it working.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top