cancel
Showing results for 
Search instead for 
Did you mean: 

Price of Bundled Product with Out of Stock bundle item is $0

Price of Bundled Product with Out of Stock bundle item is $0

My site is set to display out of stock products with their prices still showing and a message "out of stock".

 

For bundled products, if one of the required items is "out of stock", the bundled product is also "out of stock", which makes sense.

 

However, if there's only one required item in the bundle that's out of stock, the price that displays for the bundled product is "$0".

 

The display price is controlled in /bundle/catalog/product/price.phtml, and apparently the price that displays for the bundled product is the "minimum required price", which normally would be the price of the one required item.  But since the required item is out of stock, the required item's price information can't be pulled back, and so the price that gets displayed is $0.

 

Here is example code I have tried to run to get the required item price information.  Basically it makes a function call for the bundled items and echoes their prices.  Unfortunately, it pulls all of the items in the bundle except for the required item, seemingly because it is out of stock.

 

$selectionCollection = $_product->getTypeInstance(true)->getSelectionsCollection($_product->getTypeInstance(true)->getOptionsIds($_product), $_product);
$bundled_items = array();
foreach($selectionCollection as $option)
{
        $bundled_items[] = $option->product_id;
       echo $option->getPrice()."<br>";
}

My ultimate question is if there's a way to get the correct minimal price to display again for these bundled products.  Any help is greatly appreciated, thank you very much.

2 REPLIES 2

Re: Price of Bundled Product with Out of Stock bundle item is $0

Hi @Testerossah,

 

You can do something like this:

  1. Get all sub product IDs of the bundle product
  2. Get the prices of all product into an array
  3. Find the smallest price and display that.

 

You need to do custom coding in this way.

Was my answer helpful? You can accept it as a solution.
175+ Professional Extensions for M1 & M2
Need a developer?Just visit Contact Us Now

Re: Price of Bundled Product with Out of Stock bundle item is $0

Hello theMageComp, and thank you for the reply.  Unfortunately, I had actually previously tried the approach you mentioned, but it has an inherent problem --- not all of the items in a bundle may be required, which means that the lowest priced item might not actually represent the minimum price.  I more specifically have to be able to find the lowest priced item that's required, which is a little trickier.  Do you have any thoughts on a way that can be figured out?  The objects in the price.phtml file that I've investigated so far don't seem to be able to tell me the product ids of all the items in the bundle (both in and out-of stock) and whether or not they're required.