Skip to content

Instantly share code, notes, and snippets.

@Ashanna
Ashanna / functions.php
Created August 21, 2019 14:14
Remove Pending Payment order status from Easy Booking.
add_filter( 'woocommerce_cod_process_payment_order_status', 'change_cod_payment_order_status', 10, 2 );
add_filter( 'woocommerce_bacs_process_payment_order_status', 'change_cod_payment_order_status', 10, 2 );
function change_cod_payment_order_status( $order_status, $order ) {
return 'pending-payment';
}
add_filter( 'easy_booking_get_order_statuses', 'wceb_remove_order_status', 10, 1 );
function wceb_remove_order_status( $statuses ) {
@Ashanna
Ashanna / functions.php
Created March 29, 2019 14:10
Compatibility between Availability Check and WPML (not duplicates)
add_action( 'ebac_order_processed', 'ebac_wpml_compatibility', 10, 3 );
function ebac_wpml_compatibility( $item, $keep_stock_id, $booked ) {
global $sitepress;
$trid = $sitepress->get_element_trid( $keep_stock_id, 'post_product' );
if ( is_numeric( $trid ) ) {
$translations = $sitepress->get_element_translations( $trid, 'post_product' );
@Ashanna
Ashanna / functions.php
Created March 26, 2019 14:42
Compatibilty between Availability Check and WPML (Duplicate products only)
add_action( 'ebac_order_processed', 'ebac_wpml_compatibility', 10, 3 );
function ebac_wpml_compatibility( $item, $keep_stock_id, $booked ) {
$original_post_id = apply_filters( 'wpml_master_post_from_duplicate', $keep_stock_id );
if ( ! empty( $original_post_id ) ) {
$start = $item['ebs_start_format'];
$end = isset( $item['ebs_end_format'] ) ? $item['ebs_end_format'] : $start;
@Ashanna
Ashanna / functions.php
Last active March 4, 2019 13:56
Compatibilty with WooCommerce Membership for Multivendor Marketplace
add_action( 'after_wcfm_products_manage_meta_save', 'wceb_compatibility_with_wcfm', 10, 2 );
function wceb_compatibility_with_wcfm( $id, $data ) {
$booking_data = array(
'bookable' => isset( $data['_booking_option'] ) ? 'yes' : false,
'dates' => isset( $data['_booking_dates'] ) ? $data['_booking_dates'] : '',
'booking_min' => isset( $data['_booking_min'] ) ? $data['_booking_min'] : '',
'booking_max' => isset( $data['_booking_max'] ) ? $data['_booking_max'] : '',
'first_available_date' => isset( $data['_first_available_date'] ) ? $data['_first_available_date'] : '',
@Ashanna
Ashanna / functions.php
Created October 3, 2018 07:37
Change event name for Easy Booking: Calendar
add_filter( 'easy_booking_calendar_event_summary', 'add_custom_event_name', 10, 3 );
function add_custom_event_name( $name, $order_item, $order ) {
$name = '#' . absint( $order->get_order_number() ) . ' - ' . $order_item->get_name(); // Default name
return $name;
}
@Ashanna
Ashanna / functions.php
Last active August 21, 2018 12:35
Include product options with Google Calendar
add_filter( 'easy_booking_calendar_event_description', 'add_custom_event_description', 10, 3 );
function add_custom_event_description( $description, $order_item, $order ) {
$description = '<p>Client: ' . $order->get_formatted_billing_full_name() . '</p>';
$meta_data = $order_item->get_formatted_meta_data();
if ( ! empty( $meta_data ) ) {
foreach ( $meta_data as $meta_id => $data ) {
@Ashanna
Ashanna / functions.php
Created June 26, 2018 08:31
Deposits 2 (free version)
add_filter( 'easy_booking_set_booking_price', 'wceb_yith_deposit_price', 10, 2 );
function wceb_yith_deposit_price( $booking_price, $cart_item ) {
if ( isset( $cart_item['deposit'] ) && true === $cart_item['deposit'] && isset( $cart_item['deposit_value'] ) ) {
$product = $cart_item['data'];
$product_id = $product->is_type( 'variation' ) ? $product->get_parent_id() : $product->get_id();
$variation_id = $product->is_type( 'variation' ) ? $product->get_id() : false;
$booking_price = YITH_WCDP()->get_deposit( $product_id, $booking_price, false, $variation_id );
@Ashanna
Ashanna / functions.php
Last active June 26, 2018 08:56
Deposits
add_filter( 'easy_booking_set_booking_price', 'wceb_yith_deposit_price', 10, 2 );
function wceb_yith_deposit_price( $booking_price, $cart_item ) {
if ( isset( $cart_item['deposit'] ) && true === $cart_item['deposit'] && isset( $cart_item['deposit_value'] ) ) {
$product = $cart_item['data'];
$product_id = $product->is_type( 'variation' ) ? $product->get_parent_id() : $product->get_id();
$variation_id = $product->is_type( 'variation' ) ? $product->get_id() : false;
$booking_price = YITH_WCDP_Premium()->get_deposit( $product_id, $booking_price, 'edit', false, $variation_id );
@Ashanna
Ashanna / functions.php
Last active June 21, 2018 07:06
Check that all items in cart have the same date(s)
add_action( 'woocommerce_check_cart_items', 'wceb_check_dates_in_cart', 10, 1 );
function wceb_check_dates_in_cart() {
$return = true;
$start_date = '';
$end_date = '';
$i = 0;
foreach ( WC()->cart->get_cart() as $cart_item_key => $values ) {
@Ashanna
Ashanna / functions.php
Created March 28, 2018 06:33
[Easy Booking] Remove "Booking status" column from the reports page.
add_filter( 'easy_booking_reports_columns', 'wceb_reports_columns', 10, 1 );
function wceb_reports_columns( $columns ) {
unset( $columns['booking_status'] );
return $columns;
}