Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save guilhermealveslopes/f9a2fbac57176d378379b905d1a9abb9 to your computer and use it in GitHub Desktop.
Save guilhermealveslopes/f9a2fbac57176d378379b905d1a9abb9 to your computer and use it in GitHub Desktop.
Share Product Woocommerce ADDTOANY
<ul class="products">
<?php
$user_id = get_current_user_id();
$current_user= wp_get_current_user();
$customer_email = $current_user->email;
$args = array(
'post_type' => 'product',
'posts_per_page' => 12
);
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) {
while ( $loop->have_posts() ) : $loop->the_post(); $_product = get_product( $loop->post->ID );
if (wc_customer_bought_product($customer_email, $user_id,$_product->id)){ ?>
<?php the_title(); ?>
<div class="a2a_kit a2a_kit_size_32 a2a_default_style">
<a class="a2a_button_facebook"></a>
<a class="a2a_button_twitter"></a>
<a class="a2a_button_google_plus"></a>
<a class="a2a_dd" href="https://www.addtoany.com/share"></a>
</div>
<script type="text/javascript">
var a2a_config = a2a_config || {};
a2a_config.linkname = 'Example Page';
a2a_config.linkurl = [['<?php echo the_permalink(); ?>']];;
a2a_config.num_services = 10;
a2a_config.show_title = 1;
</script>
<script async src="//static.addtoany.com/menu/page.js"></script>
<?php
}
endwhile;
} else {
echo __( 'No products found' );
}
wp_reset_postdata();
?>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment