Skip to content

Instantly share code, notes, and snippets.

@Dinamiko Dinamiko/dkpdf-wc-03.php
Last active Jan 25, 2016

Embed
What would you like to do?
<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
You can’t perform that action at this time.