Skip to content

Instantly share code, notes, and snippets.

@Dinamiko
Last active January 25, 2016 11:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dinamiko/612a484a1c8780dd6eef to your computer and use it in GitHub Desktop.
Save Dinamiko/612a484a1c8780dd6eef to your computer and use it in GitHub Desktop.
<body>
<?php
global $post;
$pdf = get_query_var( 'pdf' );
$post_type = get_post_type( $pdf );
if( $pdf && $post_type == 'product' ) {
$title = get_the_title();
if( has_post_thumbnail( $post->ID ) ) {
$thumbnail = get_the_post_thumbnail( $post->ID, 'medium' );
}
$description = get_the_excerpt();
$product = new WC_Product( $post->ID );
$currency = get_woocommerce_currency_symbol();
$regular_price = get_post_meta( $post->ID, '_regular_price');
$sale_price = get_post_meta( $post->ID, '_sale_price');
$link = get_the_permalink(); ?>
<div class="product-container">
<div class="product-left">
<?php if( $thumbnail ) { echo $thumbnail; } ?>
</div>
<div class="product-right">
<h1><?php echo esc_attr( $title );?></h1>
<?php
if( $sale_price[0] != '' ) { ?>
<h2>
<span class="price line-through"><?php echo esc_attr( $regular_price[0] ). $currency; ?></span>
<span class="price"><?php echo esc_attr( $sale_price[0] ). $currency; ?></span>
</h2>
<?php } else { ?>
<h2><span class="price"><?php echo esc_attr( $regular_price[0] ). $currency; ?></span></h2>
<?php }
?>
<p><?php echo esc_html( $description );?></p>
<div class="button-container">
<div class="button-item">
<a style="font-weight:bold;text-decoration:none;color:#FFF;" href="<?php echo esc_url( $link );?>">Buy Me!</a>
</div>
</div>
</div>
</div>
<?php }
?>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment