Durante lo sviluppo di un noto sito di e-commerce ho sentito la necessità di inserire il tasto Preordina. Ecco come fare in pochi e semplici passaggi.
Innanzitutto aprite app/design/frontend/yourpackage/yourtheme/template/catalog/product/list.phtml
Cercate:
1
|
<?php $_productCollection = $this ->getLoadedProductCollection() ?> |
Aggiungete sotto:
1
2
|
<?php $addtocart = $this ->__( 'Add to Cart' ); ?> <?php $preorder = $this ->__( 'Preordina' ); ?> |
Cercate:
1
|
<p><button type= "button" title= "<?php echo $this->__('Add to Cart') ?>" class = "button btn-cart" onclick= "setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')" ><span><span><?php echo $this ->__( 'Add to Cart' ) ?></span></span></button></p> |
Sostituite con
1
|
<p><button type= "button" title= "<?php if(Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty()>0): echo $addtocart; else: echo $preorder; endif; ?>" class = "button btn-cart" onclick= "setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')" ><span><span><?php if (Mage::getModel( 'cataloginventory/stock_item' )->loadByProduct( $_product )->getQty()>0): echo $addtocart ; else : echo $preorder ; endif ; ?></span></span></button></p><br><br> |
Cercate:
1
|
<button type= "button" title= "<?php echo $this->__('Add to Cart') ?>" class = "button btn-cart" onclick= "setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')" ><span><span><?php echo $this ->__( 'Add to Cart' ) ?></span></span></button> |
Sostituite con:
1
|
<button type= "button" title= "<?php if(Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty()>0): echo $addtocart; else: echo $preorder; endif; ?>" class = "button btn-cart" onclick= "setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')" ><span><span><?php if (Mage::getModel( 'cataloginventory/stock_item' )->loadByProduct( $_product )->getQty()>0): echo $addtocart ; else : echo $preorder ; endif ; ?></span></span></button><br> |
Aprite app/design/frontend/yourpackage/yourtheme/template/catalog/product/view/addtocart.phtml
Cercate:
1
|
<?php $_product = $this ->getProduct(); ?> |
Aggiungete in basso:
1
2
|
<?php $addtocart = $this ->__( 'Add to Cart' ); ?> <?php $preorder = $this ->__( 'Preordina' ); ?> |
Cercate:
1
|
<button type= "button" title= "<?php echo $buttonTitle ?>" class = "button btn-cart" onclick= "productAddToCartForm.submit(this)" ><span><span><?php echo $buttonTitle ?></span></span></button> |
Sostituite con:
1
|
<button type= "button" title= "<?php if($_product->getStockItem()->getQty()>0): echo $addtocart; |
Non vi resta che salvare il tutto e provare. Il test è stato effettuato con Magento 1.7.0.2