Colin
Colin

Reputation: 735

Get Base Price in WooCommerce Bookings

I have a product in WooCommerece that has a display and base price. The following code is used:

global $woocommerce;

    foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $cart_item ) {
        $productID = $cart_item['product_id'];
        break; //Take the first as an example
    } 
    $product = new WC_Product($productID);
    $base_price= $product->get_price();
    $display_price = $product->get_display_price();

My issue is, the base and display price come back as the same value but they are maintained differently in the back end.

Update: Tax Settings

I understand this issue may be related to Tax settings. Here are mine:

There is also a blanket standard rate which is zero-rate.

And for the Product:

Update

The issue stems from the fact I am using the WooCommerence Booking plugin. To get the base price of a booking:

global $woocommerce;

foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $cart_item ) {
    $productID = $cart_item['product_id'];
    break;//Take the first as an example
} 

$product = new WC_Product($productID);
$admission = $product->wc_booking_cost;

Upvotes: 2

Views: 3165

Answers (1)

MirzaP
MirzaP

Reputation: 738

$product->get_regular_price() returns the regular price.

$product->get_sale_price() returns the sale price if product is on sale.

$product->get_price() returns the price of product (sale or regular depending on what is current).

$product->get_display_price() Returns the price including or excluding tax, based on the 'woocommerce_tax_display_shop' setting.

Upvotes: 4

Related Questions