Magento change payment information in the email templates - magento

I have a small problem with the email templates.
In the checkout and cart pages i managed to change 'Grand Total' to 'Total'
This didn't change in the email templates though.
does anyone know how i can remove the Grand total excl VAT.
And change 'Grand Total incl Vat' to 'Total'?
Thanks in advance

The email template that includes the total is in:
email/order/invoice/items.phtml
More specifically it's this line of code:
<?php echo $this->getChildHtml('invoice_totals')?>
The template for invoice_totals is sales/order/totals.phtml
The template for the Grand Total is in:
tax/checkout/grandtotal.phtml
To get the grand total you can use the following code:
<?php $grandTotal = Mage::getBlockSingleton('tax/checkout_grandtotal')->getTotalExclTax(); ?>

Related

Magento - Add attribute if the product qty is zero

I want to insert this attrribute that I have created into the product page above the add to cart button but only if the qty is ZERO. Basically an estimated arrival date. Items that are available on back order only have a note above the add to cart button of when the product will actually be available from. I have put the below in and it works but I don't want it to show for products already available.
<p><font color="red">AVAILABLE FROM: <?php echo $_product->getResource()->getAttribute('due_date')->getFrontend()->getValue($_product); ?></font></p>
Can someone let me know what I need to add please.
Most appreciated
Anthony
You should be able to get the stock quantity on the product page by using:
Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty()
You can then use that in a conditional to show the piece of code that you want. However, I'm not sure you need all of that to show the due date. Because you're already loading the product when you are on the product page, you should just be able to use:
<p class="red">AVAILABLE FROM: <?php echo $_product->getDueDate(); ?></p>
If that doesn't work, make sure that you have your due date attribute set to be visible on the product page. It'll be the one called, "Visible on Product View Page on Front-end".
Full code block could look something like this:
<?php
$qty = Mage::getModel(cataloginventory/stock_item)->loadByProduct($_product)->getQty();
if ($qty <= 0): ?>
<p class="red">AVAILABLE FROM: <?php echo $_product->getDueDate(); ?></p>
<?php endif; ?>
If you allow backorders, it's important you check for <= 0, rather than == 0. This is because if someone backorders it, your stock will go negative.
Also, it's more clean to remove the font tag and use CSS to style the text.

Magento Applying tax (VAT) twice

I finally got VAT (tax) working on my site with prices being entered in the catalog INCLUSIVE of tax. Then the decision was made to input value EXCLUSIVE of tax. A little SQL allowed me to change all the stored prices, however, when the catalog pages are displayed, the wrong values are being shown... tax is being applied twice!
The tax rate is 20% and if a product has a tax exclusive price of £10, it's showing as tax exclusive, £12.00 and tax inclusive £14.40.
If I click on the product then the product page shows the correct values of £10 and £12.
The template displaying the catalog prices is catalog/product/price.phtml and in there I see code which I'm not understanding (i.e. I assume it's correct because this is a well used product but it doesn't make sense to me!)
I see (in template/catalog/product/price.phtml), first of all, variables being set...
$_price = $_taxHelper->getPrice($_product, $_product->getPrice())
$_finalPrice = $_taxHelper->getPrice($_product, $_product->getFinalPrice())
$_finalPriceInclTax = $_taxHelper->getPrice($_product, $_product->getFinalPrice(), true)
and debug statements show these to be returning £10.00 and £12.00 as expected - and then £14.40 (not as expected!).
Further on, where the value is output I see...
<span class="price-excluding-tax <?=$groupclass?>">
<span class="label"><?php echo $this->helper('tax')->__('Excl. Tax:') ?></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>
So it seems to me that the final price should actually be the exclusive price but is actually including the tax, which then gets added in again!
That appears to be the mechanism but I assume I've got a setting wrong somewhere or others would have been yelling long before now!
In the configuration I've got it set saying catalog prices exclude tax and country of origin and default destination both as UK.
So what am I missing?
This is Magento 1.7.0.2
I also spent a couple of days in this problem and I realized that sometimes totals are collected in the wrong order.
In particular in my case I was using catalog prices intended as including tax and I figured out Mage_Sales_Model_Quote_Address_Total_Subtotal::collect() ran before Mage_Tax_Model_Sales_Total_Quote_Subtotal::collect(), you can understand is the same issue looking at the table sales_flat_quote_item, when the base_price field is correctly set with the price value excluding tax and the price field is set with the price gross value (including tax).
You can check the execution order of collect method for each total in app/code/core/Mage/Sales/Model/Quote/Address.php around line #1004
/**
* Collect address totals
*
* #return Mage_Sales_Model_Quote_Address
*/
public function collectTotals()
{
Mage::dispatchEvent($this->_eventPrefix . '_collect_totals_before', array($this->_eventObject => $this));
foreach ($this->getTotalCollector()->getCollectors() as $model) {
// this is the loop where totals are collected
$model->collect($this);
}
Mage::dispatchEvent($this->_eventPrefix . '_collect_totals_after', array($this->_eventObject => $this));
return $this;
}
to fix this kind of issue you have to define in config.xml of a custom module totals dependencies defining <after> and <before> where necessary
<config>
...
<global>
<sales>
<quote>
<totals>
<tax_subtotal>
<class>tax/sales_total_quote_subtotal</class>
<after>subtotal,nominal,shipping,freeshipping</after>
<before>tax,discount</before>
</tax_subtotal>
</totals>
</quote>
</sales>
</global>
...
</config>
Thanks again Magento for making my day always more interesting!
In administration go to settings > sales > tax > calculation -
And here set “tax based on” to the last item (package origin, or something like that).
Terms are not perfect,
Or you can change setting accordingly as you want in your cart.
if your code it perfect then you are just missing some configuration on it.
Also you can go throw all the inner tabs fo tax calculation.
i hope it will sure help you

