I'm using Woocommerce Bookings with only a base cost filled. No other rules. How do I display product price in a loop like this?
<?php
$args = array( 'post_type' => 'product', 'posts_per_page' => -1 );
$loop = new WP_Query( $args );
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
ID is: <?php the_ID(); ?>
Title is: <?php the_title(); ?>
Price: <?php echo esc_html( get_post_meta( get_the_ID(), '_regular_price', true ) ); ?>
<?php endwhile; wp_reset_query(); ?>
The price field didn't show anything
UPDATE
another code I tried:
<?php
global $woocommerce;
$product = new WC_Product_Booking($productID);
$base_price = $product->get_price();
$product_data = $product->get_data();
$product_pricing = get_post_meta( $product_id, '_wc_booking_pricing', true);
?>
<?php echo $product_pricing; ?>
<?php echo $base_price;?>
both also return the value of zero
ANOTHER TRY
<?php
global $woocommerce;
$product = new WC_Product_Booking($productID);
$product = wc_get_product( $product_id );
$base_price = $product->get_price();
$product_data = $product->get_data();
$product_pricing = $product_data['pricing'];
foreach($product_pricing as $key => $princing ){
$pricing_type = $princing['type'];
$pricing_base_cost = $princing['base_cost'];
$pricing_base_modifier = $princing['base_modifier'];
$pricing_cost = $princing['cost'];
$pricing_modifier = $princing['modifier'];
$pricing_from = $princing['from'];
$pricing_to = $princing['to'];
}
$pricing_data = get_post_meta( $product_id, '_wc_booking_pricing', false); ?>
<?php echo $pricing_data; ?>
nothing works :( they're all either showing blanks or showing zero. Can anyone help point in the right direction?
many thanks