php [WooCommerce预订]自动确认通过COD购买的预订

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php [WooCommerce预订]自动确认通过COD购买的预订相关的知识,希望对你有一定的参考价值。

/**
 * Will put bookings into a Confirmed status if they were paid for via COD.
 * 
 * @param int $order_id The order id
 */
function set_cod_bookings_confirmed_20170825( $order_id ) {
	
	// Get the order, then make sure its payment method is COD.
	$order = wc_get_order( $order_id );
	if ( 'cod' !== $order->get_payment_method() ) {
		return;
	}
	// Call the data store class so we can get bookings from the order.
	$booking_data = new WC_Booking_Data_Store();
	$booking_ids  = $booking_data->get_booking_ids_from_order_id( $order_id );
	// If we have bookings go through each and update the status.
	if ( is_array( $booking_ids ) && count( $booking_ids ) > 0 ) {
		foreach ( $booking_ids as $booking_id ) {
			$booking = get_wc_booking( $booking_id );
			$booking->update_status( 'confirmed' );
		}
	}
}
add_action( 'woocommerce_order_status_processing', 'set_cod_bookings_confirmed_20170825', 20 );

以上是关于php [WooCommerce预订]自动确认通过COD购买的预订的主要内容,如果未能解决你的问题,请参考以下文章

php WooCommerce预订 - 首次预订的默认日历

php [WooCommerce预订]在购物车预订到期时修改

php [WooCommerce预订]将日历默认为第一次预订

php [WooCommerce预订] - 产品依赖

php WooCommerce预订 - 更改购物车到期日

php [WooCommerce预订]使用案例:创建一周的后续行动