Hi Natasha
Thank you for the reply which pointed me down the right path. Here is the edited version I am using due to our product add-ons which have a cost adder. If there is a more elegant method of doing so I would be keen to improve.
add_action( 'easy_booking_add_booked_item', 'store_daily_rate', 10, 3 );
function store_daily_rate( $item, $start, $end ) {
$product_id = $item->get_product_id();
$product = wc_get_product( $product_id );
$base_price = $product->get_price();
if ( $end ) {
$start_time = strtotime( $start );
$end_time = strtotime( $end );
$duration = absint( ( $start_time - $end_time ) / 86400 +1 );
if ($duration >= 30) {
$daily_price = $base_price * 0.9;
}
elseif ($duration >= 7) {
$daily_price = $base_price * 0.95;
}
else {
$daily_price = $base_price;
}
$item->add_meta_data( '_daily_rate', wc_price( $daily_price ) );
}
}
Thank you!