0
votes

Thank you in advance for any help (I first post my question here, but there is no reply for several days).

In Magento, I am looking to change "Add to cart" button to "Pre-order" button for configurable products which inventory qty is set to 0.

Using this tutorial, I managed to accomplish what I am looking for but as it seems this solution works for simple products only, not for configurable ones (or I missed something)

I looked this post, where a person says that SCP Simple Configurable Product extension made by Organic Internet solved his issue. I am not sure how it helped him. I have this extension installed on my site. It seems that there is no option for changing button from "add to cart" to "pre-order" or anything like that. Perhaps I miss something.

Can anyone give me a hand in solving this issue or point me in the right direction?

3

3 Answers

1
votes

The tutorial has a php condition which is looking for the Qty value. The problem is, with configurable products, you need to load the associated simple products in order to pull the Qty values.

Suggestion: have you tried using issaleable? This would only show the "Pre-Order" button if the product is NOT saleable.

<?php if( $_product->isSaleable() ): echo $addtocart; else: echo $preorder; endif; ?>

If you simple want ALL your configurable products to have the "Pre-Order" button regardless of inventory, one solution is to modify this Qty condition to only check if its a Configurable product or not instead. One way is to change all occurrences of this:

<?php if($_product->getStockItem()->getQty()>0): echo $addtocart; else: echo $preorder; endif; ?>

to this:

<?php if( $_product->getTypeId() == 'configurable' ): echo $preorder; else: echo $addtocart; endif; ?>

Here's an example of loading the associated simple products, in order to get the Qty values. This may not be needed since its more complex.

foreach ($_product->getTypeInstance(true)->getUsedProducts ( null, $_product) as $simple) {
     Mage::getModel('cataloginventory/stock_item')->loadByProduct($simple)->getQty();
 }
0
votes

inside your pordut/list.phtml , try checking the product type as shown

<?php if( $_product->getTypeId() == 'configurable' ): ?>
0
votes

First of all go to app/design/frontend/[your-package]/[your-theme]/template/catalog/product/view/addtocart.phtml. There you can code like:

<?php if($_product ->getTypeId() == 'configurable'): ?>
//Do your part

All the best