Creating Invoice programmatically

If you placed order using Purchase Order there is no Invoice created in backend
you can crate invoice programmatically in success.phtml with code below
add it at the bottom of success.phtml
(can be updated for any other payment method etc.)

<?php 
$order = new Mage_Sales_Model_Order();
 $order_id = $this->escapeHtml($this->getOrderId()) ;
$order->loadByIncrementId($order_id);

 $payment_method = $order->getPayment()->getMethodInstance()->getCode();

 if($payment_method=='purchaseorder'){
 
    if ($order->getState() == Mage_Sales_Model_Order::STATE_NEW) {
 
            try {
                if(!$order->canInvoice()) {
                    $order->addStatusHistoryComment('PO Order cannot be invoiced .', false);
                    $order->save();  
                }
 
                //START Handle Invoice
                $invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
 
                $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_OFFLINE);
                $invoice->register();
 
                $invoice->getOrder()->setCustomerNoteNotify(false);          
                $invoice->getOrder()->setIsInProcess(true);
                $order->addStatusHistoryComment('Automatically INVOICED PO.', false);
 
                $transactionSave = Mage::getModel('core/resource_transaction')
                    ->addObject($invoice)
                    ->addObject($invoice->getOrder());
 
                $transactionSave->save();
                //END Handle Invoice
 
               
            } catch (Exception $e) {
                $order->addStatusHistoryComment('PO: Exception occurred during automatically Invoice PO Order action. Exception message: '.$e->getMessage(), false);
                $order->save();
            }                
        }       
        }  
?>

Add Next – Previous buttons for product listing- product view

this script will add two buttons on product view …view.phtml
if you want see previous or next product from the same category

you can add this script on product view

<?php // Previous and Next product links in product page
 
$_product = $this->getProduct();
 
if(!$_product->getCategoryIds())
return; // Don't show Previous and Next if product is not in any category
 
$cat_ids = $_product->getCategoryIds(); // get all categories where the product is located
$cat = Mage::getModel('catalog/category')->load( $cat_ids[0] ); // load first category, you should enhance this, it works for me
 
$order = Mage::getStoreConfig('catalog/frontend/default_sort_by');
$direction = 'asc'; // asc or desc
 
$category_products = $cat->getProductCollection()->addAttributeToSort($order, $direction);
$category_products->addAttributeToFilter('status',1); // 1 or 2
$category_products->addAttributeToFilter('visibility',4); // 1.2.3.4
 
$cat_prod_ids = $category_products->getAllIds(); // get all products from the category
$_product_id = $_product->getId();
 
$_pos = array_search($_product_id, $cat_prod_ids); // get position of current product
$_next_pos = $_pos+1;
$_prev_pos = $_pos-1;
 
// get the next product url
if( isset($cat_prod_ids[$_next_pos]) ) {
$_next_prod = Mage::getModel('catalog/product')->load( $cat_prod_ids[$_next_pos] );
} else {
$_next_prod = Mage::getModel('catalog/product')->load( reset($cat_prod_ids) );
}
// get the previous product url
if( isset($cat_prod_ids[$_prev_pos]) ) {
$_prev_prod = Mage::getModel('catalog/product')->load( $cat_prod_ids[$_prev_pos] );
} else {
$_prev_prod = Mage::getModel('catalog/product')->load( end($cat_prod_ids) );
}
?>
 
<div>
<?php if($_prev_prod != NULL): ?>
<a href="<?php print $_prev_prod->getUrlPath(); if($search_parameter):?>?search=1<?php endif;?>"><span><?php echo $this->__('PREVIOUS PRODUCT') ?></span></a>
<?php endif; ?>
||
<?php if($_next_prod != NULL): ?>
<a href="<?php print $_next_prod->getUrlPath(); if($search_parameter):?>?search=1<?php endif;?>"><span><?php echo $this->__('NEXT PRODUCT') ?></span></a>
<?php endif; ?>
</div>

Qty dropdown in cart (Qtys come from tier prices)

If product has tier prices we can create dropdown in cart .. otherwise there will be standart QTY box

first update default.phtml … in chcekout/cart/item/default.phtml .. with code below

<?php
    $ID = $_item->getProductId();
   
     $_product =  Mage::getModel('catalog/product')->load($ID);

     $prices = $_product->getTierPrice();
     if($prices!=NULL){ 
              echo '<select id="selectqty" onchange="getNewVal(this);" style="margin-top:13px;border:1px solid;height:30px;">';
              echo ' <option value="'.$this->getQty().'">'.$this->getQty().'</option>';
            foreach($prices as $tier){
                  // echo intval($tier[price_qty]).'<br/>';
                   echo '<option value="'.intval($tier[price_qty]).'_'.$_item->getId().'">'.intval($tier[price_qty]).'</option>';
             } 
      echo '</select>';
      ?>
       <input style="visibility:hidden;" type="text" id="<?php echo $_item->getId() ?>_QTY" name="cart[<?php echo $_item->getId() ?>][qty]" value="<?php echo $this->getQty() ?>" 
         size="4" title="<?php echo $this->__('Qty') ?>" class="input-text input-block-level qty" maxlength="12" />
          <?php
             }else{
            ?>
        <input type="text" id="<?php echo $_item->getId() ?>_QTY" name="cart[<?php echo $_item->getId() ?>][qty]" value="<?php echo $this->getQty() ?>" 
         size="4" title="<?php echo $this->__('Qty') ?>" class="input-text input-block-level qty" maxlength="12" /> 
             <?php 
                }
            ?>

and at the bottom add this

next.. update cart.phtml in checkout/cart.phtml

find button “Update Shopping Cart” and add id=”update_cart”

 <button type="submit" id="update_cart" name="update_cart_action" value="update_qty" title="<?php echo $this->__('Update Shopping Cart'); ?>" 
    class="btn btn-link update"><i class="fa fa-rotate-right"></i> <?php echo $this->__('Update Shopping Cart'); ?></button>