Created
August 18, 2017 12:08
-
-
Save Auke1810/40efa63cc7cd32e4bc2fd837df1095af to your computer and use it in GitHub Desktop.
Te vinden in shelflife/includes/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* More Products Component | |
* | |
* Display X more products. | |
* | |
* @author Matty | |
* @since 1.0.0 | |
* @package WooFramework | |
* @subpackage Component | |
* | |
* @aangepast door Auke | |
* meta query aangepast waardoor we alleen featured producten laten zien. | |
*v.a. regel 36 - 57 | |
*/ | |
global $woocommerce; | |
$settings = array( | |
'product_limit' => '10', | |
'featured_exclude' => 'true' | |
); | |
$settings = woo_get_dynamic_values( $settings ); | |
if ( $settings['product_limit'] > 0 ) { | |
?> | |
<section id="more" class="fix"> | |
<h1 class="section-heading"><?php _e( 'More Products', 'woothemes' ); ?></h1> | |
<ul class="recent products fix"> | |
<?php | |
$i = 0; | |
$meta_query = WC()->query->get_meta_query(); | |
$tax_query = WC()->query->get_tax_query(); | |
$tax_query[] = array( | |
'taxonomy' => 'product_visibility', | |
'field' => 'name', | |
'terms' => 'featured', | |
'operator' => 'IN', | |
); | |
$args = array( | |
'post_type' => 'product', | |
'post_status' => 'publish', | |
'ignore_sticky_posts' => 1, | |
'posts_per_page' => $atts['per_page'], | |
'orderby' => $atts['orderby'], | |
'order' => $atts['order'], | |
'meta_query' => $meta_query, | |
'tax_query' => $tax_query, | |
); | |
$loop = new WP_Query( $args ); | |
$count = 0; | |
while ( $loop->have_posts() ) { | |
$loop->the_post(); | |
if ( function_exists( 'get_product' ) ) { | |
$_product = get_product( $loop->post->ID ); | |
} else { | |
$_product = new WC_Product( $loop->post->ID ); | |
} | |
$count++; | |
?> | |
<li class="product <?php $i++; if( 1 == $i ) { echo 'first'; } else if( 4 == $i ) { $i = 0; echo 'last'; }?>"> | |
<?php do_action( 'woocommerce_before_shop_loop_item' ); ?> | |
<div class="img-wrap"> | |
<?php woocommerce_show_product_sale_flash( $post, $_product ); ?> | |
<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); ?>"> | |
<?php | |
if ( has_post_thumbnail( $loop->post->ID ) ) { | |
echo get_the_post_thumbnail( $loop->post->ID, 'shop_single' ); | |
} else { | |
$image_size = wc_get_image_size( 'shop_single' ); | |
echo '<img src="'. esc_url( $woocommerce->plugin_url() . '/assets/images/placeholder.png' ) . '" alt="Placeholder" width="' . esc_attr( $image_size['width'] ) . '" height="' . esc_attr( $image_size['height'] ) . '" />'; | |
} | |
?> | |
</a> | |
</div> | |
<div class="meta"> | |
<h3><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3> | |
<span class="price"><?php echo $_product->get_price_html(); ?></span> | |
<?php woocommerce_template_loop_add_to_cart( $loop->post, $_product ); ?> | |
</div><!--/.meta--> | |
<?php do_action( 'woocommerce_after_shop_loop_item' ); ?> | |
</li> | |
<?php | |
} | |
wp_reset_postdata(); | |
?> | |
</ul><!--/ul.recent--> | |
<?php | |
$shop_page_url = ''; | |
$shop_page_id = get_option( 'woocommerce_shop_page_id' ); | |
if ( $shop_page_id != '' ) { | |
$shop_page_url = get_permalink( intval( $shop_page_id ) ); | |
} | |
if ( $shop_page_url != '' ) { | |
?> | |
<div class="more-products-link"> | |
<a class="button" href="<?php echo esc_url( $shop_page_url ); ?>" title="<?php esc_attr_e( 'More Products', 'woothemes' ); ?>"><?php _e( 'More Products', 'woothemes' ); ?></a> | |
</div> | |
<?php | |
} ?> | |
</section> | |
<?php | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment