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 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
<?php
include_once( dirname( __FILE__ ) . '/orddd-lite-common.php' );
class orddd_lite_integration {
public function __construct() {
add_action( 'wpo_wcpdf_after_order_details', array( &$this, 'orddd_lite_plugins_packing_slip' ) );
add_filter( 'wc_customer_order_csv_export_order_headers', array( &$this, 'orddd_lite_csv_export_modify_column_headers' ) );
add_filter( 'wc_customer_order_csv_export_order_row', array( &$this, 'orddd_lite_csv_export_modify_row_data' ), 10, 3 );
add_filter( 'wcdn_order_info_fields', array( &$this, 'orddd_lite_print_invoice_delivery_note' ), 10, 2 );
add_action( 'woocommerce_cloudprint_internaloutput_footer', array( &$this, 'orddd_lite_cloud_print_fields' ) );
add_action( 'wc_pip_after_body', array( &$this, 'orddd_lite_woocommerce_pip' ), 10, 4 );
}
function orddd_lite_plugins_packing_slip() {
global $wpo_wcpdf, $orddd_lite_date_formats;
$order_export = $wpo_wcpdf->export;
$order_obj = $order_export->order;
$order_id = $order_obj->id;
$delivery_date_formatted = orddd_lite_common::orddd_lite_get_order_delivery_date( $order_id );
if( $delivery_date_formatted != '' ) {
echo '<p><strong>' . __( get_option( 'orddd_lite_delivery_date_field_label' ), 'order-delivery-date' ) . ': </strong>' . $delivery_date_formatted;
}
}
function orddd_lite_csv_export_modify_column_headers( $column_headers ) {
$new_headers = array(
'column_1' => __( get_option( 'orddd_lite_delivery_date_field_label' ), 'order-delivery-date' )
);
return array_merge( $column_headers, $new_headers );
}
public static function orddd_lite_csv_export_modify_row_data( $order_data, $order, $csv_generator ) {
$new_order_data = $custom_data = array();
$order_id = $order->id;
$delivery_date_formatted = orddd_lite_common::orddd_lite_get_order_delivery_date( $order_id );
$custom_data = array(
'column_1' => $delivery_date_formatted,
);
if ( isset( $csv_generator->order_format ) && ( 'default_one_row_per_item' == $csv_generator->order_format || 'legacy_one_row_per_item' == $csv_generator->order_format ) ) {
foreach ( $order_data as $data ) {
$new_order_data[] = array_merge( (array) $data, $custom_data );
}
} else {
$new_order_data = array_merge( $order_data, $custom_data );
}
return $new_order_data;
}
function orddd_lite_print_invoice_delivery_note( $fields, $order ) {
$new_fields = array();
$order_id = $order->id;
$delivery_date_formatted = orddd_lite_common::orddd_lite_get_order_delivery_date( $order_id );
if( $delivery_date_formatted != '' ) {
$new_fields[ get_option( 'orddd_lite_delivery_date_field_label' ) ] = array(
'label' => __( get_option( 'orddd_lite_delivery_date_field_label' ), 'order-delivery-date' ),
'value' => $delivery_date_formatted
);
}
return array_merge( $fields, $new_fields );
}
function orddd_lite_cloud_print_fields( $order ) {
$field_date_label = get_option( 'orddd_lite_delivery_date_field_label' );
$order_id = $order->id;
$delivery_date_formatted = orddd_lite_common::orddd_lite_get_order_delivery_date( $order_id );
echo '<p><strong>'.__( $field_date_label, 'order-delivery-date' ) . ': </strong>' . $delivery_date_formatted;
}
function orddd_lite_woocommerce_pip( $type, $action, $document, $order ) {
global $orddd_date_formats;
$delivery_date = get_option( 'orddd_lite_delivery_date_field_label' );
$order_id = $order->id;
$delivery_date_formatted = orddd_lite_common::orddd_lite_get_order_delivery_date( $order_id );
if( $delivery_date_formatted != '' ) {
echo '<p><strong>' . __( $delivery_date, 'order-delivery-date' ) . ': </strong>' . $delivery_date_formatted;
}
}
}
$orddd_lite_integration = new orddd_lite_integration();
?>