Magento : Availability of configurable products on Cart page - magento

I want to show Stock Availability on cart page in magento for a configurable products.
The stock status is fine on Product Detail page, however on cart page it always shows "out of stock" for configurable product. I can understand what the reason is, the inventory of the configurable product itself is set to 0. However on a product detail page it does show "In Stock" because the child products are "In Stock". But if I want to check the availability on Cart page, it always shows "Out of Stock".
Below is the code how I want to achieve the Stock Availability on a Cart page.
<?php
$thisProduct = Mage::getModel('catalog/product')->load($_item->getId());
if($thisProduct->isAvailable()):
echo $this->__('In stock');
else:
echo $this->__('Out of stock');
endif;
?>

You can try with: isSaleable() method instead.
Let me know if that works for you.
Thanks

In the path template\checkout\cart\item\default.phtml use the below code to check product availability
$_item->getProduct()->isSaleable() or else when you got $_item = $this->getItem(); object
Hope it may helps

Related

Magento 2: Get Simple Product's Price?

I've been building a Magento 2 template however I've hit a roadblock with the way I'm pulling the prices. The prices are being pulled correctly for simple products by using the following (simplified as I'm exploding the variable to split the string):
$price = $product->getPrice();
<p><?php echo $price; ?></p>
Due to Magento 2 changing the way it processes the prices of configurable products, the price is being outputted as 0.00 for configurables and not pulling the price of the simple products that are attached to it. This was to be expected because I'm not telling it to pull the price of the simple products.
What's the best way for me to get the prices of the simple products? There's a size dropdown on the configurable so ideally, the price would change depending on which product you click on in the dropdown.
Due to me having to explode the price string, I can't just call the block in the XML file either unless I write an overkill jQuery script to split the string on the browser...
Thanks!
Try this code it will help you.
if($product->getTypeId() == \Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE){
$product->getFinalPrice();
}
else
{
echo $product->getPrice();
}
in your block phtml file you can just use
<?php
$_product = $this->getProduct();
echo $_product->getFinalPrice();
?>
it should show you final price,it work with simple and bundle products

Magento get $product->getFinalPrice();

I am having issue in magento..
On my product Page when I try
$product->getFinalPrice();
it shows discounted Price correctly ($812)..
but when order is placed, Instead of this price, I get some other wrong price(411) ( I haven;t figured out what Price is that because I haven't set that price anywhere while adding this prodcut)
so my question is,
How can I send Correct Price ($product->getFinalPrice();) on Cart page..
On cart page, price is shown with
$item->getPrice() which comes from qouted items
anyway I can access $product->getFinalPrice(); and replace $item->getPrice(). with $product->getFinalPrice(); on cart page ???
can anybody guide me why prices are shown so wrong??
Check is there any other "Shopping Cart Price Rule" or "coupons" are being applied...

Static Block for specific products in magento

Is there any way to do this :
I have two kinds of products, Handmade and ready women accessories. for handmade products I want a block under the price that tell the customer "This Product is 100% Handmade" and for the ready product nothing. So it will be only for the Handmade.
I already have a block but it is visible to all products, so I want it to be visible only for Handmade products.
Any Ideas ?
Can you not create an attribute specifically for the Handmade products? e.g the attribute could be called 'IsHandmade'.
Then on your product page (view.phtml) under the price have something like this?:
<?php if ($product->getIsHandMade == 'Yes'):
echo 'This Product is 100% Handmade';
endif; ?>

Add tier price to upsell block

I searched high and low on google for this answer. I need to display the tier prices for the products that show on the upsell block in the product page.
I tried this:
<?php echo $this->getTierPriceHtml() ?>
However, it echos the tier price for the main product on the page instead of the tier prices for the products in the upsell block.
Does anyone know a work around here?
You're almost done
$this->getTierPriceHtml($_link);
Indeed, this method accept a parameter for the $product to show, if you don't set it it will show the price for Mage::registry('current_product') aka the main product, just pass the upsold product as argument and you're ok.

Magento display grouped products special price

I am trying to figure out how I display the special price of a grouped product on the catalog page.
For example if i have 5 simple products attatched to my grouped product, how do I display the RRP for those products as well as the special price, on the catalog page?
At the moment it will display on the product page only and magento will fetch the lowest price it can find to display on the catalog page.
Any help is greatly appreciate!
If you're using the default theme, you'll have to modify:
app/design/frontend/base/default/template/catalog/product/list.phtml
You can add the prices you'll need like this by passing through the product:
<?php echo $this->getPriceHtml($_product, true) ?>

Resources