Display tax class in Magento - magento

I want to display the tax name that applies to a product on the product page (the same tax class that is configured on the product).
This is what I wan to show:
Price: 100 U$S + Sample Tax
Thanks!

This returns the Name of the Tax-Class:
$taxClassId = $_product->getTaxClassId();
$taxClass = Mage::getModel('tax/class')->load($taxClassId);
$taxClassName = $taxClass->getClassName();

Related

custom options price calculation

How does custom options price calculation work for a fixed and percent price?
I want to change percent calculation functionality from base price to total price.
Currently it's calculating price from base price.
How to change this from base price to total price?
For example:
base price = $10
custom option1 = $10
custom option2 = 10%
default Magento calculation:
Total price = Base price + selected custom option1 + selected custom option.
Total price = $10+$10+ 10% of $10(baseprice) = $21.
But we need this Total price after selecting the custom option:
Total price = $10+$10 = $20.
Total price after select custom option2
Total price = $20 + (10% of Total price)
Total price = $20 + (10% of $20).
Total price = $20 + $2 = $22.
I need to calculate the percentage from the total price, not from the base price. Please advise.
This is done in
Mage_Catalog_Model_Product_Type_Price::_applyOptionsPrice
If this applies only to special products, you might want to create an own product type with a customer price handler.

Add additional product price with mangento base product price

I want to add additional price with product(simple) price, I am trying to do this with the help of custom attributes. I add a custom attribute "Margin Price" and I want to add up this custom attribute value (margin price) with the base price of the product in the template file.
I am updating all product price after each 5 minutes by cron job, thats why I think I have to do add margin price with base product price by this way.
I added it successfully in product list page and in product view page, but have problem with how to add this margin price with base price in the cart and onepage checkout?
Here is the code on the product list page and same for the product detail page which works fine for me in magento 1.6.x.
$regularPrice = number_format($_product->getFinalPrice(), 2);
//echo $regularPrice = $this->getPriceHtml($_product, true
$priceWithoutComma = str_replace(",", "",$regularPrice);
settype($priceWithoutComma, "float");
$marPrice = $_product->getMarginPrice();
settype($marPrice, "integer");
$finalPrice = $priceWithoutComma + $marPrice;
echo $finalPrice.Mage::app()->getLocale()->currency(Mage::app()->getStore()->
getCurrentCurrencyCode())->getSymbol();
I am doing this right way or I have to changes the whole process?
Looks like you might need to consider a different approach. The reason being that echoing the price from a template file does not modify the price of the item in any way. It simply outputs a calculation.
You'll need to learn a bit about event listeners for this one to work.
Here's a blog post of mine on how to do this.

Magento: use tier_price instead of price

How can I show and use the Tier Price of the "Customer Group" to which the current user belongs?
I'm using Magento ver. 1.4.1.1
You can use:
$oProduct = Mage::getModel('catalog/product')->load($product_id);
$aTierPrice = $oProduct->getTierPrice();
to get the proper tier price(s) of a product.
If you define distinct tier prices for a product, e.g.
price of x for customer group 'NOT_LOGGED_IN'
price of y for customer group 'General'
getTierPrice() will only return the matching tier price.

is it possible to get only the associated product count from shopping cart?

I am working on a Ajax cart for my website. I am trying to validate Configurable products for the stock availability. Please consider below case
Cotton shirt (Product ID : 421 - Configurable Product)
Size : L (Product ID : 425 - Simple product)
Size : M (Product ID : 436 - Simple product)
User should select at least one size to add product to the cart.
When i added this product with "Size L" twice and added this product with "Size M" once.
And when i print the item ids in shopping cart, it shows only the id of Configurable product (421).
How do i get ids of Simple product which are really being added to the cart?
You will need to check if the product in the cart is configurable, then if it is you can get the information stored in the product options to work out the simple product that was actually added. The below code should help a bit:
if($product['product_type']=='configurable'){
$options = unserialize($product['product_options']);
$simpleProduct = Mage::getModel('catalog/product')->loadByAttribute('sku',$options['simple_sku']);
}

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