43 posts
  • Has referred 1+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
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
43 posts
  • Has referred 1+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
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(); ?>

43 posts
  • Has referred 1+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
Design_Mania says

Double post Sorry

55 posts
  • Has referred 10+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 100+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+3 more
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!

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by