Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 59525

Woocommerce Price (Changes sinces update)

$
0
0

Replies: 0

Hi,

I’m using WooCommerce on my website; for the product pages i used to have a breakdown of the price which showed the price +vat and excluding VAT. I think the code has changed since an update which has reverted the price back to the default display (Price +VAT)

Below is the code i was using could anyone let me know what i need to update?

<?php
/**
 * Single Product Price
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/single-product/price.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/
 * @package WooCommerce/Templates
 * @version 3.0.0
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly
}

global $product;

if ( $product->get_price_html() ) :
    // Get the prices
    $price_excl_tax = wc_get_price_excluding_tax( $product ); // price without VAT
    $price_incl_tax = wc_get_price_including_tax( $product );  // price with VAT
    $tax_amount     = $price_incl_tax - $price_excl_tax; // VAT amount

    // Display the prices
    ?>
    <span class="price price-excl"><?php echo wc_price( $price_excl_tax ); ?></span><br>
    <span class="price tax-price">+ VAT = <?php  echo wc_price( $tax_amount ); ?></span><br>
    <span class="price price-incl">Total = <?php echo wc_price( $price_incl_tax ); ?></span>
<?php endif ?>

Viewing all articles
Browse latest Browse all 59525

Trending Articles