Showing posts with label Magento. Show all posts
Showing posts with label Magento. Show all posts

Thursday, 3 September 2015

Generate (create) automatically invoice after the orders are shipped

Create module config file : app\etc\modules\Nik_Autoinvoice.xml
<config>
    <modules>
        <Nik_Autoinvoice>
            <active>true</active>
            <codePool>local</codePool>
        </Nik_Autoinvoice>
    </modules>
</config>
I'd go the creating an event observer for sales_order_shipment_save_after:

File path: app/code/local/Nik/Autoinvoice/etc/config.xml 
<?xml version="1.0"?>
<config>
    <modules>
        <Nik_Autoinvoice>
            <version>0.1.0</version>
        </Nik_Autoinvoice>
    </modules>
    <global>
        <events>
            <sales_order_shipment_save_after>
                <observers>
                    <nik_autoinvoice>
                        <type>singleton</type>
                        <class>Nik_Autoinvoice_Model_Observer</class>
                        <method>autoInvoice</method>
                    </nik_autoinvoice>
                </observers>
            </sales_order_shipment_save_after>
        </events>
    </global>
</config>
Now, we create one observer file : 
app\code\local\Nik\Autoinvoice\Model\Observer.php 
<?php
class Nik_Autoinvoice_Model_Observer
{
 public function autoInvoice($observer) {
 $shipment = $observer->getEvent()->getShipment();
 $order = $shipment->getOrder();
 if($order->canInvoice())
 {
 $invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
 $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
 $invoice->register();
 $transactionSave = Mage::getModel('core/resource_transaction')
 ->addObject($invoice)
 ->addObject($invoice->getOrder());
 $transactionSave->save();
 }
 }
}

Wednesday, 2 September 2015

product price display with tax in product listing in Magento



Follow the steps to achieve this.

1. Sign in to Magento Admin Panel
2. Go to System > Configuration
3. Click on ‘Tax’ listed under Sales
4. Go to ‘Calculation’ and set ‘tax based on’ to ‘Shipping Origin’
5. Go to ‘Display’ and set ‘Display Cart/Order Prices’ to ‘including and excluding tax’
6. Go to ‘Display’ and set ‘Display Product Prices’ to ‘including and excluding tax’
7. Save the Configuration

Magento upgrade 1.7 to 1.8, ‘Place Order’ button does not work



Replace the base file the following path
app/design/frontend/default/your_theme/template/checkout/onepage/review/info.phtml 

 OR

Replace the line number 81 in info.phtml
review = new Review(’<?php echo $this->getUrl('checkout/onepage/saveOrder', array('form_key' => Mage::getSingleton('core/session')->getFormKey())) ?>’, ‘<?php echo $this->getUrl('checkout/onepage/success') ?>’, $(’checkout-agreements’));

add custom field in newsletter module Magento



Step 1 : Open file: root/app/design/frontend/your-package-name/your-theme/template/newsletter/subscribe.phtml

Add input field for ‘Name’ before ‘Email’ Field :
<input type="text" name="subscriber_name" id="subscriber_name" title="<?php echo $this->__('Name') ?>" />

Step 2 : Open file:  root/app/code/core/Mage/Newsletter/controllers/SubscriberController.php
A. Search:
$status = Mage::getModel('newsletter/subscriber')->subscribe($email);
Replace with:
if ($this->getRequest()->getPost('subscriber_name'))
{
$subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
$subscriber_name     = (string) $this->getRequest()->getPost('subscriber_name');
$subscriber->setsubscriber_name($subscriber_name);
}
$status = Mage::getModel('newsletter/subscriber')->subscribe($email,$subscriber_name);

Step 3 : Open file : root/app/code/core/Mage/Newsletter/Model/Subscriber.php
A. Search:
public function subscribe($email)
Replace with:
public function subscribe($email,$subscriber_name=null)
B. Search:
$this->setSubscriberEmail($email);
Add after it:
$this->setsubscriber_name($subscriber_name);
C. Search:
public function setEmail($value)
{
return $this->setSubscriberEmail($value);
}
Add after it:
public function setsubscriber_name($value)
{
return $this->setSubscriberName($value);
}

Step 4 : Open file : root/app/code/core/Mage/Adminhtml/Block/Newsletter/Subscriber/Grid.php
A. Search:
$this->addColumn('email', array(
'header'    => Mage::helper('newsletter')->__('Email'),
'index'     => 'subscriber_email'
));
Add before it:
$this->addColumn('subscriber_name', array(
'header'    => Mage::helper('newsletter')->__('Subscriber Name'),
'index'     => 'subscriber_name',
'default'   =>    '----'
));

Step 5 : Open your database.
Create a field ‘subscriber_name’ in table “Newsletter Subscriber”.

Step 6 : Clear the caches

Product (Item) Total Price Change the Option to show in Magento



Sol : You need to modify Abstact.PHP file.. It is located at app/code/core/Mage/Catalog/Block/Product/View/Options/Abstract.php
        $_priceInclTax = $this->getPrice($value['pricing_value'], true);
        $_priceExclTax = $this->getPrice($value['pricing_value']);

 Replace above code below code

        $_priceInclTax = $this->getPrice($value['pricing_value'], true)+$this->getProduct()->getFinalPrice();
        $_priceExclTax = $this->getPrice($value['pricing_value'])+$this->getProduct()->getFinalPrice();