Tuesday, 21 October 2014

MAGENTO : ONEPAGE CHECKOUT SCROLLING ISSUE.

Here i found good fix of this issue.
Open opcheckout.js and find gotoSection function and replace this function as follow.

gotoSection: function(section)
{
    var sectionElement = $('opc-'+section);
    sectionElement.addClassName('allow');
    this.accordion.openSection('opc-'+section);
    this.reloadProgressBlock(section);
    jQuery("html, body").delay(10).animate({scrollTop: jQuery("#opc-"+section).offset().top }, 1000);
},

Friday, 30 May 2014

Set user permission & role in Custom module in magento

For set user permission & role in your custom module, you have to change your custom module's ect/config.xml file
 remove these type of code
        <acl>
          <resources>
            <all>
              <title>Allow Everything</title>
            </all>
            <admin>
              <children>
                <Namespace_Contactsdetail>
                  <title>Contactsdetail Module</title>
                  <sort_order>10</sort_order>
                </Namespace_Contactsdetail>
              </children>
            </admin>
          </resources>
        </acl>
Add below Code instead of it.

        <acl>
          <resources>
            <all>
              <title>Allow Everything</title>
            </all>
            <admin>
              <children>
                <system>
                  <children>
                    <config>
                      <children>
                        <contactsdetail translate="title" module="contactsdetail">
                          <title>Contactsdetail</title>
                        </contactsdetail>
                      </children>
                    </config>
                  </children>
                </system>
                <contactsdetail>
                  <title>contactsdetail Module</title>
                  <sort_order>10</sort_order>
                  <children>
                    <items>
                      <title>Contactsdetail</title>
                      <sort_order>3</sort_order>
                    </items>
                  </children>
                </contactsdetail>
              </children>
            </admin>
          </resources>
        </acl>

Monday, 28 October 2013

Add gift options in invoice pdf in Magento

for Add gift message to Magento’s PDF packingslip you have to modified invoice.php file in (\app\code\local\Mage\Sales\Model\Order\Pdf\Invoice.php)
it is a core file ao you have to move this file in local directory
 then find getPdf($invoices = array()) function in it

before   $this->_afterGetPdf();  this line add below code in it.

/*    Draw gift options*/
                $message = Mage::getModel('giftmessage/message');
                   $oid= $item->getOrderItemId();
                  $sales =  Mage::getModel('sales/order_item')->load($oid);
           
        $gift_message_id = $sales->getGiftMessageId();
        if(!is_null($gift_message_id)) {
              $message->load((int)$gift_message_id);
              $gift_sender = $message->getData('sender');
              $gift_recipient = $message->getData('recipient');
              $gift_message = $message->getData('message');

              $page->drawText(Mage::helper('sales')->__('Message from:'), 55, $this->y, 'UTF-8');
              $page->drawText(Mage::helper('sales')->__($gift_sender), 120, $this->y, 'UTF-8');
             $this->y -=10;
              $page->drawText(Mage::helper('sales')->__('Message to:'), 55, $this->y, 'UTF-8');
              $page->drawText(Mage::helper('sales')->__($gift_recipient), 120, $this->y, 'UTF-8');
             $this->y -=15;
              $page->drawText(Mage::helper('sales')->__('Message:'), 55, $this->y, 'UTF-8');
              $page->drawText(Mage::helper('sales')->__($gift_message), 120, $this->y, 'UTF-8');
             
             // $gift_message = wordwrap($gift_message, 140, "\n", false);
              /*$token = strtok($gift_message, "\n");
              $y = 740;
              while ($token != false) {
              if ($y < 60) {
              $pdf->pages[] = ($page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4));
              $page->setStyle($style);
              }
              else {
              $page->drawText($token, 40, $this->y);
              $this->y-=10;
              }
              $token = strtok("\n");
              }*/

            }
                  /*    Draw gift options end*/

Wednesday, 2 October 2013

delete existing order from invoice,shipment,credit memo.

http://www.magentocommerce.com/magento-connect/orders-eraser.html using of this extension you may delete order from sales > order> grid ,but if you want to delete same existing order id from invoice, shipment, creditmemo grid you have to customize little more in this extension.

For this you may change in function _erase2($orderId) in(\app\code\community\Wyomind\Orderseraser\Model\Orderseraser.php)
add below code:

$tablesfig = $resource->getTableName('sales_flat_invoice_grid');
$tablesfsg = $resource->getTableName('sales_flat_shipment_grid');
$tablesfcg = $resource->getTableName('sales_flat_creditmemo_grid');


$sql = "DELETE FROM " . $tablesfig . " WHERE order_id     = " . $orderId . ";";
$delete->query($sql);
$sql = "DELETE FROM " . $tablesfsg . " WHERE order_id     = " . $orderId . ";";
$delete->query($sql);
$sql = "DELETE FROM " . $tablesfcg . " WHERE order_id     = " . $orderId . ";";
$delete->query($sql);
      

magento summary rating of customers review in review list

put this code in(deault/default\template\review\product\view/list.phtml)
         <tbody>
                    <?php
                     $_percent = 0;
                    foreach ($_review->getRatingVotes() as $_vote){
                    $_percent = $_percent + $_vote->getPercent();
                    }
                      $_percent = $_percent / count($_review->getRatingVotes());?>
                    <tr>
                        <th class="label"><?php //echo $this->escapeHtml($_vote->getRatingCode()) ?>Aggregate rating:</th>
                        <td class="value">
                            <div class="rating-box">
                                <div class="rating" style="width:<?php echo  $_percent  ?>%;"></div>
                            </div>
                        </td>
                    </tr>
                    <?php //endforeach; ?>
                </tbody>


