1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
<?php
if (!class_exists('Booking_Information_In_Voucher_Template')) {
class Booking_Information_In_Voucher_Template {
public $plugin_version = '1.0';
public function __construct() {
add_filter('woo_vou_pdf_template_inner_html', array( &$this, 'woo_vou_pdf_template_replace_shortcodes'), 10, 6 );
}
public static function woo_vou_pdf_template_replace_shortcodes( $voucher_template_html, $orderid, $item_key, $items, $voucodes, $productid ) {
$order = new WC_Order( $orderid );
$order_items = $order->get_items();
foreach( $order_items as $k => $v ) {
$buyerstartdate = isset( $v['wapbk_booking_date'] ) ? $v['wapbk_booking_date'] : '';
$buyerenddate = isset( $v['wapbk_checkout_date'] ) ? $v['wapbk_checkout_date'] : '';
$buyertime = isset( $v['wapbk_time_slot'] ) ? $v['wapbk_time_slot'] : '';
}
$bkap_date_format = apply_filters("bkap_change_date_format", "j.n.Y" );
$buyerstart_date_formatted = date_create_from_format( 'Y-m-d', $buyerstartdate );
$start_date_format = date_format( $buyerstart_date_formatted, $bkap_date_format );
$buyerend_date_formatted = date_create_from_format( 'Y-m-d', $buyerenddate );
$end_date_format = date_format( $buyerend_date_formatted, $bkap_date_format );
$voucher_template_html = str_replace( '{booking_start_date}', $start_date_format, $voucher_template_html );
$voucher_template_html = str_replace( '{booking_end_date}', $end_date_format, $voucher_template_html );
$voucher_template_html = str_replace( '{booking_timeslot}', $buyertime, $voucher_template_html );
return $voucher_template_html;
}
}
}
$booking_information_in_voucher_template = new Booking_Information_In_Voucher_Template();