Skip to content

Instantly share code, notes, and snippets.

@mmilosheski
Created March 15, 2021 15:29
Show Gist options
  • Save mmilosheski/960394015e54547e13dfb449614fafcd to your computer and use it in GitHub Desktop.
Save mmilosheski/960394015e54547e13dfb449614fafcd to your computer and use it in GitHub Desktop.
<div class="pricing__slider">
<?php
if(count($plan_options) > 2) :
?>
<div id="pricingSlider2" class="swiper-container"
data-simulateTouch = "true"
data-scrollbar=".swiper-scrollbar"
data-slidesPerView = "2"
data-slidesPerView320="auto"
data-slidesPerView576="2"
data-initialSlide="<?php echo (isset($_REQUEST['plan']) && !empty($_REQUEST['plan'])) ? (intval($_REQUEST['plan'])-1) : 0; ?>"
>
<div class="swiper-wrapper">
<?php
foreach ( $plan_options as $k => $plan_option) {
$product = wc_get_product( $plan_option['product']->ID );
?>
<div class="swiper-slide">
<div class="pricing__col --red tables_<?php echo $plan_option['product']->post_name; ?>">
<div class="pricing__head" style="--color-top: <?php echo $plan_option['plan_start_color']; ?>; --color-bottom: <?php echo $plan_option['plan_end_color']; ?>">
<div class="name">
<h3><?php echo $plan_option['product']->post_title; ?></h3>
<p><?php echo (false !== strpos($plan_option['product']->post_title, 'Silver')) ? 'Basic' : 'Premium'; ?></p>
</div>
<div class="price">
<sup>$</sup><?php echo $product->get_price(); ?><sub class="text-small"> / month</sub>
</div>
</div>
<div class="pricing__body">
<ul>
<?php
foreach ( $plan_options[$k]['options_all_shop'] as $options ) {
if($options['bold']) {
echo '<li><b>' . $options['option'] . '</b></li>';
} else {
echo '<li>' . $options['option'] . '</li>';
}
}
?>
</ul>
</div>
<div class="pricing__body --mobile">
<ul>
<?php
foreach ( $plan_options[$k]['options'] as $options ) {
if($options['bold']) {
echo '<li><b>' . $options['option'] . '</b></li>';
} else {
echo '<li>' . $options['option'] . '</li>';
}
}
?>
</ul>
</div>
<div class="pricing__footer">
<a href="#" class="btn-secondary <?php echo (false !== strpos($plan_option['product']->post_title, 'Silver')) ? '--blue' : '--red'; ?>" data-product-id="<?php echo $plan_option['product']->ID; ?>" data-price="<?php echo $product->get_price(); ?>" data-product-name="<?php echo $plan_option['product']->post_title; ?>">
<span class="btn-text" data-text-selected="Selected" data-text-original="Price your plan">Price your plan</span>
</a>
</div>
</div>
</div>
<?php
}
wp_reset_query();
?>
</div>
<div class="swiper-scrollbar"></div>
</div>
<?php
else :
?>
<div id="pricingSlider" class="swiper-container"
data-simulateTouch = "true"
data-scrollbar=".swiper-scrollbar"
data-slidesPerView = "2"
data-slidesPerView320="auto"
data-slidesPerView576="2"
data-initialSlide="<?php echo (isset($_REQUEST['plan']) && !empty($_REQUEST['plan'])) ? (intval($_REQUEST['plan'])-1) : 0; ?>"
>
<div class="swiper-wrapper">
<?php
foreach ( $plan_options as $k => $plan_option) {
$product = wc_get_product( $plan_option['product']->ID );
?>
<div class="swiper-slide">
<div class="pricing__col --red tables_<?php echo $plan_option['product']->post_name; ?>">
<div class="pricing__head" style="--color-top: <?php echo $plan_option['plan_start_color']; ?>; --color-bottom: <?php echo $plan_option['plan_end_color']; ?>">
<div class="name">
<h3><?php echo $plan_option['product']->post_title; ?></h3>
<p><?php echo (false !== strpos($plan_option['product']->post_title, 'Silver')) ? 'Basic' : 'Premium'; ?></p>
</div>
<div class="price">
<sup>$</sup><?php echo $product->get_price(); ?><sub class="text-small"> / month</sub>
</div>
</div>
<div class="pricing__body">
<ul>
<?php
foreach ( $plan_options[$k]['options_all_shop'] as $options ) {
if($options['bold']) {
echo '<li><b>' . $options['option'] . '</b></li>';
} else {
echo '<li>' . $options['option'] . '</li>';
}
}
?>
</ul>
</div>
<div class="pricing__body --mobile">
<ul>
<?php
foreach ( $plan_options[$k]['options'] as $options ) {
if($options['bold']) {
echo '<li><b>' . $options['option'] . '</b></li>';
} else {
echo '<li>' . $options['option'] . '</li>';
}
}
?>
</ul>
</div>
<div class="pricing__footer">
<a href="#" class="btn-secondary <?php echo (false !== strpos($plan_option['product']->post_title, 'Silver')) ? '--blue' : '--red'; ?>" data-product-id="<?php echo $plan_option['product']->ID; ?>" data-price="<?php echo $product->get_price(); ?>" data-product-name="<?php echo $plan_option['product']->post_title; ?>">
<span class="btn-text" data-text-selected="Selected" data-text-original="Price your plan">Price your plan</span>
</a>
</div>
</div>
</div>
<?php
}
wp_reset_query();
?>
</div>
<div class="swiper-scrollbar"></div>
</div>
<?php endif; ?>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment