I want to show the freeshipping price as text, like "Free shipping" but I can't get it to work. In app/code/core/Mage/Shipping/Model/Carrier/Freeshipping.php I found these lines:
$method->setPrice('0.00');
$method->setCost('0.00');
But if I change the 0.00 to "Free shipping", nothing happens.
I did a LOT of research on the internet but nothing works. There are also much plugins that can set the price to "Free" but that only counts for the products.
So I am desperate and I hope someone can help me here.
I am using Magento 1.7.0.2.
Many thanks
Copy app/design/frontend/base/default/template/checkout/onepage/shipping_method/available.phtml to the respective theme folder you are using.
In the available.phtml file, look for the following code (around line 56):
<label for="s_method_<?php echo $_rate->getCode() ?>"><?php echo $_rate->getMethodTitle() ?>
<?php $_excl = $this->getShippingPrice($_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?>
<?php $_incl = $this->getShippingPrice($_rate->getPrice(), true); ?>
<?php echo $_excl; ?>
<?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
(<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
<?php endif; ?>
</label>
Replace it with the following:
<label for="s_method_<?php echo $_rate->getCode() ?>"><?php echo $_rate->getMethodTitle() ?>
<?php if($_rate->getPrice() > 0) : ?>
<?php $_excl = $this->getShippingPrice($_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?>
<?php $_incl = $this->getShippingPrice($_rate->getPrice(), true); ?>
<?php echo $_excl; ?>
<?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
(<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
<?php endif; ?>
<?php else : ?>
(<?php echo $this->__('Free Shipping'); ?>)
<?php endif; ?>
</label>
Save available.phtml, and clear your Magento caches. "Free Shipping" will now appear next to all methods containing a $0 amount on the One-Page-Checkout shipping section.
Related
i have been trying to echo the codes and it not working properly. after reading up ifelse statement, i still cant figure what wrong with this statement in php outputting unexpected end of file.
<?php if($current_type){?>
<?php echo " Manage Product Type ";
echo "Menu Name:". $current_type["product_type"]."<br>";?>
Edit Subject;
<?php}elseif($current_category){?>
<h1> Manage Product category </h1>
<?php echo "Menu Name:". $current_category["category_name"];?>
<?php}elseif ($current_product){?>
<h1> Manage Products </h1>
<?php echo "Menu Name:". $current_product["product_names"];?>
<?php }else{?>
Please select a Product, category, or type
<?php};?>
This is a huge improvement on the readability of your code. It uses PHP alternate syntax for control structures.
<?php if($current_type): ?>
<h1>Manage Product Type</h1>
Menu Name: <?php echo $current_type["product_type"] ?><br>
Edit Subject
<?php elseif ($current_category): ?>
<h1>Manage Product category</h1>
Menu Name: <?php echo $current_category["category_name"] ?>
<?php elseif ($current_product): ?>
<h1>Manage Products</h1>
Menu Name <?php echo $current_product["product_names"] ?>
<?php else: ?>
Please select a Product, category, or type
<?php endif ?>
try this,
<?php if($current_type){ ?>
<?php echo " Manage Product Type ";
echo "Menu Name:". $current_type["product_type"]."<br>";?>
Edit Subject;
<?php } else if($current_category){ ?>
<h1> Manage Product category </h1>
<?php echo "Menu Name:". $current_category["category_name"];?>
<?php } else if ($current_product){?>
<h1> Manage Products </h1>
<?php echo "Menu Name:". $current_product["product_names"];?>
<?php } else {?>
Please select a Product, category, or type
<?php }?>
Use this rationale
<?php if(1 == 1) { ?>
<?php echo "xxxxx"; ?>
<?php } elseif(1 == 2) { ?>
<?php echo "xxxxx"; ?>
<?php } elseif (1 == 3){ ?>
<?php echo "xxxxx"?>
<?php } else { ?>
<?php echo "xxxxx"?>
<?php } ?>
I am running Magento v1.9.0.1. I want to disable Cash on Delivery for specific products. I have installed COD extension from magento commerce.
I am new to Magento structure and no nothing to little about it. Tried some debugging on it but it is going up above my head.
Also, I have search every where over the internet but no one has ever provided the code for Magento v1.9.0.1.
Create a custom attribute with attribute code as cod and assign it to General of attribute sets.
Now as per you requirement change your methods.phtml (if there is no custom code included in this) as follows.
<?php
$methods = $this->getMethods();
$oneMethod = count($methods) <= 1;
?>
<?php if (empty($methods)): ?>
<dt>
<?php echo $this->__('No Payment Methods') ?>
</dt>
<?php else:
foreach ($methods as $_method):
$_code = $_method->getCode();
?>
<dt>
<?php
//cod verification starts
$attr_cod = array();
$cartItems = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();
foreach ($cartItems as $item) {
$attr_cod[] = Mage::getModel('catalog/product')->load($item->getProduct()->getId())->getCod();
}
if(in_array('1', $attr_cod) && $_code == 'cashondelivery') {continue; }
//cod verification ends
?>
<?php if(!$oneMethod): ?>
<input id="p_method_<?php echo $_code ?>" value="<?php echo $_code ?>" type="radio" name="payment[method]" title="<?php echo $this->escapeHtml($_method->getTitle()) ?>" onclick="payment.switchMethod('<?php echo $_code ?>')"<?php if($this->getSelectedMethodCode()==$_code): ?> checked="checked"<?php endif; ?> class="radio" />
<?php else: ?>
<span class="no-display"><input id="p_method_<?php echo $_code ?>" value="<?php echo $_code ?>" type="radio" name="payment[method]" checked="checked" class="radio" /></span>
<?php $oneMethod = $_code; ?>
<?php endif; ?>
<label for="p_method_<?php echo $_code ?>"><?php echo $this->escapeHtml($this->getMethodTitle($_method)) ?> <?php echo $this->getMethodLabelAfterHtml($_method) ?></label>
</dt>
<?php if ($html = $this->getPaymentMethodFormHtml($_method)): ?>
<dd>
<?php echo $html; ?>
</dd>
<?php endif; ?>
<?php endforeach;
endif;
?>
<?php echo $this->getChildChildHtml('additional'); ?>
<script type="text/javascript">
//<![CDATA[
<?php echo $this->getChildChildHtml('scripts'); ?>
payment.init();
<?php if (is_string($oneMethod)): ?>
payment.switchMethod('<?php echo $oneMethod ?>');
<?php endif; ?>
//]]>
</script>
I have tested this and works fine.
COD is already in magento you didn't need to install it.
There are two way
create a new config setting in which you can enter ids of products
for which you didn't want COD option.
You can create product attribute too for checking COD option.
and check these ids (if you create config settings ) with the
product id or check for the product attribute on
app\design\frontend\base\default\template\checkout\onepage\payment\methods.phtml.
And by simple if else conditions you can avoid COD option for these
products.
I would like to add the article tags in my blog layout in joomla 3.x.
I overwrote the joomla layout files and tried to add the code below in blog_style_default_item_title.php as it is in article
<?php if ($params->get('show_tags', 1) && !empty($this->item->tags)) : ?>
<?php $this->item->tagLayout = new JLayoutFile('joomla.content.tags'); ?>
<?php echo $this->item->tagLayout->render($this->item->tags->itemTags); ?>
<?php endif; ?>
but it did not work. I guess variable name is not the good one. Any ideas?
My knowledges in php language are pretty weak but I had a look and tried a few think.
I finaly got something by adding code below in /com_content/category/blog_items.php
<?php $this->item->tagLayout = new JLayoutFile('joomla.content.tags'); ?>
<?php echo $this->item->tagLayout->render($this->item->tags->itemTags); ?>
but i would like to add "tags" on the title line so in blog_style_default_item_title.phpfile
<?php
defined('_JEXEC') or die;
// Create a shortcut for params.
$params = $displayData->params;
$canEdit = $displayData->params->get('access-edit');
JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html');
JHtml::_('behavior.framework');
?>
<?php if ($params->get('show_title') || $displayData->state == 0 || ($params->get('show_author') && !empty($displayData->author ))) : ?>
<div class="page-header">
<?php if ($params->get('show_title')) : ?>
<h2>essai
<?php if ($params->get('link_titles') && $params->get('access-view')) : ?>
<a href="<?php echo JRoute::_(ContentHelperRoute::getArticleRoute($displayData->slug, $displayData->catid)); ?>">
<?php echo $this->escape($displayData->title); ?></a>
<?php else : ?>
<?php echo $this->escape($displayData->title); ?>
<?php endif; ?>
</h2>
<?php endif; ?>
<?php $this->item->tagLayout = new JLayoutFile('joomla.content.tags'); ?>
<?php echo $this->item->tagLayout->render($this->item->tags->itemTags); ?>
<?php if ($displayData->state == 0) : ?>
<span class="label label-warning"><?php echo JText::_('JUNPUBLISHED'); ?></span>
<?php endif; ?>
</div>
<?php endif; ?>
But i have a error???
Here is how they are added to individual weblinks
<?php $tagsData = $item->tags->getItemTags('com_weblinks.weblink', $item->id); ?>
<?php if ($this->params->get('show_tags', 1)) : ?>
<?php $this->item->tagLayout = new JLayoutFile('joomla.content.tags'); ?>
<?php echo $this->item->tagLayout->render($tagsData); ?>
<?php endif; ?>
What you would want to do is something similar but for com_content.article and make sure the $item and $this->params references match what you have.
Here a picture of the design I would like
And he below the way the page id made of (as i understood it)
in blog_item.php there is this line which call the
...
<?php echo JLayoutHelper::render('joomla.content.blog_style_default_item_title', $this->item); ?>
....
and so in blog_style_default_item_title.php
....
<div class="page-header">
<?php if ($params->get('show_title')) : ?>
<h2>essai
<?php if ($params->get('link_titles') && $params->get('access-view')) : ?>
<a href="<?php echo JRoute::_(ContentHelperRoute::getArticleRoute($displayData->slug, $displayData->catid)); ?>">
<?php echo $this->escape($displayData->title); ?></a>
<?php else : ?>
Did I make a mistake??
I am using onestepcheckout in Magento. I have added in some extra flat rates and I am using two of them. I want to be able to only show one of the flat rates depending on the subtotal of the cart.
I have got the subtotal into a variable but the code has a foreach through each shipping method available so I need a way to say if $total is over 500 only show the second shipping method, if the total is under 500 only show the first shipping method.
<?php $total = Mage::getSingleton('checkout/session')->getQuote()->getSubtotal(); ?>
<?php foreach ($_shippingRateGroups as $code => $_rates): ?>
<dd><?php echo $this->getCarrierName($code) ?></dd>
<?php foreach ($_rates as $_rate): ?>
<dt style="margin-bottom: 5px;">
<?php if ($_rate->getErrorMessage()): ?>
<ul class="messages"><li class="error-msg"><ul><li><?php echo $_rate->getErrorMessage() ?></li></ul></li></ul>
<?php else: ?>
<input name="shipping_method" type="radio" class="validate-one-required-by-name" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>"<?php if($_rate->getCode()===$this->getAddressShippingMethod()) echo ' checked="checked"' ?> />
<label for="s_method_<?php echo $_rate->getCode() ?>"><!--<b><?php echo $this->getCarrierName($code) ?>:</b>--> <?php echo $_rate->getMethodTitle() ?>
<strong>
<?php $_excl = $this->getShippingPrice($_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?>
<?php $_incl = $this->getShippingPrice($_rate->getPrice(), true); ?>
<?php echo $_excl; ?>
<?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
(<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
<?php endif; ?>
</strong>
</label>
<?php endif ?>
</dt>
<?php endforeach; ?>
<?php endforeach; ?>
Just do ...
//first method here by default
if($total>500){
//second method here
}
Something tells me you already know how to do this though
I can't decipher, what the first and second method are in your code, otherwise I would've posted a more complete code
Hi i am in new in opencart. I have code in product.tpl. i want remove the "price" in the option box selection....
If i remove the "price" in option box, it affect in price calculation i.e., finalpricevalue in header.tpl
I want solution
hide the "price" in the option box (OR)
Change the colour of "price" in the option box (OR)
remove the "price" in product.tpl and assign value to "finalpricevalue" in header.tpl
product.tpl---->
<select name="option[<?php echo $option['product_option_id']; ?>]" width="300"style="width:200px">
<option value=""><?php echo $text_select; ?></option>
<?php foreach ($option['option_value'] as $option_value) { ?>
<option value="<?php echo $option_value['product_option_value_id']; ?>"><?php echo $option_value['name']; ?>
<?php if ($option_value['price']) { ?>
(<?php echo $option_value['price_prefix']; ?><?php echo $option_value['price']; ?>)
<?php } ?>
</option>
<?php } ?>
</select>
header.tpl----->
var position1 = newPriceValue.indexOf("(");
var position2 = newPriceValue.indexOf(")");
position1 = position1+3;
var **finalPriceValue** = newPriceValue.substring(position1, position2);
var txt = newPriceValue;
txt = txt.replace(/,/g, '');
array=txt.match(/(?!$)\d+(\.\d+)/g);
Please help me......
In product.tpl there are several instances of $option_value['price'] correlating to different types of options you can have on a product. First make a copy of product.tpl for a backup then to make the price "disappear" search product.tpl for each instance of:
<?php if ($option_value['price']) { ?>
(<?php echo $option_value['price_prefix']; ?><?php echo $option_value['price']; ?>)
<?php } ?>
and enclose it with a html comment like this:
<!--
<?php if ($option_value['price']) { ?>
(<?php echo $option_value['price_prefix']; ?><?php echo $option_value['price']; ?>)
<?php } ?>
-->
That shouldn't effect the header total which is what I assume you mean by:
If i remove the "price" in option box, it affect in price calculation
To change the color of the price; find the same code blocks and make it something like this:
<?php if ($option_value['price']) { ?>
<span class="price_color">(<?php echo $option_value['price_prefix']; ?><?php echo $option_value['price']; ?>)</span>
<?php } ?>
Then make a backup copy of /catalog/view/theme/your_theme/stylesheet/stylesheet.css and add:
.price_color {color: #000000}
or whatever color you want it to be. Just enclosing it in a span for styling. There may be better ways to do what you're trying to do. You might put the styling in a new css so its not overwritten when updating the template if it's not your own.