I am trying to skip the shipping method step on the One Page checkout on magento 1.9.1 . I have got the module to function and skip/hide the step as this is not needed. I have enabled the method selection on the cart page.
What my problem is that my checkout has 4 steps:
- Billing Info
- Shipping Info
- Payment Info
- Order review
The problem i am having is that after the customer enters his billing info and clicks use billing address for shipping he is moved on to step 3. However the progress icons do not change to completed state for Step 2 which he has skipped. If for example he decides he wants to ship to different address at step one and moves to step 2 then this changes the state to active and then completed when moved to step 3.
I can not work out how i can resolve this. Please help with your expertise. The module file details are below. I know this is due to this module as when i add it the progress does not change. However when not active i have the steps working fine. Hope you guys can help. Thanks
config.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<JMAWD_Checkout>
<version>0.0.2</version>
</JMAWD_Checkout>
</modules>
<global>
<models>
<checkout>
<rewrite>
<type_onepage>JMAWD_Checkout_Model_Type_Onepage</type_onepage>
</rewrite>
</checkout>
</models>
<blocks>
<checkout>
<rewrite>
<onepage_shipping_method>JMAWD_Checkout_Block_Onepage_Shipping_Method</onepage_shipping_method>
</rewrite>
</checkout>
</blocks>
</global>
<frontend>
<routers>
<checkout>
<args>
<modules>
<checkoutjmawd before="Mage_Checkout">JMAWD_Checkout</checkoutjmawd>
</modules>
</args>
</checkout>
</routers>
</frontend>
</config>
OnepageController.php
class JMAWD_Checkout_OnepageController extends Mage_Checkout_OnepageController
{
public function saveShippingAction()
{
if ($this->_expireAjax()) {
return;
}
if ($this->getRequest()->isPost()) {
$data = $this->getRequest()->getPost('shipping', array());
$customerAddressId = $this->getRequest()->getPost('shipping_address_id', false);
$result = $this->getOnepage()->saveShipping($data, $customerAddressId);
if (!isset($result['error'])) {
$result['goto_section'] = 'payment';
$result['update_section'] = array(
'name' => 'payment-method',
'html' => $this->_getPaymentMethodsHtml()
);
}
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
}
}
public function saveBillingAction()
{
if ($this->_expireAjax()) {
return;
}
if ($this->getRequest()->isPost()) {
$data = $this->getRequest()->getPost('billing', array());
$customerAddressId = $this->getRequest()->getPost('billing_address_id', false);
$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'] = 'payment';
$result['update_section'] = array(
'name' => 'payment-method',
'html' => $this->_getPaymentMethodsHtml()
);
}
else {
$result['goto_section'] = 'shipping';
}
} $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
}
}
}
Onepage.php in the /Model/Type Folder
<?php
class JMAWD_Checkout_Model_Type_Onepage extends Mage_Checkout_Model_Type_Onepage
{
protected function validateOrder()
{
$helper = Mage::helper('checkout');
if ($this->getQuote()->getIsMultiShipping()) {
Mage::throwException($helper->__('Invalid checkout type.'));
}
$addressValidation = $this->getQuote()->getBillingAddress()->validate();
if ($addressValidation !== true) {
Mage::throwException($helper->__('Please check billing address information.'));
}
if (!($this->getQuote()->getPayment()->getMethod())) {
Mage::throwException($helper->__('Please select valid payment method.'));
}
}
}
Method.php from the /Block/Onepage/Shipping Folder
<?php
class JMAWD_Checkout_Block_Onepage_Shipping_Method extends Mage_Checkout_Block_Onepage_Shipping_Method
{
public function isShow()
{
return false;
}
}
And finally the module xml file
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<JMAWD_Checkout>
<active>true</active>
<codePool>local</codePool>
</JMAWD_Checkout>
</modules>
</config>