Snippets WooCommerce

August 19, 2018 Artikel,Plugin,Snippets Kholis net

Snippet WooCommerce ini saya kumpulkan ketika mengerjakan theme WooCommerce, dan semoga bermanfaat!

1. wp_query untuk menampilkan produk-produk berdasarkan katergori.


<div class="col-md-1 col-xs-6 teas">
	
<h4><a href="<?php echo $smof_data['classictea']; ?>">Classic Tea</a></h4>

       
<ul class="teas">
           <?php $args = array( 'posts_per_page' => '5',
        'product_cat' => 'classic-tea',
        'post_type' => 'product',
        'orderby' => 'title',
    );?>


<?php $query = new WP_Query( $args ); if( $query->have_posts()) : while( $query->have_posts() ) : $query->the_post();?>
            
<li><a href="<?php the_permalink();?>"><?php echo the_title();?></a></li>

<?php endwhile;?>
<?php endif; ?>
            
            
<li><a href="<?php echo $smof_data['classictea']; ?>"><i class="fa fa-chevron-circle-right"> See All</i></a></li>

		   
        </ul>

		
</div>

2. Menampilkan Shopping cart di header.


<div class="cart-bg">
<?php if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
$count = WC()->cart->cart_contents_count;
?><a class="cart-contents" href="<?php echo WC()->cart->get_cart_url(); ?>" title="<?php _e( 'View your shopping cart' ); ?>"><?php
if ( $count > 0 ) {
?>
<span class="cart-contents-count"><?php echo esc_html( $count ); ?></span>
<?php
}
?></a>
<?php } ?>
</div>

3. Add plus and minus buttons to WooCommerce quantity inputs

https://gist.github.com/helgatheviking/6abe7385c23ba4238710ba6d1ccc5181

 

 

 

67 total views, 1 views today

Facebooktwittergoogle_plusredditpinterestlinkedinmail

Yes No