<?php
    $class = isset($args['class']) ? $args['class'] : '';
    $category = false;
    $plans_features = [];

    // WP_Query arguments
    $query_args = array(
        'post_type'           => 'pricing',
        'post_status'         => 'publish',
        'ignore_sticky_posts' => 1,
        'posts_per_page'      => -1,
        'orderby'             => 'ASC',
        'order'               => 'ASC',
        'tax_query'           => array(
            array(
                'taxonomy'  => 'pricing_categories',
                'field'     => 'slug', // Optional as it defaults to 'term_id'
                'terms'     => $category ? $category : 'home',
                'operator'  => 'IN' // Possible values: 'IN', 'NOT IN', 'AND'.
            )
        )
    );

    // Run the query
    $the_query = new WP_Query($query_args);
?>


<section class="section pricing-promotions <?php echo $class; ?>" id="pricingPromo">
    <div class="container">
        <?php if ( $the_query->have_posts() ) : ?>
            <div class="row">
                <div class="col-lg-3">
                    <!--<h2 class="slide-right">Features</h2> -->
                </div>
                <div class="col-lg-9">
                    <ul>
                        <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
                            <li class="slide-down">
                                <?php echo get_the_title(); ?>
                                <a href="<?php echo site_url();?>/signup/">Start Free Trial</a>
                            </li>
                            <?php
                                $field_object['sub_fields'] = get_field_object('package_features')['sub_fields'];
                                $field_object['values'] = get_field('package_features');
                                $plans_features[] = $field_object;
                            ?>
                        <?php endwhile; ?>
                        <?php wp_reset_postdata(); ?>
                    </ul>
                </div>
            </div>
        <?php endif; ?>

        <div class="table-cont">
            <div class="table-responsive slide-up">
                <table class="table table-bordered">
                    <tbody>
                        <?php for ($i=0; $i < count($plans_features[0]['sub_fields']); $i++) : ?>
                            <?php $name  = $plans_features[0]['sub_fields'][$i]['name']; ?>
                            <tr>
                                <td><?php echo $plans_features[0]['sub_fields'][$i]['label']; ?></td>
                                <td><?php echo $plans_features[0]['values'][$name]; ?></td>
                                <td><?php echo $plans_features[1]['values'][$name]; ?></td>
                                <td><?php echo $plans_features[2]['values'][$name]; ?></td>
                            </tr>
                        <?php endfor; ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</section>