function thb_product_single($atts, $content = null) { extract(shortcode_atts(array('product_id' => ''), $atts)); global $post, $product, $woocommerce, $woocommerce_loop; $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'p' => $product_id); $products = new WP_Query($args); ob_start(); $catalog_mode = ot_get_option('shop_catalog_mode', 'off'); $shop_product_listing = ot_get_option('shop_product_listing', 'style1'); if ($products->have_posts()) { while ($products->have_posts()) { $products->the_post(); ?> <?php $product = get_product($products->post->ID); ?> <div class="products"> <article itemscope itemtype="<?php echo woocommerce_get_product_schema(); ?> " <?php post_class("post small-12 columns " . $shop_product_listing); ?> > <?php do_action('woocommerce_before_shop_loop_item'); ?> <?php $image_html = ""; if (has_post_thumbnail()) { $image_html = wp_get_attachment_image(get_post_thumbnail_id(), 'shop_catalog'); } ?> <?php if ($shop_product_listing == 'style1') { ?> <figure class="fresco"> <?php do_action('thb_product_badge'); ?> <?php echo $image_html; ?> <div class="overlay"></div> <div class="buttons"> <?php echo thb_wishlist_button(); ?> <div class="post-title<?php if ($catalog_mode == 'on') { echo ' catalog-mode'; } ?> "> <a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a> </div> <?php if ($catalog_mode != 'on') { ?> <?php /** * woocommerce_after_shop_loop_item_title hook * * @hooked woocommerce_template_loop_price - 10 */ do_action('woocommerce_after_shop_loop_item_title'); ?> <?php do_action('woocommerce_after_shop_loop_item'); ?> <?php } ?> </div> </figure> <?php } else { if ($shop_product_listing == 'style2') { ?> <figure class="fresco"> <?php do_action('thb_product_badge'); ?> <a href="<?php the_permalink(); ?> "><?php echo $image_html; ?> </a> </figure> <div class="post-title<?php if ($catalog_mode == 'on') { echo ' catalog-mode'; } ?> "> <a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a> </div> <?php if ($catalog_mode != 'on') { ?> <?php /** * woocommerce_after_shop_loop_item_title hook * * @hooked woocommerce_template_loop_price - 10 */ do_action('woocommerce_after_shop_loop_item_title'); ?> <?php do_action('woocommerce_after_shop_loop_item'); ?> <?php } ?> <?php } } ?> </article><!-- end product --> </div> <?php } } $out = ob_get_contents(); if (ob_get_contents()) { ob_end_clean(); } wp_reset_query(); wp_reset_postdata(); remove_filter('posts_clauses', array($woocommerce->query, 'order_by_rating_post_clauses')); return $out; }
<div class="variations_button"> <?php woocommerce_quantity_input(); ?> <?php if (sizeof($attributes) == $loop) { echo '<a class="reset_variations" href="#reset">' . __('Clear selection', THB_THEME_NAME) . '</a>'; } ?> <button type="submit" class="single_add_to_cart_button button alt"><?php echo $product->single_add_to_cart_text(); ?> </button> <?php echo thb_wishlist_button(); ?> </div> <input type="hidden" name="add-to-cart" value="<?php echo $product->id; ?> " /> <input type="hidden" name="product_id" value="<?php echo esc_attr($post->ID); ?> " /> <input type="hidden" name="variation_id" value="" /> <?php do_action('woocommerce_after_single_variation'); ?>
function load_products() { $type = isset($_POST['type']) ? $_POST['type'] : "latest-products"; $footer_products_count = ot_get_option('footer_products_count', 6); if ($type == "latest-products") { $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $footer_products_count, 'no_found_rows' => true, 'suppress_filters' => 0); } else { if ($type == "featured-products") { $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $footer_products_count, 'meta_query' => array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN'), array('key' => '_featured', 'value' => 'yes')), 'no_found_rows' => true, 'suppress_filters' => 0); } else { if ($type == "best-sellers") { $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $footer_products_count, 'meta_key' => 'total_sales', 'orderby' => 'meta_value', 'meta_query' => array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN')), 'no_found_rows' => true, 'suppress_filters' => 0); } else { $category = get_term_by('id', $type, 'product_cat'); $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'product_cat' => $category->slug, 'posts_per_page' => $footer_products_count, 'no_found_rows' => true, 'suppress_filters' => 0); } } } $products = new WP_Query($args); $catalog_mode = ot_get_option('shop_catalog_mode', 'off'); $shop_product_listing = ot_get_option('shop_product_listing', 'style1'); global $post; if ($products->have_posts()) { ?> <div class="carousel products no-padding owl row" data-columns="6" data-navigation="true" data-loop="true" data-bgcheck="false"> <?php while ($products->have_posts()) { $products->the_post(); ?> <?php $product = get_product($products->post->ID); ?> <article itemscope itemtype="<?php echo woocommerce_get_product_schema(); ?> " <?php post_class("post small-6 medium-4 large-2 columns product " . $shop_product_listing); ?> > <?php do_action('woocommerce_before_shop_loop_item'); ?> <?php $image_html = ""; if (has_post_thumbnail()) { $image_html = wp_get_attachment_image(get_post_thumbnail_id(), 'shop_catalog'); } ?> <?php if ($shop_product_listing == 'style1') { ?> <figure class="fresco"> <?php do_action('thb_product_badge'); ?> <?php echo $image_html; ?> <div class="overlay"></div> <div class="buttons"> <?php echo thb_wishlist_button(); ?> <div class="post-title<?php if ($catalog_mode == 'on') { echo ' catalog-mode'; } ?> "> <a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a> </div> <?php if ($catalog_mode != 'on') { ?> <?php /** * woocommerce_after_shop_loop_item_title hook * * @hooked woocommerce_template_loop_price - 10 */ do_action('woocommerce_after_shop_loop_item_title'); ?> <?php do_action('woocommerce_after_shop_loop_item'); ?> <?php } ?> </div> </figure> <?php } else { if ($shop_product_listing == 'style2') { ?> <figure class="fresco"> <?php do_action('thb_product_badge'); ?> <a href="<?php the_permalink(); ?> "><?php echo $image_html; ?> </a> </figure> <div class="post-title<?php if ($catalog_mode == 'on') { echo ' catalog-mode'; } ?> "> <a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a> </div> <?php if ($catalog_mode != 'on') { ?> <?php /** * woocommerce_after_shop_loop_item_title hook * * @hooked woocommerce_template_loop_price - 10 */ do_action('woocommerce_after_shop_loop_item_title'); ?> <?php do_action('woocommerce_after_shop_loop_item'); ?> <?php } ?> <?php } } ?> </article> <?php } ?> </div> <div class="ai-dotted ai-indicator"><span class="ai-inner1"></span><span class="ai-inner2"></span><span class="ai-inner3"></span></div> <?php } wp_reset_query(); wp_reset_postdata(); die; }
function thb_product($atts, $content = null) { extract(shortcode_atts(array('product_sort' => 'best-sellers', 'carousel' => 'no', 'item_count' => '4', 'columns' => '4', 'cat' => '', 'product_ids' => ''), $atts)); global $post, $product, $woocommerce, $woocommerce_loop; $args = array(); if ($product_sort == "latest-products") { $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $item_count); } else { if ($product_sort == "featured-products") { $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'meta_key' => '_featured', 'meta_value' => 'yes', 'posts_per_page' => $item_count); } else { if ($product_sort == "top-rated") { add_filter('posts_clauses', array($woocommerce->query, 'order_by_rating_post_clauses')); $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $item_count); $args['meta_query'] = $woocommerce->query->get_meta_query(); } else { if ($product_sort == "sale-products") { $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $item_count, 'meta_query' => array('relation' => 'OR', array('key' => '_sale_price', 'value' => 0, 'compare' => '>', 'type' => 'numeric'), array('key' => '_min_variation_sale_price', 'value' => 0, 'compare' => '>', 'type' => 'numeric'))); } else { if ($product_sort == "by-category") { $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'product_cat' => $cat, 'posts_per_page' => $item_count); } else { if ($product_sort == "by-id") { $product_id_array = explode(',', $product_ids); $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'post__in' => $product_id_array); } else { $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $item_count, 'meta_key' => 'total_sales', 'orderby' => 'meta_value'); } } } } } } $products = new WP_Query($args); $woocommerce_loop['columns'] = apply_filters('loop_shop_columns', $columns); ob_start(); switch ($columns) { case 2: $col = 'medium-6'; break; case 3: $col = 'medium-4'; break; case 4: $col = 'medium-3'; break; } $catalog_mode = ot_get_option('shop_catalog_mode', 'off'); if ($products->have_posts()) { ?> <?php if ($carousel == "yes") { ?> <div class="carousel-container"> <div class="carousel products owl row" data-columns="<?php echo $columns; ?> " data-navigation="true"> <?php while ($products->have_posts()) { $products->the_post(); ?> <?php $product = wc_get_product($products->post->ID); ?> <article itemscope itemtype="<?php echo woocommerce_get_product_schema(); ?> " <?php post_class("post small-6 {$col} columns"); ?> > <?php do_action('woocommerce_before_shop_loop_item'); ?> <figure class="fresco"> <?php $image_html = ""; if (thb_out_of_stock()) { echo '<span class="badge out-of-stock">' . __('Out of Stock', THB_THEME_NAME) . '</span>'; } else { if ($product->is_on_sale()) { echo apply_filters('woocommerce_sale_flash', '<span class="badge onsale">' . __('Sale', THB_THEME_NAME) . '</span>', $post, $product); } } if (has_post_thumbnail()) { $image_html = wp_get_attachment_image(get_post_thumbnail_id(), 'shop_catalog'); } ?> <?php echo $image_html; ?> <div class="overlay"> <div class="buttons"> <?php echo thb_wishlist_button(); ?> <a class="quick quick-view" data-id="<?php echo $post->ID; ?> " href="#"><i class="icon-budicon-545"></i></a> </div> </div> </figure> <div class="post-title<?php if ($catalog_mode == 'on') { echo ' catalog-mode'; } ?> "> <a href="<?php the_permalink(); ?> "><?php echo thb_ShortenText(get_the_title($post->ID), 20); ?> </a> <?php if ($catalog_mode != 'on') { ?> <?php /** * woocommerce_after_shop_loop_item_title hook * * @hooked woocommerce_template_loop_price - 10 */ do_action('woocommerce_after_shop_loop_item_title'); ?> <?php do_action('woocommerce_after_shop_loop_item'); ?> <?php } ?> </div> </article><!-- end product --> <?php } // end of the loop. ?> </div> </div> <?php } else { ?> <div class="products row" data-equal="article"> <?php while ($products->have_posts()) { $products->the_post(); ?> <?php $product = wc_get_product($products->post->ID); ?> <article itemscope itemtype="<?php echo woocommerce_get_product_schema(); ?> " <?php post_class("post small-6 {$col} columns"); ?> > <?php do_action('woocommerce_before_shop_loop_item'); ?> <figure class="fresco"> <?php $image_html = ""; if (thb_out_of_stock()) { echo '<span class="badge out-of-stock">' . __('Out of Stock', THB_THEME_NAME) . '</span>'; } else { if ($product->is_on_sale()) { echo apply_filters('woocommerce_sale_flash', '<span class="badge onsale">' . __('Sale', THB_THEME_NAME) . '</span>', $post, $product); } } if (has_post_thumbnail()) { $image_html = wp_get_attachment_image(get_post_thumbnail_id(), 'shop_catalog'); } ?> <?php echo $image_html; ?> <div class="overlay"> <div class="buttons"> <?php echo thb_wishlist_button(); ?> <a class="quick quick-view" data-id="<?php echo $post->ID; ?> " href="#"><i class="icon-budicon-545"></i></a> </div> </div> </figure> <div class="post-title<?php if ($catalog_mode == 'on') { echo ' catalog-mode'; } ?> "> <a href="<?php the_permalink(); ?> "><?php echo thb_ShortenText(get_the_title($post->ID), 25); ?> </a> <?php if ($catalog_mode != 'on') { ?> <?php /** * woocommerce_after_shop_loop_item_title hook * * @hooked woocommerce_template_loop_price - 10 */ do_action('woocommerce_after_shop_loop_item_title'); ?> <?php do_action('woocommerce_after_shop_loop_item'); ?> <?php } ?> </div> </article><!-- end product --> <?php } // end of the loop. ?> </div> <?php } ?> <?php } $out = ob_get_contents(); if (ob_get_contents()) { ob_end_clean(); } wp_reset_query(); wp_reset_postdata(); remove_filter('posts_clauses', array($woocommerce->query, 'order_by_rating_post_clauses')); return $out; }
function thb_footer_products() { if (class_exists('woocommerce')) { $footer_products_radio = isset($_GET['footer_products_radio']) ? htmlspecialchars($_GET['footer_products_radio']) : ot_get_option('footer_products_radio'); $footer_products_sections = ot_get_option('footer_products_sections'); $footer_products_cat = ot_get_option('footer_products_categories'); $footer_products_count = ot_get_option('footer_products_count', 6); $footer_columns = ot_get_option('footer_columns', 'fourcolumns'); ?> <section id="footer_products" class="footer_products cf"> <?php if ($footer_products_radio == 'wid') { ?> <aside class="sidebar"> <?php if ($footer_columns == 'fourcolumns') { ?> <div class="small-12 medium-3 columns"> <?php dynamic_sidebar('footer1'); ?> </div> <div class="small-12 medium-3 columns"> <?php dynamic_sidebar('footer2'); ?> </div> <div class="small-12 medium-3 columns"> <?php dynamic_sidebar('footer3'); ?> </div> <div class="small-12 medium-3 columns"> <?php dynamic_sidebar('footer4'); ?> </div> <?php } elseif ($footer_columns == 'threecolumns') { ?> <div class="small-12 medium-4 columns"> <?php dynamic_sidebar('footer1'); ?> </div> <div class="small-12 medium-4 columns"> <?php dynamic_sidebar('footer2'); ?> </div> <div class="small-12 medium-4 columns"> <?php dynamic_sidebar('footer3'); ?> </div> <?php } elseif ($footer_columns == 'twocolumns') { ?> <div class="small-12 medium-6 columns"> <?php dynamic_sidebar('footer1'); ?> </div> <div class="small-12 medium-6 columns"> <?php dynamic_sidebar('footer2'); ?> </div> <?php } elseif ($footer_columns == 'doubleleft') { ?> <div class="small-12 medium-6 columns"> <?php dynamic_sidebar('footer1'); ?> </div> <div class="small-12 medium-3 columns"> <?php dynamic_sidebar('footer2'); ?> </div> <div class="small-12 medium-3 columns"> <?php dynamic_sidebar('footer3'); ?> </div> <?php } elseif ($footer_columns == 'doubleright') { ?> <div class="small-12 medium-3 columns"> <?php dynamic_sidebar('footer1'); ?> </div> <div class="small-12 medium-3 columns"> <?php dynamic_sidebar('footer2'); ?> </div> <div class="small-12 medium-6 columns"> <?php dynamic_sidebar('footer3'); ?> </div> <?php } elseif ($footer_columns == 'fivecolumns') { ?> <div class="small-12 medium-2 columns"> <?php dynamic_sidebar('footer1'); ?> </div> <div class="small-12 medium-3 columns"> <?php dynamic_sidebar('footer2'); ?> </div> <div class="small-12 medium-2 columns"> <?php dynamic_sidebar('footer3'); ?> </div> <div class="small-12 medium-3 columns"> <?php dynamic_sidebar('footer4'); ?> </div> <div class="small-12 medium-2 columns"> <?php dynamic_sidebar('footer5'); ?> </div> <?php } elseif ($footer_columns == 'onecolumns') { ?> <div class="small-12 columns"> <?php dynamic_sidebar('footer1'); ?> </div> <?php } ?> </aside> <?php } else { if ($footer_products_radio == 'just') { ?> <?php if (is_array($footer_products_sections)) { ?> <aside id="footer_tabs" class="footer_tabs"> <ul> <?php if (in_array('just-arrived', $footer_products_sections)) { ?> <li><a href="#" class="active" data-type="latest-products"><?php _e('Just Arrived', THB_THEME_NAME); ?> </a></li> <?php } ?> <?php if (in_array('best-sellers', $footer_products_sections)) { ?> <li><a href="#" <?php if (!in_array('just-arrived', $footer_products_sections)) { ?> class="active" <?php } ?> data-type="best-sellers"><?php _e('Best Sellers', THB_THEME_NAME); ?> </a></li> <?php } ?> <?php if (in_array('featured', $footer_products_sections)) { ?> <li><a href="#" <?php if (!in_array('just-arrived', $footer_products_sections) && !in_array('best-sellers', $footer_products_sections)) { ?> class="active" <?php } ?> data-type="featured-products"><?php _e('Featured', THB_THEME_NAME); ?> </a></li> <?php } ?> </ul> </aside> <?php } ?> <?php if (!empty($footer_products_sections)) { ?> <?php global $post; $catalog_mode = ot_get_option('shop_catalog_mode', 'off'); $shop_product_listing = ot_get_option('shop_product_listing', 'style1'); $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $footer_products_count, 'no_found_rows' => true, 'suppress_filters' => 0); $products = new WP_Query($args); ?> <div class="carousel-container"> <div class="carousel products no-padding owl row" data-columns="6" data-navigation="true" data-loop="true" data-bgcheck="false"> <?php while ($products->have_posts()) { $products->the_post(); ?> <?php $product = get_product($products->post->ID); ?> <article itemscope itemtype="<?php echo woocommerce_get_product_schema(); ?> " <?php post_class("post small-6 medium-4 large-2 columns product " . $shop_product_listing); ?> > <?php do_action('woocommerce_before_shop_loop_item'); ?> <?php $image_html = ""; if (has_post_thumbnail()) { $image_html = wp_get_attachment_image(get_post_thumbnail_id(), 'shop_catalog'); } ?> <?php if ($shop_product_listing == 'style1') { ?> <figure class="fresco"> <?php do_action('thb_product_badge'); ?> <?php echo $image_html; ?> <div class="overlay"></div> <div class="buttons"> <?php echo thb_wishlist_button(); ?> <div class="post-title<?php if ($catalog_mode == 'on') { echo ' catalog-mode'; } ?> "> <a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a> </div> <?php if ($catalog_mode != 'on') { ?> <?php /** * woocommerce_after_shop_loop_item_title hook * * @hooked woocommerce_template_loop_price - 10 */ do_action('woocommerce_after_shop_loop_item_title'); ?> <?php do_action('woocommerce_after_shop_loop_item'); ?> <?php } ?> </div> </figure> <?php } else { if ($shop_product_listing == 'style2') { ?> <figure class="fresco"> <?php do_action('thb_product_badge'); ?> <a href="<?php the_permalink(); ?> "><?php echo $image_html; ?> </a> </figure> <div class="post-title<?php if ($catalog_mode == 'on') { echo ' catalog-mode'; } ?> "> <a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a> </div> <?php if ($catalog_mode != 'on') { ?> <?php /** * woocommerce_after_shop_loop_item_title hook * * @hooked woocommerce_template_loop_price - 10 */ do_action('woocommerce_after_shop_loop_item_title'); ?> <?php do_action('woocommerce_after_shop_loop_item'); ?> <?php } ?> <?php } } ?> </article><!-- end product --> <?php } // end of the loop. ?> </div> <div class="ai-dotted ai-indicator"><span class="ai-inner1"></span><span class="ai-inner2"></span><span class="ai-inner3"></span></div> </div> <?php } ?> <?php } else { if ($footer_products_radio == 'cat') { ?> <?php if (is_array($footer_products_cat)) { ?> <aside id="footer_tabs" class="footer_tabs"> <ul> <?php $i = 0; foreach ($footer_products_cat as $cat) { ?> <?php $category = get_term_by('id', $cat, 'product_cat'); ?> <li><a href="#"<?php if ($i == 0) { echo ' class="active"'; } ?> data-type="<?php echo $cat; ?> "><?php echo $category->name; ?> </a></li> <?php $i++; } ?> </ul> </aside> <?php } ?> <?php if (!empty($footer_products_cat)) { ?> <?php global $post; $catalog_mode = ot_get_option('shop_catalog_mode', 'off'); $category = get_term_by('id', reset($footer_products_cat), 'product_cat'); $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'product_cat' => $category->slug, 'posts_per_page' => $footer_products_count, 'no_found_rows' => true, 'suppress_filters' => 0); $products = new WP_Query($args); ?> <div class="carousel-container"> <div class="carousel products no-padding owl row" data-columns="6" data-navigation="true" data-bgcheck="false"> <?php while ($products->have_posts()) { $products->the_post(); ?> <?php $product = get_product($products->post->ID); ?> <article itemscope itemtype="<?php echo woocommerce_get_product_schema(); ?> " <?php post_class("post small-6 medium-4 large-2 columns product"); ?> > <?php do_action('woocommerce_before_shop_loop_item'); ?> <figure class="fresco"> <?php $image_html = ""; do_action('thb_product_badge'); if (has_post_thumbnail()) { $image_html = wp_get_attachment_image(get_post_thumbnail_id(), 'shop_catalog'); } ?> <?php echo $image_html; ?> <div class="overlay"> <a class="quick quick-view" data-id="<?php echo $post->ID; ?> " href="#"><i class="icon-budicon-545"></i></a> </div> <div class="buttons"> <?php echo thb_wishlist_button(); ?> <div class="post-title<?php if ($catalog_mode == 'on') { echo ' catalog-mode'; } ?> "> <a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a> </div> <?php if ($catalog_mode != 'on') { ?> <?php /** * woocommerce_after_shop_loop_item_title hook * * @hooked woocommerce_template_loop_price - 10 */ do_action('woocommerce_after_shop_loop_item_title'); ?> <?php do_action('woocommerce_after_shop_loop_item'); ?> <?php } ?> </div> </figure> </article><!-- end product --> <?php } // end of the loop. ?> </div> <div class="ai-dotted ai-indicator"><span class="ai-inner1"></span><span class="ai-inner2"></span><span class="ai-inner3"></span></div> </div> <?php } ?> <?php } } } // $footer_products_radio ?> </section> <?php } }