cancel-subscription.php 4.94 KB
<?php
/**
 * The template for displaying the Cancel 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: Cancel Subscription
 *
 * @package storefront
 */
/*
 * Created on : Mar 9, 2016, 9:15:42 AM
 * Author: Tran Trong Thang
 * Email: trantrongthang1207@gmail.com
 * Skype: trantrongthang1207
 */
remove_filter('the_content', 'wpautop');
get_header();
?>

<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');
            ?>

            <?php
            //get_template_part('content', 'page');
            /*
              do_action( 'cancelled_subscription', 16, '275_181' );
              $subscriptions = WC_Subscriptions_Manager::get_users_subscriptions(get_current_user_id());

              $subscription = wcs_get_subscription_from_key( '275_181' );
              $subscription->update_status( 'cancelled' );
              echo get_current_user_id();
              print_r($subscription); */

            $subscriptions = wcs_get_users_subscriptions(get_current_user_id());
            foreach ($subscriptions as $key => $value) {
                $actions = wcs_get_all_user_actions_for_subscription($value, get_current_user_id());
                if ($value->post->post_status != 'wc-cancelled' && $value->post->post_status != 'wc-pending-cancel') {
                    $url = $actions['cancel']['url'];
                    break;
                }
            }
            if ($url) {
                $url = str_replace('change_subscription_to', 'cancelled_subscription', $url);
            }
            ?>
            <div class="bg2 page_cancel_subscription">
                <header class="tv-header text-center">
                    <h1 itemprop="name" class="tv-title">cancel membership</h1>
                </header>

                <div class="col-w-310">
                    <h2 class="text-uppercase font20 robotobold">we'll be sorry to see you go</h2>
                    <form action="<?php echo $url ?>" method="post" >
                        <div class="text-left">
                            <ul class="nav nav-pills nav-stacked">
                                <li>
                                    <input type="radio" name="cancel_reason" value="Dislike the product" class="required"/>
                                    <label>
                                        Dislike the product
                                    </label>
                                </li>
                                <li>
                                    <input type="radio" name="cancel_reason" value="Unsatisfied with your service"/>
                                    <label>
                                        Unsatisfied with your service
                                    </label>
                                </li>
                                <li>
                                    <input type="radio" name="cancel_reason" value="I am receiving too much REIZE"/>
                                    <label>
                                        I'm receiving too much REIZE
                                    </label>
                                </li>
                                <li>
                                    <input type = "radio" name = "cancel_reason" value = "I have stopped drinking energy drinks"/>
                                    <label>
                                        I've stopped drinking energy drinks
                                    </label>
                                </li>
                            </ul>
                            <br/>
                            <div>
                                Other
                                <textarea name="cancel_other" class="cancel_other"></textarea>
                            </div>
                            <br/>
                            <br/>
                        </div>
                        <button class="button btnrow"><span>Quit the REIZE Club</span> <i class="fa fa-angle-right hide"></i></button>
                    </form>
                    <br/>
                    <a href="/my-account" class="btnbgnone btnrowleft robotobold_italic"><span>Nevermind, take me back to My Account</span> <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(); ?>