Adding a Step to Checkout

Your AppThemes Checkout process by default is very simple. You can select a plan, enter some information, and pay. We try to make sure that your customers get to their destination as quickly as possible. But for some of you, there might be some other important steps that your customer needs to take in order to get the full functionality of your website.

For instance, you might have a newsletter or a gift card that needs to be processed. You might want to give the user an option to add an item or two to their order before paying. Or, you might want to display pertinent information to the user after their order is completed. All this is possible thanks to AppThemes Checkout.

Creating a New Checkout Step

Adding a new checkout step is incredibly easy. In fact, if you’ve created a payment gateway, you might find some of the API incredibly similar.

A checkout step is simply an object that extends APP_Checkout_Step. This object should have two main functions display() and process().

class MyCheckoutStep extends APP_Checkout_Step {

    function display( $order, $checkout ) {


    function process( $order, $checkout ) {



Displaying Your Step

Your display() method runs in the body of the checkout page. Through it, you can output forms and other HTML markup that will create the interface for your checkout step.

In your method, you’ll have access to the order being processed, and can use this object to display information relevant to the user’s purchase.

    function display( $order ) {
        echo 'Your current order total is ' . $order->get_total();
        if ( $order->get_total() < 5 ) {
            echo 'You should spend more money!';

Processing During a Step

Your process() method runs every time your step is called, before the page headers are sent. This lets you do things like redirect the page if necessary, like if you’re directing your user over to a payment gateway. It also is the perfect place for doing things like processing forms, if your step has one.

    function process( $order ) {
        if ( ! empty( $_POST ) ) {
            // ... process form things 
            $order->add_item( 'my-item', 5.00 );

Like the display() method, you have access to the order being process. This is helpful if you want to do something such as apply a coupon code, as you can simply add another item to the order that adjusts the amount.

Finishing a Checkout Step

When you are finished processing, you can call the $this->finish_step() method inherited by your class from APP_Checkout_Step. This method will automatically cause the user to be redirected to the next step after your processing has completed.

Calling $this->finish_step() will not immediately stop processing, so you if you expect your method to finish you must use the return keyword to force a break.

    function process( $order ) {

        echo 'This code will run';

        return $this->finish_step();
        echo 'This code will not run';


Registering Your Checkout Step

Now that the basic functions of your checkout step are squared away, you will need to register with an actual checkout process. There are lots of different checkout processes. Standard process include create-listing and edit-listing, but you can find more by searching for calls to appthemes_setup_checkout( $checkout_id );.

To register your checkout to a checkout process, you will need to create a constructor in your class, like so:

public function __construct(){
	parent::__construct( 'your-step-id', array(
		'register_to' => array(
	) );

You can also register a step specifically in relation to another step. If you wanted your step to always go after the Select Plan page on Vantage, you could do:

parent::__construct( 'your-step-id', array(
	'register_to' => array(
		'add-service' => array( 'after' => 'select-plan' )
) );

Finishing Up

Finally, the last step is initializing your new step to set everything into motion. All you need to do is make a new instance of your class after the file has loaded. Your functions.php file might be a good place.

new MyNewStep();

Like this tutorial? Subscribe and get the latest tutorials delivered straight to your inbox or feed reader.

Your rating: none
Rating: 4.2 - 5 votes

Popular Add-ons

Fortumo SMS payment gateway

Fortumo sms payment gateway for ClassiPress


ClassiPress Video Embed

Allow users to embed video from YouTube & Vimeo into their ad listings…


Price Comparer

Jump start your Price Comparision site with products from Amazon,…