Wednesday, June 1, 2011

skip shipping method from onepage checkout :=>In Magento

skip shipping method from onepage checkout :=>In Magento

step 1: app/code/core/Mage/Checkout/Block/Onepage/Onepage.php

change the line
$stepCodes = array('billing', 'shipping', 'shipping_method', 'payment', 'review');
with
$stepCodes = array('billing', 'payment', 'review');

step2 : app/code/core/mage/checkout/controller/Onepagecontrollers.php

protected $_sectionUpdateFunctions = array(
'payment-method' => '_getPaymentMethodsHtml',
'shpping-method' => '_getShippingMeghtoHtml',
'review' => '_getReviewHtml',
);

to

protected $_sectionUpdateFunctions = array(
'payment-method' => '_getPaymentMethodsHtml',
'review' => '_getReviewHtml',
);


Step 3. In same page

------------------------Change this code--------------------------
public function saveBillingAction()
{
if ($this->_expireAjax()) {
return;
}
if ($this->getRequest()->isPost()) {
$postData = $this->getRequest()->getPost('billing', array());
$data = $this->_filterPostData($postData);
$customerAddressId = $this->getRequest()->getPost('billing_address_id', false);

if (isset($data['email'])) {
$data['email'] = trim($data['email']);
}
$result = $this->getOnepage()->saveBilling($data, $customerAddressId);

if (!isset($result['error'])) {
/* check quote for virtual */
if ($this->getOnepage()->getQuote()->isVirtual()) {
$result['goto_section'] = 'payment';
$result['update_section'] = array(
'name' => 'payment-method',
'html' => $this->_getPaymentMethodsHtml()
);
} elseif (isset($data['use_for_shipping']) && $data['use_for_shipping'] == 1) {
$result['goto_section'] = 'shipping_method';
$result['update_section'] = array(
'name' => 'shipping-method',
'html' => $this->_getShippingMethodsHtml()
);

$result['allow_sections'] = array('shipping');
$result['duplicateBillingInfo'] = 'true';
} else {
$result['goto_section'] = 'shipping';
}
}

$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
}
}
-----------------------With-----------------------
public function saveBillingAction()
{
if ($this->_expireAjax()) {
return;
}
if ($this->getRequest()->isPost()) {
$postData = $this->getRequest()->getPost('billing', array());
$data = $this->_filterPostData($postData);
$customerAddressId = $this->getRequest()->getPost('billing_address_id', false);

if (isset($data['email'])) {
$data['email'] = trim($data['email']);
}
$result = $this->getOnepage()->saveBilling($data, $customerAddressId);

if (!isset($result['error'])) {
/* check quote for virtual */
if ($this->getOnepage()->getQuote()->isVirtual()) {
$result['goto_section'] = 'payment';
$result['update_section'] = array(
'name' => 'payment-method',
'html' => $this->_getPaymentMethodsHtml()
);
} else {
$result['goto_section'] = 'payment';
}
}

$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
}
}



Step 4. app/code/core/Mage/Sales/Model/Service/Quote.php

-------------------------Change this code ----------------
protected function _validate()
{
$helper = Mage::helper('sales');
if (!$this->getQuote()->isVirtual()) {
$address = $this->getQuote()->getShippingAddress();
$addressValidation = $address->validate();
if ($addressValidation !== true) {
Mage::throwException(
$helper->__('Please check shipping address information. %s', implode(' ', $addressValidation))
);
}
$method= $address->getShippingMethod();
$rate = $address->getShippingRateByCode($method);*/
if (!$this->getQuote()->isVirtual() && (!$method || !$rate)) {
Mage::throwException($helper->__('Please specify a shipping method.'));
}
}


---------------------------With------------------------
protected function _validate()
{
$helper = Mage::helper('sales');
if (!$this->getQuote()->isVirtual()) {
$address = $this->getQuote()->getShippingAddress();
$addressValidation = $address->validate();
}



Step: 5. app/design/frontend/base/default/template/checkout/onepage/billing.phtml

remove the code of radio button : line no 173

Step: 6. app/design/frontend/base/default/template/checkout/onepage/progress.phtml
remove the code for hide shipping method block: Your Checkout Progress

Step: 7.

Change Order tamplate which you have created
OR
Change from here:
app/locale/en_US/template/email/sales/order_new.html

Remove following code:















Shipping Information: Shipping Method:

{{var order.getShippingAddress().format('html')}}
 
 
{{var order.getShippingDescription()}}
 


>>>>>>>>>>>>>>>>>>OR<<<<<<<<<<<<<<<<<<<<<<<<<
Refer Following url:
http://www.magentocommerce.com/boards/viewthread/76049/


Thanks

6 comments:

  1. This is awesome. i try more for removing shipping method but finally read this article and i got solution thanks again.

    Thanks

    ReplyDelete
  2. Hey man, nice work with shipping. Can you write here how to skip payment too?

    Thanks

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. i want to merge shipping method an payment information as a single step both thing should be visible in single step and when i click on the continue button then both values shoul get saved same as earlier it was happening.
    i appreciate your help pls help me out with this
    thanks in advance

    ReplyDelete
  5. It is such an interesting thing having this post of yours. I was interested with the topic as well as the flow of the story. Keep up doing this. magento one step checkout

    ReplyDelete
  6. this is provide the best aspect of choosing the Hire Magento Programmer from Indian native market is flexible and it also offers to choose the best of the Magento designers.
    Hire Magento Developers

    ReplyDelete