Skip to content

Instantly share code, notes, and snippets.

@stompweb
Created July 13, 2017 12:31
Show Gist options
  • Save stompweb/f1b379231f49bd523a935e83df364ee0 to your computer and use it in GitHub Desktop.
Save stompweb/f1b379231f49bd523a935e83df364ee0 to your computer and use it in GitHub Desktop.
<?php
/**
* The template for displaying product content within loops
*
* This template can be overridden by copying it to yourtheme/woocommerce/content-product.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates
* @version 3.0.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
global $product;
?>
<?php if ( is_tax() ) { ?>
<div class="col-lg-4 col-sm-6">
<?php } else { ?>
<div class="col-lg-3 col-md-4 col-sm-6">
<?php } ?>
<div class="shop-product">
<?php if ( product_has_savings() ) { ?>
<div class="member-offer">Member Offer</div>
<?php } ?>
<div class="image">
<a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail( 'news-thumbnail' ); ?>
</a>
</div>
<div class="detail">
<h2 class="part-title">
<a href="<?php the_permalink(); ?>">
<?php the_title(); ?>
</a>
</h2>
<div class="row">
<div class="col-xs-8">
<?php if ( is_post_type_archive() || is_front_page() ) {
$category = wp_get_post_terms( get_the_ID(), 'product_cat' );
if ( '' != $category[0] ) { ?>
<p>
<a href="<?php echo esc_url( get_term_link( $category[0] ) ); ?>">
<?php echo esc_html( $category[0]->name ); ?>
</a>
</p>
<?php } ?>
<?php if ( product_has_savings() ) { ?>
<p class="price">
<strike>RRP <?php the_product_rrp(); ?></strike>
<?php the_product_price(); ?>
</p>
<?php } else { ?>
<p class="price">RRP <?php the_product_price(); ?></p>
<?php } ?>
<?php } else { ?>
<?php if ( product_has_savings() ) { ?>
<p class="price no-cat"><strike>RRP <?php the_product_rrp(); ?></strike> <?php the_product_price(); ?></p>
<?php } else { ?>
<p class="price no-cat">RRP <?php the_product_price(); ?></p>
<?php } ?>
<?php } ?>
</div>
<div class="col-xs-4">
<div class="linked-button">
<a href="<?php the_permalink(); ?>" class="btn btn-outlined btn-primary-filled">
View
</a>
</div>
</div>
</div>
</div>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment