How to display VAT after price in magento - php

Im struggling a bit here. Basically, out client want the prices on the listing and product page to exclude VAT which is fine. But they she wan't written after the price '+VAT (£0.00)'.
Obviously the £0.00 will be the exact amount of VAT that will be added onto the product. So if its £20, it will need to say:
£20.00 +VAT (£3.40)
Does anyone know of a way to do this?
thanks.

You need to override price.phtml. Create copy of price.phtml to new_price.phml and call it from catalog.xml file for product listing page. Also enable System->Configuration->Tax->Price Display Settings->Display Product Prices In Catalog : Including and Excluding Tax
Then, in new_price.phtml do some changes as below:
<span class="price-excluding-tax">
<span class="label"><?php echo $this->helper('tax')->__('Price:') ?></span>
<span class="price" id="price-excluding-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
<?php if ($_finalPrice == $_price): ?>
<?php echo $_coreHelper->currency($_price, true, false) ?>
<?php else: ?>
<?php echo $_coreHelper->currency($_finalPrice, true, false) ?>
<?php endif; ?>
</span>
</span>
<span class="price-including-tax">
<span class="label"><?php echo $this->helper('tax')->__('Vat:') ?></span>
<span class="price" id="price-including-tax-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
<?php //echo $_coreHelper->currency($_finalPriceInclTax, true, false) ?>
<?php if ($_finalPrice == $_price): ?>
<?php echo $_coreHelper->currency($_finalPriceInclTax - $_price, true, false) ?>
<?php else: ?>
<?php echo $_coreHelper->currency($_finalPriceInclTax - $_finalPrice, true, false) ?>
<?php endif; ?>
</span>
</span>
Hope it will help!

Related

Add "Starting from" in front of prices on category page in open cart store

I'm trying to edit the template and I need to add "Starting from" in front of the prices on the catalog page (and then maybe the product page, but one step at a time)
I've located where it echos the price in the tpl file
<p class="price">
<?php if (!$product['special']) { ?>
<?php echo $product['price']; ?>
<?php } else { ?>
<span class="price-new"><?php echo $product['special']; ?></span> <span class="price-old"><?php echo $product['price']; ?></span>
<?php } ?>
What I tried was to add a row in the oc_product table called starting_from and manually enter "Starting from" in each one. (there are only 6 products for now).
With very little knowlegde i added
<?php echo $product['starting_from']; ?>
so it then looked like this
<p class="price">
<?php if (!$product['special']) { ?>
<?php echo $product['starting_from']; ?>
<?php echo $product['price']; ?>
<?php } else { ?>
<span class="price-new"><?php echo $product['special']; ?></span> <span class="price-old"><?php echo $product['price']; ?></span>
<?php } ?>
Shockingly, it didn't work.
Can someone try and explain the magnitude of my errors, please?
And maybe help me out.
Thank
If your want to simply add the hardcoded string Starting from, you can do:
<p class="price">Starting from
<?php if (!$product['special']) { ?>
<?php echo $product['price']; ?>
<?php } else { ?>
<span class="price-new"><?php echo $product['special']; ?></span> <span class="price-old"><?php echo $product['price']; ?></span>
<?php } ?>
Actually, if I got you right, this is very basic, so I'd recommend some PHP tutorial to start with.

Magento, showing payment of a product conditions on the homepage

have a phtml file riding the payment of the value of a product, the function responsible for it automatically puts on every page of the product installment conditions, but does not appear the payment terms on the homepage where I coloto one "carousel "for featured products.
Someone would have a hint of what I do?
Note 1: I use a AllPago the module to set the conditions only that I can not use the stand for the value that do not have access.
Note 2: according to the source code that assembles the installments for me (file name in magento to find looks like this: allpago_installments / productviewtable.phtml
<?php foreach ($this->getInstallments() as $installment): ?>
<?php $result = count($this->getInstallments()); ?>
<?php if($installment->getValue()==$result):?>
<div class="product-view-parcel">
<?php echo $installment->getValue() . ' x ' . $installment->getInstallment() . ' ' . $installment->getMessage(); ?>
</div>
<?php endif;?>
<?php endforeach; ?>
Note 3: a part of the home page code where I try to call the price and conditions (heeding the price appears correctly only the payment terms that do not):
<div id="ripplesslider" class="ripplesslider" style="height: 470px!important;">
<?php foreach ($_productCollection_slider as $_product): ?>
<div id="slide" style="text-align: center !important;height: 470px!important;"
class="latest-slider-item slide slider<?php echo $_product->getId() ?>">
<a href="<?php echo $_product->getProductUrl() ?>"
title="<?php echo $this->htmlEscape($_product->getName()) ?>">
<div style="height: 200px!important;">
<img onmouseover="mouseover(<?php echo $_product->getId() ?>)"
onmouseout="mouseout(<?php echo $_product->getId() ?>)"
style="width:<?php echo $t ?>px;
height:<?php echo $imageheight ?>px; "
src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image'); ?>"
alt="<?php echo $this->htmlEscape($_product->getName()) ?>"/>
</div>
</a>
<div class="desc-item">
<div class="carousel-name-product"> <?php echo $_product->getName() ?></div>
<div class="latest-price">
<?php if ($_product->getRatingSummary()): ?>
<?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
<?php endif; ?>
<?php $this->getPriceHtml($_product, true) ?>
<?php echo '<span czlass="price">' . str_replace('R$','', $this->getPriceHtml($_product, true)) . '</span>'; ?>
</div>
</div>
</div>
<?php endforeach ?>
</div>
haha staff already got, I'll post here what I did to perhaps help others.
<div>
<?php echo '<span class="price">' . str_replace('R$','', $this->getPriceHtml($_product, true)) . '</span>'; ?>
<?php // object reference?>
<?php $reference = Mage::getStoreConfig('allpago/installments/active'); ?>
<?php//returns a new object. references ?>
<?php $installmentModel = Mage::getModel('installments/'.$reference); ?>
<?php //access the parameters to get the conditions have to function "getInstallmentHighest" to return the plots?>
<?php $installmentModel->setValue($_product->getFinalPrice()); ?>
<?php $installment = $installmentModel->getInstallmentHighest(); ?>
<span style="text-align: left;color: #A8A0A8;position: absolute;margin-top: -46px !important;margin-left: -78px !important;font-size: 12px;">
<?php echo $installment->getValue().' x '. $installment->getInstallment() . ' ' . $installment->getMessage(); ?>
</span>
</div>

Add Span Between Currency Symbol and Price in Magento

I am looking to split the price from the currency symbol so i can add
<span class="price" itemprop="price">
Between the two.
I have found the code in the price.
<p class="special-price">
<span class="price-label"><?php echo $_specialPriceStoreLabel ?></span>
<span class="price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
<?php echo $_coreHelper->currency($_finalPrice, true, false) ?>
</span>
</p>
How do i go about changing this so i can place the span between the symbol and price.
To get price without currency
$_coreHelper->currency($_finalPrice, false, false)
To get current currency symbol
Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol()
So your code would become something like this:
<p class="special-price">
...
<span class="currency-code"> <?php echo Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol(); ?> </span>
<span class="price" itemprop="price"> <?php echo $_coreHelper->currency($_finalPrice, false, false); ?> </span>
</p>

add string to displayed price in magento

I'm trying to add a simple string to the display price in Magento. Currently the price displays as $##.## by default. I would like it to read: Price: $##.##
A simple search of the displayed prices brought me to template/catalog/product/price.phtml. This file seems to control price display when there are variables involved. IE, price including tax, excluding tax, special prices, etc...
Which file is controlling the displayed price when there are no variables involved, the default price:
<span class="price">$##.##</span>
Once I figure out where this is located, I'm confident I can append a simple string before the displayed price.
Thanks in advance.
OK. I was suggesting in the comments not to get lost in the if-else statements but I just did also for a few minutes. Finally found it.
Inside this if statement
<?php if ($_finalPrice >= $_price): ?>
there is an other if:
<?php if ($_taxHelper->displayBothPrices()): ?>
On the else statement of this last if there is the part you are looking for.
<?php if ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($_product, 0)): // including ?>
<span class="regular-price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
<?php echo $_coreHelper->currency($_price + $_weeeTaxAmount, true, true) ?>
</span>
<?php elseif ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($_product, 1)): // incl. + weee ?>
<span class="regular-price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
<?php echo $_coreHelper->currency($_price + $_weeeTaxAmount, true, true) ?>
</span>
<span class="weee">(
<?php foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?>
<?php echo $_weeeSeparator; ?>
<?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo $_coreHelper->currency($_weeeTaxAttribute->getAmount(), true, true); ?>
<?php $_weeeSeparator = ' + '; ?>
<?php endforeach; ?>
)</span>
<?php elseif ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($_product, 4)): // incl. + weee ?>
<span class="regular-price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
<?php echo $_coreHelper->currency($_price + $_weeeTaxAmount, true, true) ?>
</span>
<span class="weee">(
<?php foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?>
<?php echo $_weeeSeparator; ?>
<?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo $_coreHelper->currency($_weeeTaxAttribute->getAmount() + $_weeeTaxAttribute->getTaxAmount(), true, true); ?>
<?php $_weeeSeparator = ' + '; ?>
<?php endforeach; ?>
)</span>
<?php elseif ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($_product, 2)): // excl. + weee + final ?>
<span class="regular-price"><?php echo $_coreHelper->currency($_price,true,true) ?></span><br />
<?php foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?>
<span class="weee">
<?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo $_coreHelper->currency($_weeeTaxAttribute->getAmount(), true, true); ?>
</span>
<?php endforeach; ?>
<span class="regular-price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
<?php echo $_coreHelper->currency($_price + $_weeeTaxAmount, true, true) ?>
</span>
<?php else: ?>
<span class="regular-price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
<?php if ($_finalPrice == $_price): ?>
<?php echo $_coreHelper->currency($_price, true, true) ?>
<?php else: ?>
<?php echo $_coreHelper->currency($_finalPrice, true, true) ?>
<?php endif; ?>
</span>
<?php endif; ?>
Each part in this code shows a regular price, depending on the tax settings. Most probably you need only the last part.
<?php if ($_finalPrice == $_price): ?>
<?php echo $_coreHelper->currency($_price, true, true) ?>
<?php else: ?>
<?php echo $_coreHelper->currency($_finalPrice, true, true) ?>
<?php endif; ?>
i'm on magento 1.8, and developing on nearly plain system, when debugging, i'm on
<?php if ($_finalPrice == $_price): ?>
<?php echo $_coreHelper->currency($_price, true, true) ?>
<?php else: ?>
<?php echo $_coreHelper->currency($_finalPrice, true, true) ?>
<?php endif; ?>
round about line 201

