show consultancy woocommerce
a custom template for show consultancy woocommerce bookable product.
// Add Shortcode
function JTS_shortcode_show_consultancy( $atts ) {
// Attributes
$atts = shortcode_atts(
array(
'category' => '',
),
$atts,
'jts-show-consultancy'
);
$args = array( 'post_type' => 'product', 'posts_per_page' => 4, 'product_cat' => $atts['category'] , 'orderby' => 'rand' );
$loop = new WP_Query( $args );
ob_start();
?>
<div class="plan__wrapper">
<?php while ( $loop->have_posts() ) : $loop->the_post(); global $product; ?>
<div class="plan">
<a href="<?php echo get_permalink( $loop->post->ID ) ?>" title="<?php echo esc_attr($loop->post->post_title ? $loop->post->post_title : $loop->post->ID); ?>">
<header class="plan__title">
<h3><?php the_title(); ?></h3>
</header>
<div class="plan__content">
<?php echo $product->get_short_description(); ?>
</div>
<div class="plan__cost">
<?php echo $product->get_price(); ?><?php echo get_woocommerce_currency_symbol(); ?>
+ IVA
</div>
</a>
</div>
<?php endwhile; ?>
</div>
<?php
$output = ob_get_clean();
wp_reset_query();
return $output;
}
add_shortcode( 'jts-show-consultancy', 'JTS_shortcode_show_consultancy' );