<?php

defined('_VALID_CALL') or die('Direct Access is not allowed.');

function coupons_checkout_first()
{
    global $page;

    if(($page->page_name == 'checkout' && $_POST['action'] == 'shipping')
        ||
        ($page->page_name == 'checkout' && $page->page_action == 'payment')
    )
    {
        $coupons = new xt_coupons();
        if($_SESSION['sess_coupon'])
        {
            $coupons->_addToCart($_SESSION['sess_coupon']['coupon_code']);
        }

    }
}

coupons_checkout_first();
