change-subscription.php 3.18 KB
<?php
/**
 * The template for displaying the Change Subscription .
 *
 * This page template will display any functions hooked into the `homepage` action.
 * By default this includes a variety of product displays and the page content itself. To change the order or toggle these components
 * use the Homepage Control plugin.
 * https://wordpress.org/plugins/homepage-control/
 *
 * Template name: Change Subscription
 *
 * @package storefront
 */
/*
 * Created on : August 1, 2016
 * Author: Tran Thi Phuong An
 * Email: phuongantt.na@gmail.com
 */
remove_filter('the_content', 'wpautop');
get_header();

$subscription_result = FGC_ActiveCampaign::get_info_of_active_or_onhold_subscription(get_current_user_id());

$link_upgrade = get_site_url() . '/get-started';
$can_upgrade = false;
$link_downgrade = '';
$can_downgrade = false;
$link_takemonth = '';
$can_take_month_off = false;

if ($subscription_result['has_subscription']) {
    if ($subscription_result['current_drink'] < 600) {
        $link_upgrade = get_site_url() . '/upgrade';
        $can_upgrade = true;
    }
    if ($subscription_result['current_drink'] > 3) {
        $link_downgrade = get_site_url() . '/downgrade';
        $can_downgrade = true;
    }
    if ($subscription_result['status'] == 'active') {
        $link_takemonth = get_site_url() . '/take-month-off';
        $can_take_month_off = true;
    }
}
?>

<div id="primary" class="content-area">
    <main id="main" class="site-main" role="main">

        <?php while (have_posts()) : the_post(); ?>

            <?php
            do_action('storefront_page_before');
            ?>
            <div class="bg2 text-center "><header class="tv-header">
                    <h1 class="tv-title">Change your plan</h1>
                </header>
                <div class="innersmall plan_options ">
                    <h2 class="text-uppercase font20 robotobold">Easily manage your plan here</h2>
                    <a href="<?php echo $link_upgrade; ?>" class="button  <?php echo ($can_upgrade) ? 'btnrow' : 'disable'; ?>"><?php esc_html_e('Upgrade your plan', 'woocommerce-subscriptions'); ?><i class="fa fa-angle-right hide"></i></a>
                    <a href="<?php echo $link_downgrade; ?>" class="button  <?php echo ($can_downgrade) ? 'btnrow' : 'disable'; ?>"><?php esc_html_e('Downgrade your plan', 'woocommerce-subscriptions'); ?><i class="fa fa-angle-right hide"></i></a>
                    <a class="button  <?php echo ($can_take_month_off) ? 'btnrow' : 'disable'; ?>" href="<?php echo $link_takemonth; ?>">
                        <?php esc_html_e('Take a month off', 'woocommerce-subscriptions') ?><i class="fa fa-angle-right hide"></i>
                    </a>
                    <br/>
                    <a class="btnbgnone btnrow" href="/cancel-membership">Other options <i class="fa fa-angle-right hide"></i></a>
                </div>
                <div class="form-group clearfix"></div>
            </div>
            <?php
            /**
             * @hooked storefront_display_comments - 10
             */
            do_action('storefront_page_after');
            ?>

        <?php endwhile; // end of the loop.      ?>

    </main><!-- #main -->
</div><!-- #primary -->

<?php get_footer(); ?>