29 posts
  • Referred between 1 and 9 users
  • Exclusive Author
  • Has been a member for 2-3 years
  • Europe
  • Sold between 10 000 and 50 000 dollars
  • Bought between 10 and 49 items
Design_Mania says

Hi,

I my having troubles trying to print woo commerce price in my template files for my new them.

What I am trying to do is to print single product price in a front slider carousel located in header.php.

<?php global $product; ?> query_posts(‘post_type=product&meta_key=slider&meta_value=1’); ?>
<?php if (have_posts()) : ?>

<?php endif ?> Fatal error : Call to a member function get_price_html() on a non-object in D:\xampp\htdocs\cooker\wp-content\themes\cooker\header.php on line 130 I noticed that I cannot get the product class if I use this piece of code before wp_footer().

<?php
29 posts
  • Referred between 1 and 9 users
  • Exclusive Author
  • Has been a member for 2-3 years
  • Europe
  • Sold between 10 000 and 50 000 dollars
  • Bought between 10 and 49 items
Design_Mania says

Ok I solve it.

Hope it will help to someone else.

global $woocommerce;

<?php $product = new WC_Product(the_ID()); ?>

<?php echo $product->get_price_html(); ?>

29 posts
  • Referred between 1 and 9 users
  • Exclusive Author
  • Has been a member for 2-3 years
  • Europe
  • Sold between 10 000 and 50 000 dollars
  • Bought between 10 and 49 items
Design_Mania says

Double post Sorry

37 posts
  • Sold between 100 000 and 250 000 dollars
  • Elite Author
  • Has been a member for 3-4 years
  • Exclusive Author
  • Europe
  • Bought between 100 and 499 items
  • Referred between 10 and 49 users
lidplussdesign says

Ok I solve it.

Hope it will help to someone else.

global $woocommerce;

<?php $product = new WC_Product(the_ID()); ?>

<?php echo $product->get_price_html(); ?>

You just saved my time, very appreciate this!

by
by
by
by
by
by