magento add tax on custom attribute based price

we sell bunch of product and we need to display each price product and entire box price.For that reason i have created attribute with each price and calling it on product page.So main price of product will be box price and each price will be display from attribute.but now i when i add tax i can see the main price with excluding and including tax but how to apply that tax on attribute based price?
this would be each product price
<?php echo $_product->getResource()->getAttribute('each_price')->getFrontend()- >getValue($_product)?>
this would be whole box price
<?php echo $this->getPriceHtml($_product, true);?>
some thing like this can be done to achive this.please look the code below
<?php $txrate= $_product->getData('tax_percent');
if($txrate!=""):
echo '<div class="each-inc-tax">';
$ech_price= $_product->getResource()->getAttribute('each_price')->getFrontend()->getValue($_product);
$tx=($txrate*$ech_price)/100;
$each_tax=$ech_price+$tx;
echo ' <b>Each Price Including Tax:</b> <b>'. $each_tax.'</b>';
echo '</div>';
endif;
I was using the MSRP attribute in my magento and storing the value excluding Tax, but wishing to display on the frontend including Tax.
I used the following code...
<?php
$_finalPriceExclTax = $this->helper('tax')->getPrice($_product, $_product->getPrice(), false);
$_finalPriceInclTax = $this->helper('tax')->getPrice($_product, $_product->getFinalPrice(), true);
$_taxpercent = $_finalPriceInclTax / $_finalPriceExclTax;
$_msrpPrice = $_product->getMsrp() * $_taxpercent;
?>

Subtotal less coupons/discounts on order confirmation page of Magento

On the Order Confirmation page of Magento 1.5 (using the template , I have the a number of analytics conversion code scripts (like Google AdWords Conversion tracking).
The code that is currently used to get the subtotal is
<?php $order_id = Mage::getSingleton('checkout/session')->getLastRealOrderId(); ?>
<?php $order_details = Mage::getModel('sales/order')->loadByIncrementId($order_id); ?>
<?php $subtotal = $order_details->subtotal; ?>
And then the $subtotal variable is used throughout. The problem is that this is the subtotal BEFORE any coupons or discounts are applied. I need it to be the total AFTER coupons or discounts.
Can anyone help me with the code to get at that value?
You can call var_dump($order_details->debug()) to see all the data fields of the order object. I don't see anything that matches the subtotal with discount, but I do see a discount_amount field, which has the total discount amount (as a negative number); add this to your subtotal.
If you want the grand total, with discounts and shipping included, use the grand_total field.

How to access to the discount price in Magento?

I'm trying to rewrite a template for the cart.
I need to retrieve the discount amount but I was not able to find where.
Ie If my coupon code gives me $10 discount I want to retrieve 10, if I have a discount of 5% I want to retrieve 5 if the total price is $100.
Thank you.
you can debug your object by printing it out and observing what values it contains
print_r($this->getQuote()->getData());
I used the following code to access discount price. I was accessing the details of last order in a phtml file. For the last order if there was a discount coupon used then I used following code to access the Discount Amount.
$lastOrderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
$order=Mage::getModel('sales/order')->loadByIncrementID($lastOrderId);
if($lastOrderId) //If order was placed then only display coupon code
{
$coupon=$order->getCouponCode();
echo "<b>Discount coupon used during order:</b>".$coupon;
$disAmount=$order->getDiscountAmount();
echo "<br/>Discount Amount: ".$disAmount;
}

Resources