instead of

            <tbody>
                        <?php foreach ($_votes as $_vote): ?>
                        <tr>
                            <th><?php echo $this->escapeHtml($_vote->getRatingCode()) ?></th>
                            <td>
                                <div class="rating-box">
                                    <div class="rating" style="width:<?php echo $_vote->getPercent() ?>%;"></div>
                                </div>
                            </td>
                        </tr>
                        <?php endforeach; ?>
                    </tbody>


Friday, 20 September 2013

Get Order Details On Order Success-page

put the below code in frontend/default/default/template/checkout/success.phtml

<?php /* order detail on success page code starts here:- */ ?>
<?php $order = Mage::getModel('sales/order')->loadByIncrementId($this->getOrderId());
 $order_items = $order->getAllItems();
?>
<div class="success-box">
  <div class="successorderleft">
    <div class="content">
      <h4><?php echo $this->__('Your Confirmation Number is:') ?></h4>
      <p><?php echo $this->getOrderId();?></p>
      <p>Order Date: <?php echo  $this->formatDate($order->getCreatedAt(),'long') ;?></p>
    </div>
    <?php if($order->_data["shipping_description"]!=''){ ?>
    <div class="content">
      <h4><?php echo $this->__('Your Delivery type is:') ?></h4>
      <p><?php echo $shipping_method = $order->_data["shipping_description"];  ?></p>
    </div>
    <?php } ?>
    <div class="content">
      <h4><?php echo $this->__('And we&rsquo;ll deliver to:') ?></h4>
      <p><?php echo $order->getShippingAddress()->getFormated(true); ?></p>
    </div>
  </div>
  <div class="Successright">
    <div class="order-details-head"><?php echo $this->__('You Ordered:') ?></div>
    <table border="0" cellspacing="0" cellpadding="0" class="data-table">
      <thead>
        <tr class="first last">
          <th class="first" colspan="1"><?php echo $this->__('Product Name') ?></th>
          <th class="a-center" style="width:48px;"><?php echo $this->__('QTY') ?></th>
          <th class="a-right" style="width:102px;"><?php echo $this->__('Unit Price') ?></th>
        </tr>
      </thead>
      <tbody>
        <?php foreach($order_items as $_item):
        if ($_item->getParentItem()) continue;
       
        $product = Mage::getModel("catalog/product")->getIdBySku($_item->getSku());
        $product = Mage::getModel("catalog/product")->load($product);
    ?>
        <tr class="odd a-letf">
          <td><h2 class="product-name"><a href="<?php echo $product->getProductUrl() ?>">
              <?php  echo $this->htmlEscape($product->getName());?>
              </a> </h2>
            <?php
          if($_options = $_item->getProductOptions()):?>
            <dl class="item-options">
              <?php foreach ($_options['attributes_info'] as $_option) :  ?>
              <dt><?php echo $this->htmlEscape($_option['label']) ?></dt>
              <dd><?php echo $_option['value'] ?></dd>
              <?php endforeach; ?>
            </dl>
            <?php endif; ?></td>
          <td class="a-center" ><p class="Succqty"><?php echo abs($_item->getQtyOrdered()); ?></p></td>
          <td class="a-right" ><?php echo Mage::helper('checkout')->formatPrice($this->helper('checkout')->getSubtotalInclTax($_item)) ?></td>
        </tr>
        <?php endforeach; ?>
      </tbody>
    </table>
    <table cellpadding="0" cellspacing="0" background="0" class="Successtabletotal">
      <tr>
        <td colspan="2" class="a-right success-subtotal"><?php echo $this->__('Subtotal:'); ?></td>
        <td class="a-right success-subtotal" style="width:102px;"><?php echo Mage::helper('checkout')->formatPrice($order->getSubtotal());?></td>
      </tr>
      <?php if($order->getCouponCode()!=""){?>
      <tr>
        <td colspan="2" class="a-right success-subtotal"><?php echo $this->__('Discount('.$order->getCouponCode().')'); ?></td>
        <td class="a-right success-subtotal" style="width:102px;"><?php echo Mage::helper("core")->currency($order->discount_amount) ;?></td>
      </tr>
      <?php }?>
      <tr>
        <td colspan="2" class="a-right success-shipping"><?php echo $this->__('Shipping:'); ?></td>
        <td class="a-right success-shipping" style="width:102px;"><?php echo Mage::helper('checkout')->formatPrice($order->getShippingAmount());?></td>
      </tr>
      <tr>
        <td colspan="2" class="a-right success-tax"><?php echo $this->__('Tax:'); ?></td>
        <td class="a-right success-tax" style="width:102px;"><?php echo Mage::helper('checkout')->formatPrice($order->getTaxAmount());?></td>
      </tr>
      <tr>
        <td colspan="2" class="a-right success-total"><?php echo $this->__('Total:'); ?></td>
        <td class="a-right success-total" style="width:102px;"><?php echo Mage::helper('checkout')->formatPrice($order->getGrandTotal());?></td>
      </tr>
    </table>
  </div>
</div>
<?php /* order detail on success page code end here:- */ ?>