Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Page 2 of 3
“Onepage” checkout - adding a step
 
tony-fav
Jr. Member
 
Total Posts:  11
Joined:  2008-06-10
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:  209
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:  63
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:  63
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
 
mikewhitby
Member
 
Total Posts:  38
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
 
dri
Jr. Member
 
Total Posts:  7
Joined:  2008-06-12
 

Hi i succeed to insert a step for a coupn code like Georg Ringer explain.

Unfortunately , after validation of coupon code, there is a redirect to ‘my cart’.

I’d like to know if someone could tell me how to redirect to the step ‘coupon code ‘ on the onepage chekout, with message of success or unsuccess

What i’ve tried is on CartController.php :
adding _goBack_Coupon:

protected function _goBack_Coupon()
    
{
        
if (!Mage::getStoreConfig('checkout/cart/redirect_to_cart')
            && !
$this->getRequest()->getParam('in_cart')
            && 
$backUrl $this->_getRefererUrl()) {

            $this
->getResponse()->setRedirect($backUrl);
        
else {
            
if (($this->getRequest()->getActionName() == 'add') && !$this->getRequest()->getParam('in_cart')) {
                $this
->_getSession()->setContinueShoppingUrl($this->_getRefererUrl());
            
}
            $this
->_redirect('checkout/onepage');
        
}
        
return $this;
    
}    


   
public function couponPostAction()
    
{
        $couponCode 
= (string) $this->getRequest()->getParam('coupon_code');
        if (
$this->getRequest()->getParam('remove') == 1{
            $couponCode 
'';
        
}
        $oldCouponCode 
$this->_getQuote()->getCouponCode();

        if (!
strlen($couponCode) && !strlen($oldCouponCode)) {
            $this
->_goBack();
            return;
        
}

        
try {
            $this
->_getQuote()->getShippingAddress()->setCollectShippingRates(true);
            
$this->_getQuote()->setCouponCode(strlen($couponCode) ? $couponCode '')
                ->
collectTotals()
                ->
save();
            if (
$couponCode{
                
if ($couponCode == $this->_getQuote()->getCouponCode()) {
                    $this
->_getSession()->addSuccess(
                        
$this->__('Coupon code "%s" was applied successfully.'Mage::helper('core')->htmlEscape($couponCode))
                    );
                
}
                
else {
                    $this
->_getSession()->addError(
                        
$this->__('Coupon code "%s" is not valid.'Mage::helper('core')->htmlEscape($couponCode))
                    );
                
}
            } 
else {
                $this
->_getSession()->addSuccess($this->__('Coupon code was canceled successfully.'));
            
}

        }
        
catch (Mage_Core_Exception $e{
            $this
->_getSession()->addError($e->getMessage());
        
}
        
catch (Exception $e{
            $this
->_getSession()->addError($this->__('Can not apply coupon code.'));
        
}
        
        $this
->_goBack_Coupon();
    
}

But I’m only redirected on the onepagecheckout on the first step , without message success or unsuccess, and if i go back to the cart, there is the message…

Any help woul be very appreciated
Thanks a lot

 
Magento Community Magento Community
Magento Community
Magento Community
 
alkarim
Guru
 
Total Posts:  368
Joined:  2008-04-10
 

Yeah, I did it....

not perfect but not bad neither…

if you got any problem about it, you can ask me about it....

PM me or add my IM at

 
Magento Community Magento Community
Magento Community
Magento Community
 
alkarim
Guru
 
Total Posts:  368
Joined:  2008-04-10
 

check it out here :

http://www.magentocommerce.com/boards/viewthread/30340/#6

 
Magento Community Magento Community
Magento Community
Magento Community
 
dorgan
Jr. Member
 
Total Posts:  12
Joined:  2009-05-19
 

I am trying to do this through a module instead of hacking these file, and I was able to add the stepcode but now I am not sure waht has to go inside of config.xml so that onepage.php can pull the stepData

 
Magento Community Magento Community
Magento Community
Magento Community
 
sibble
Jr. Member
 
Avatar
Total Posts:  24
Joined:  2008-09-15
Philadelphia
 
Mike Whitby - 22 October 2008 07:26 AM

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();

Those notes worked perfectly!! THANKS!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Magestore
Mentor
 
Avatar
Total Posts:  1015
Joined:  2009-08-07
Viet Nam
 

I just added discount coupon section to checkout page for my customer. I put it in review order and use ajax to apply or cancel discount without returing shopping cart. You can see at his site: http://homemedexpress.com/
If someone is interested in this, let me know, I will package it as an free extension and send to you.
Best Regards, Neo.

 
Magento Community Magento Community
Magento Community
Magento Community
 
lbenitez
Jr. Member
 
Total Posts:  18
Joined:  2009-02-27
 
MageStore - 01 October 2009 01:04 AM

I just added discount coupon section to checkout page for my customer. I put it in review order and use ajax to apply or cancel discount without returing shopping cart. You can see at his site: http://homemedexpress.com/
If someone is interested in this, let me know, I will package it as an free extension and send to you.
Best Regards, Neo.

I wan to see it.. !! Looking forward to the extension!

 
Magento Community Magento Community
Magento Community
Magento Community
 
smily
Jr. Member
 
Avatar
Total Posts:  15
Joined:  2008-05-05
Sydney, Australia
 

The guys at Inchoo have made a module for this: http://inchoo.net/ecommerce/magento/adding-a-new-tab-under-one-page-checkout-full-working-module/ Haven’t tried it tho.

 
Magento Community Magento Community
Magento Community
Magento Community
 
cindym
Jr. Member
 
Total Posts:  3
Joined:  2009-05-04
 
MageStore - 01 October 2009 01:04 AM

I just added discount coupon section to checkout page for my customer. I put it in review order and use ajax to apply or cancel discount without returing shopping cart. You can see at his site: http://homemedexpress.com/
If someone is interested in this, let me know, I will package it as an free extension and send to you.
Best Regards, Neo.

I am interested in this, could you send me your extension please?

Also, I looked at your site. Very nice! I notice you organize by brands, was that custom code or did you treat the brands as categories?

Where are you hosting this? It seems very slow, too bad for a nice design.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 2 of 3