function widget($args, $instance) { extract($args); extract($instance); global $product; $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); ?> <section class="section section-product"> <div class="container"> <div class="row category"> <div class="col-xs-3 category-name"> <img src="<?php echo get_template_directory_uri(); ?> /img/<?php echo !empty($icon_class) ? $icon_class : 'category-woman'; ?> .png" class="img-responsive"> <?php if (!empty($title)) { echo '<span>' . $title . '</span>'; } ?> </div> <div class="col-xs-9 type-list"> <?php //echo $cat; $args_product_cat = array('type' => 'product', 'child_of' => 1, 'parent' => $cat, 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => 1, 'hierarchical' => 1, 'exclude' => '', 'include' => '', 'number' => '', 'taxonomy' => 'product_cat', 'pad_counts' => false); $product_list_cats = get_categories($args_product_cat); // print_r($product_list_cat); ?> <?php if (!empty($product_list_cats)) { ?> <ul class="type-list-ul"> <?php foreach ($product_list_cats as $i => $product_list_cat) { if ($i > 3) { break; } else { ?> <li class="type-list-item"><a href="<?php echo get_term_link($product_list_cat, 'product_cat'); ?> " cat-term="<?php echo $product_list_cat->term_id; ?> "><?php echo $product_list_cat->name; ?> </a> </li> <?php } } ?> <?php if (count($product_list_cats) > 4) { ?> <li class="type-list-item more"> <button type="button" class="btn dropdown-toggle more-btn" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> <span class="more-title">SẢN PHẨM KHÁC</span> <span class="caret"></span> <span class="sr-only">Toggle Dropdown</span> </button> <ul class="dropdown-menu"> <?php foreach ($product_list_cats as $i => $product_list_cat) { if ($i > 3) { ?> <li><a href="<?php echo get_term_link($product_list_cat, 'product_cat'); ?> " cat-term="<?php echo $product_list_cat->term_id; ?> "><?php echo $product_list_cat->name; ?> </a> </li> <?php } } ?> </ul> </li> <?php } ?> </ul> <?php } ?> </div> </div> <?php $product_widget_cat = new WP_Query(array('post_type' => 'product', 'showposts' => 2, 'tax_query' => array(array('taxonomy' => 'product_cat', 'field' => 'term_id', 'terms' => $cat)))); ?> <?php if ($product_widget_cat->have_posts()) { ?> <div class="row sample"> <?php while ($product_widget_cat->have_posts()) { $product_widget_cat->the_post(); ?> <div class="col-xs-6 sample-item"> <div class="thumbnail"> <a href="<?php the_permalink(); ?> "> <?php product_percent_2(); ?> <span class="sale-title">SALE</span> <span class="new-title">NEW</span> <?php the_post_thumbnail(array(236, 330, 'bfi_thumb' => true), array('class' => 'img-responsive')); ?> </a> <div class="caption clearfix"> <a href="<?php the_permalink(); ?> "><span class="caption-title"><?php hhs_brand(); ?> </span></a> <hr/> <?php $product = new WC_Product(get_the_ID()); ?> <p class="caption-description"><?php echo get_the_title() . $product->get_sku(); ?> </p> <div class="caption-price"> <?php $price = get_post_meta(get_the_ID(), '_regular_price', true); $sale = get_post_meta(get_the_ID(), '_sale_price', true); ?> <div class="price-info"> <?php echo '<p class="old-price">' . number_format($price, 0, '.', '.') . ' VNĐ</p>'; ?> <?php echo '<p class="new-price">' . number_format($sale, 0, '.', '.') . ' VNĐ</p>'; ?> </div> <div class="cart"> <a href="<?php echo esc_url($product->add_to_cart_url()); ?> "><img src="<?php echo get_template_directory_uri(); ?> /img/product-cart.png"></a> </div> </div> </div> </div> </div> <?php } wp_reset_postdata(); ?> </div> <?php } ?> </div> <!-- /.row row-no-padding --> </div> </section> <!-- /.section section-product --> <?php }
$featured_query2 = new WP_Query($args2); if ($featured_query2->have_posts()) { echo '<div class="row top-product-list">'; while ($featured_query2->have_posts()) { $featured_query2->the_post(); ?> <div class="col-xs-4 top-product-item"> <a href="<?php the_permalink(); ?> " title="<?php the_title(); ?> "> <?php product_percent_2(); ?> <?php $price = get_post_meta(get_the_ID(), '_regular_price', true); $sale = get_post_meta(get_the_ID(), '_sale_price', true); if ($sale) { $price_html = '<span class="price-info"><b>' . number_format($sale, 0, '.', '.') . ' VNĐ</b><br/><span class="old-price">' . number_format($price, 0, '.', '.') . ' VNĐ</span></span>'; } else { $price_html = '<span class="price-info"><b>' . number_format($price, 0, '.', '.') . ' VNĐ</b></span>'; } ?> <?php echo $price_html; ?> <?php the_post_thumbnail(array(260, 165), array('class' => 'img-responsive'));