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.
Related
I am writing am extension for my magento shop which basically gives 5% discount to all newsletter subscribed customers. the extension is working but now problem is it doesn't show the promotion code discounts entered by customers.
I am using this code to get discount:
$address->setDiscountAmount($total - $discountAmount);
$address->setDiscountDescription("5% Discounted Subtotal");
$address->setBaseDiscountAmount($total - $discountAmount);
I was wondering if there is any magento method or functions which gets an array of all applied discounts for the cart.
Or if anyone can tell me where can i find list of all the available functions in magento.
To get total discount for all the items in the cart, you can try this,
$quote2 = Mage::getSingleton('checkout/session')->getQuote();
$discountTotal = 0;
foreach ($quote2->getAllItems() as $item){
$discountTotal += $item->getDiscountAmount();
}
magento i need to apply discount 20% for the total if above 50euros but not to the discounted items if customers selects some already discounted items that should not include in the total can any one help
Thanks in advance
You need to create a custom module or say shopping cart price rule and an event observer to check whether the "special price" is zero or not. If it is "Zero" that means it is not a already discounted product or you can even check the "final price" with the "price" , if the final price is lesser than price it is already discounted.
If these conditions are satisfied get the prices of remaining products prices and discount them then add the already discounted products price to make the total amount.
I hope You understood this concept and write your own module.
you have to use a check in view page.
for example
$price = $product->getPrice();
$specialprice = $product->getFinalPrice();
if(!empty($specialprice)){
//then your price would be same
}
elseif(empty($specialprice)){
then price would be = $price*20/100;
}
hope this would help you and don't forget to like if it was helpful
I am using Tier Prices and have a set price for quantities that fall between 1 and 4 and a per item price for anything over 4.
I want to modify my cart to have a set price for items where Qty >= 1 && Qty <=4
How do I do that?
Here is the item i testing this with: http://stjamestutorials.com/ppptransportation/index.php/mayfield-falls-tours-negril-jamaica-tours.html
Try and create an observer for this event:
catalog_product_get_final_price
which is found in the class :
app\code\core\Mage\Catalog\Model\Product\Type\Price.php
The event comes with the product and the qty, so you can write your logic and then set your custom price in the final_price attribute of the product.
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']);
}
We have a mixture of products, some with specialPrice and some with Catalog Rules set.
I need to display the discounted % for all my products on my frontend.
We were using $_product->getSpecialPrice() to get the discounted price, but this fails for products which prices based on catalog rules.
Is it possible to get the Discounted prices based on the catalog rule or from the specialPrice ?
Yes you can use $_product->getFinalPrice().
Here is the difference in the three prices:
$regularPrice = number_format($_product->getPrice(), 2);
$discountedPrice = number_format($_product->getFinalPrice(), 2);
$specialPrice = number_format($_product->getSpecialPrice(), 2);
Try this snippet:
This one will calculate price rules.
Mage::getModel('catalogrule/rule')->calcProductPriceRule($product,$product->getPrice());
Is is what you looking for?