php 轻松预订的早鸟价格(如果至少提前11天,则为-5%)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 轻松预订的早鸟价格(如果至少提前11天,则为-5%)相关的知识,希望对你有一定的参考价值。

add_filter( 'easy_booking_one_date_price', 'wceb_early_bird_pricing', 40, 5 );
add_filter( 'easy_booking_two_dates_price', 'wceb_early_bird_pricing', 40, 5 );

function wceb_early_bird_pricing( $new_price, $product, $_product, $booking_data, $price_type ) {

    // Get current date
    $current_date = strtotime( date( 'Y-m-d' ) );

    // Get start data
    $start_date = strtotime( $booking_data['start'] );

    // Get interval between current date and start date
    $interval = absint( ( $start_date - $current_date ) / 86400 );

    if ( $interval >= 11 ) {
        $new_price *= 0.95;
    }

    return $new_price;
}

// Maybe display price detail
add_filter( 'easy_booking_booking_price_details', 'wceb_display_early_bird_discount', 10, 3 );

function wceb_display_early_bird_discount( $details, $product, $booking_data ) {

    // Get current date
    $current_date = strtotime( date( 'Y-m-d' ) );

    // Get start data
    $start_date = strtotime( $booking_data['start'] );

    // Get interval between current date and start date
    $interval = absint( ( $start_date - $current_date ) / 86400 );

    if ( $interval >= 11 ) {
        $details .= '<br />' . __( 'Price include a 5% discount', 'easy_booking' );
    }

    return $details;
}

以上是关于php 轻松预订的早鸟价格(如果至少提前11天,则为-5%)的主要内容,如果未能解决你的问题,请参考以下文章

php 更改轻松预订的活动名称:日历

php [轻松预订]将订单状态栏添加到“报告”页面

早鸟票倒计时5天——国内首届领域驱动设计中国峰会

延长公告 | Steam游戏兑换券拿到手软 微星RTX30游戏本早鸟计划火热进行中!

php 如果在30天之前创建,则显示行

为什么有些人赚钱那么轻松