Call-back icon  Sales: Call 877.832.5289 (N America)|310.295.4144 (International)

Magento

eCommerce Software for Online Growth

Magento Forum

   
Page 2 of 2
“Onepage” checkout - adding a step
 
tony-fav
Jr. Member
 
Total Posts:  11
Joined:  2008-06-11
France
 

hi nafnaf

it’s possible to remove or add a step to onepage checkout, but as you’ve seen, it’s not easy because steps are linked between them, so you must study php and js files and take some hours to success

(sorry for my bad english rasberry)

for the shipping method, i think you can insert a test in template/checkout/onepage/shipping_method.phtml after have identified the good shipping method id in database
hope that helps a bit

 
Magento Community Magento Community
Magento Community
Magento Community
 
nafnaf1000
Sr. Member
 
Total Posts:  119
Joined:  2008-02-21
 

@tony-fav

Thanks for the reply.

O well, it is a shame it is such a bother to do simple things. :(

 
Magento Community Magento Community
Magento Community
Magento Community
 
Georg Ringer
Member
 
Avatar
Total Posts:  59
Joined:  2008-07-04
Linz, Austria
 

any updates at this topic? anyone achieved adding a step and saving information?

thx a lot!
georg

 
Magento Community Magento Community
Magento Community
Magento Community
 
Georg Ringer
Member
 
Avatar
Total Posts:  59
Joined:  2008-07-04
Linz, Austria
 

Hi,

i did it now myself and this is who it goes:
/app/code/core/Mage/Checkout/Block/Onepage.php: Add the code, in my case “coupon”

$stepCodes = array('billing''coupon''shipping''shipping_method''payment''review');

/app/code/core/Mage/Checkout/Block/Onepage/Coupon.php

class Mage_Checkout_Block_Onepage_Coupon extends Mage_Checkout_Block_Onepage_Abstract
{
    
protected function _construct()
    
{
        $this
->getCheckout()->setStepData('coupon', array(
            
'label'     => Mage::helper('checkout')->__('Coupon Information'),
            
'is_show'   => $this->isShow()
        ));

        
parent::_construct();
    
}

    
public function getMethod()
    
{
        
return $this->getQuote()->getCheckoutMethod();
    
}
}

/app/design/frontend/default/<theme>/template/checkout/onepage/coupon.phtml
create a template, like billing.phtml

/app/code/core/Mage/Checkout/Block/Onepage/Progress.php Don’t know if needed but add

public function getCoupon()
    
{
        
return $this->getQuote()->getShippingAddress();
    
}

/app/code/core/Mage/Checkout/controllers/OnepageController.php
It is imporant to set in one step the goto_section to “coupon” to get there… additionally you need a new function to save or at least go to the next step

public function saveCouponAction()
    
{
        $this
->_expireAjax();
        if (
$this->getRequest()->isPost()) {
            $result[
'goto_section''shipping_method';
            
$this->getResponse()->setBody(Zend_Json::encode($result));
            
        
}

    }

/app/design/frontend/default/cyberhouse/layout/checkout.xml
add

<block type="checkout/onepage_coupon" name="checkout.onepage.coupon" as="coupon" template="checkout/onepage/coupon.phtml"/>

/app/code/core/Mage/Checkout/Model/Type/Onepage.php Dont know if needed

public function saveCoupon($data$customerAddressId)
    
{

        $this
->getCheckout()
            ->
setStepData('coupon''allow'true)
            ->
setStepData('coupon''complete'true)
            ->
setStepData('shipping_method''allow'true);

        return array();
    
}

/skin/frontend/default/<theme>/js/opcheckout.js
tricky part: I copied the Billing class and renamed it to Coupon. Still i got some troubles and so I did in coupon.phtml

<button class="form-button right" onclick="checkout.accordion.openNextSection(true); return false;"><span><?php echo $this->__('Continue'?></span></button>
to load the next step

I hope it helps!

 
Magento Community Magento Community
Magento Community
Magento Community
 
meph137
Jr. Member
 
Total Posts:  25
Joined:  2008-09-08
 

I’ll chuck my lot in here, right now I don’t have time to edit my noets, but feel free to read them unedited! This is me adding the ability to add a delivery date step to the onepage checkout, these are my condensed notes, if you want the full ones feel free to PM me.

By the way, this isn’t code, but I use notepad for note taking so I’m using the code view to preformat my text…

Also, this doesn’t update the right hand “progress” box yet…

core/Mage/Checkout/Block/Onepage.php
-- add your step into the $stepCodes array

core/Mage/Checkout/Block/Onepage/Deliverydate.php
-- Copy Billing.php as a base, and remove all methods except for _construct()
-- 
Change setStepDatachanging billing to deliverydate

template/checkout/onepage/deliverydate.phtml
-- Copied billing.phtmlremove the fat and rename billing to deliverydate
-- Add an input with name and id delivery_date

layout/checkout.xml
-- I added this noderight after the onepage_shipping node:
   <
block type="checkout/onepage_deliverydate" name="checkout.onepage.deliverydate" as="deliverydate"
    
template="checkout/onepage/deliverydate.phtml"/>

core/Mage/Checkout/controllers/Onepage.php
-- Add a method saveDeliverydateAction(), copy it from saveShippingMethodAction(), do this to it:
--- 
Mage::dispatchEvent('checkout_controller_onepage_save_shipping_method'...(etc)
--- 
$this->getResponse()->setBody(Zend_Json::encode($result))
-- 
Change the getpost and result lines:
--- 
$data $this->getRequest()->getPost('delivery_date''');
--- 
$result $this->getOnepage()->saveDeliverydate($data);

core/Mage/Checkout/Model/Type/Onepage.php
-- Add a method saveDeliverydate(), copy it from saveShippingMethod(), do this to it:
--- 
change the argument from $shippingMethod to $data, do this throughout function
--- 
get rid of these lines
---- $rate = ..(etc)
---- 
the entire if ($!ratestatement
---- $this->getQuote()->getShippingAddress()->setShippingMethod($shippingMethod);
--- 
Change $this->getQuote()->collectTotals()->save(); to $this->getQuote()->save();
--- 
Add this linebelow the if(empty($dataconditional:
---- 
$this->getQuote()->getShippingAddress()->setDelivery_date($data);
--- 
Change the $this->getCheckout() part to:
---- ->
setStepData('deliverydate''complete'true)->setStepData('shipping_method''allow'true);

js/opcheckout.js
-- Add your step to this.steps (inside Checkout.prototype)
-- 
create setDeliverydate() (inside Checkout.prototype), copy from setShipping()
-- 
Alter any gotoSection()'s from 'shipping_method' to 'deliverydate' (should be in setBilling() & setShipping())
-- Create Deliverydate() in the root, copy from ShippingMethod(), make changes:
--- change save()'
s checkout.setLoadWaiting to ('deliverydate');
--- 
I commented out the calidationkeep it or not...
--- 
I copied nextStep() from Shippingit seemed more genericthen I changed checkout.setStepResponse(response); to
    checkout
.setDeliverydate();

 
Magento Community Magento Community
Magento Community
Magento Community
 
emkay
Jr. Member
 
Total Posts:  2
Joined:  2008-10-22
 

Hi. I’m pretty new to magento, but am attempting to add a step to checkout. I almost have it completed and working and will outline the steps that I took to get to that point.

1. Figure out what the step involves adding and name them. I tried to keep the name consistent, it’s important because of the __call magic method that magento uses to set properties.

2. Add each one of the attributes to magento_eav_attributes. You are going to have to figure out what entity type it is you are adding. What I did was picked one of the payment ones and copied most of it changing the little data that I needed.

3. Create new columns for each of the attributes in the magento_sales_flat_quote, or other appropriate flat table. Keep the names consistent.

4. Add the fields to the array in Sales/Model/Entity/Setup.php. (Not really sure where I’m trying to shoehorn them into quote and orders).

5. Add fields to array in Sales/Model/Mysql4/Setup.php. (Again not really sure about this step).

6. Add to Sales/etc/config.xml.

7. Override the controller. There are other forum posts on here explaining how to override a controller. Following them worked for me. The important thing to remember is that you can’t just throw controllers in the local directory to override them. I didn’t have too much trouble with this step. You have to extend Mage_Checkout_OnepageController and add a method saveStepnameAction(). If you look at the other examples such as billing and shipping it should help out.

8. Make a new local Checkout Block.
This is a php file that you will create in /code/local/Mage/Checkout/Block/Onepage/. You need to write a class that extends Mage_Checkout_Block_Onepage_Abstract.

class Mage_Checkout_Block_Onepage_Stepname extends Mage_Checkout_Block_Onepage_Abstract {
 
public function __construct() {
        $this
->getCheckout()->setStepData('stepname', array(
            
'label' => 'Step label'
            
'is_show' => $this->isShow())
        );
        
parent::__construct();
    
}
 
public function getMethod() {
        
return $this->getQuote()->getCheckoutMethod();
 
}
}

9. Override the Onepage Checkout Model.
This involves copying over the /code/core/Mage/Checkout/Model/Type/Onepage.php to /code/local/Mage/Checkout/Model/Type/Onepage.php.
You need to add a new method. I followed most of the directions in the previous post, but had to add some magic methods to actually get it to set the data.

$this->getQuote()->setBusinessType($data['business_type']);
You can method chain others onto that, the format set/getWhatever will call the magic method __call to set/get properties.

These are the steps that I have taken, not including the progress widget. The point I am at now has data being saved to the flat table, but not to the eav table. I am not sure exactly what I am doing wrong, but if anyone has some suggestions it would be appreciated.

EDIT: I was wrong. What I outlined above works perfectly for me. The problem was I was looking for the saved data in the wrong table. I expected it to show up in magento_sales_order_entity_varchar and it is showing up in magento_sales_order_varchar.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top
Page 2 of 2
 
Sales: Call 877.832.5289 (North America) 310.295.4144 (International)
© Copyright 2008 Varien. Magento, eCommerce software, is a trademark of Irubin Consulting Inc. DBA Varien
Privacy Policy|Terms of Service
Magento Community Count
53200 users|743 users currently online|107234 forum posts