substr not working with $item->getTitle

I'm making a website with Joomla and am using RokSprocket to display some news. Now, some Titles are too long, so I wanted to shorten it after a certain character number, but it's not working. Am a total php noob, my apologies.
Here's the whole code:
<li data-lists-item>
<h4 class="sprocket-lists-title ">
<?php if ($item->custom_can_have_link): ?><a href="<?php echo $item->getPrimaryLink()->getUrl(); ?>"><?php endif; ?>
<?php if(strlen($item->getTitle)>10)
echo substr($item->getTitle,0,10) . ' ...';
else
echo $item->getTitle();?></a>
<div class="date"><?php echo date('d.M. Y', strtotime($item->getDate()));?></div>
</h4>
<span class="sprocket-lists-item" data-lists-content>
<span class="sprocket-padding">
<?php if ($item->getPrimaryImage()) :?>
<img src="<?php echo $item->getPrimaryImage()->getSource(); ?>" class="sprocket-lists-image" />
<?php endif; ?>
<?php echo $item->getText(); ?>
<?php if ($item->getPrimaryLink()) : ?>
<span><?php rc_e('READ_MORE'); ?></span>
<?php endif; ?>
</span>
</span>
</li>
I'm hoping it's something very obvious and I'm just being stupid. Thanks a bunch already!
$item->getTitle is probably a method not a property, so try:
$item->getTitle(); // <-- parenthesis
Change to:
<?php if(strlen($item->getTitle())>10)
echo substr($item->getTitle(),0,10) . ' ...';

Categories