Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  • Hook Reference
  • Docs Home

Packages

  • None
  • Order-Delivery-Date-Lite-for-WooCommerce
    • Admin
      • Delivery-Date-on-Edit-Order-Page
      • Display-Holidays
      • Pro-Notices
      • Settings
      • Welcome-Page
    • Common-Functions
    • Frontend
      • Checkout-Page-Processes
    • Integrate-Delivery-Date

Classes

  • orddd_lite_common
  • orddd_lite_filter
  • orddd_lite_integration
  • orddd_lite_pro_notices
  • orddd_lite_process
  • orddd_lite_settings
  • ORDDD_LITE_View_Holidays_Table
  • ORDDD_Welcome
  • order_delivery_date_lite
  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 
/**
* Order Delivery Date for WooCommerce Lite
*
* Integration of the WooCommerce Order Delivery Date plugin with various 3rd party plugins 
*
* @author      Tyche Softwares
* @package     Order-Delivery-Date-Lite-for-WooCommerce/Integrate-Delivery-Date
* @since       3.5
*/

include_once( dirname( __FILE__ ) . '/orddd-lite-common.php' );
/** 
 * Integration class to integrate the WooCommerce Order Delivery Date plugin with various 3rd party plugins
 * 
 * @class orddd_lite_integration
 */
class orddd_lite_integration {
     /**
     * Default Constructor
     * 
     * @since 3.5
     */    
    public function __construct() {     
        // WooCommerce PDF Invoices & Packing Slips
        add_action( 'wpo_wcpdf_after_order_details', array( &$this, 'orddd_lite_plugins_packing_slip' ) );
        
        // add custom columns headers to csv when Order/Customer CSV Export Plugin is activate
        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 );
        
        //WooCommerce Print Invoice & Delivery Note     
        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' ) );
        
        //WooCommerce Print Invoice/Packing list plugin
        add_action( 'wc_pip_after_body', array( &$this, 'orddd_lite_woocommerce_pip' ), 10, 4 );
    }

    /**
     * Adds delivery date and time selected for an order in the PDF invoices
     * and Packing slips from WooCommerce PDF Invoices & Packing Slips plugin.
     *
     * @hook wpo_wcpdf_after_order_details
     * @since 1.7
     */
    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;
        }
    }

    /**
     * Adds delivery date and time column headings to CSV when order
     * is exported from Order/Customer CSV Export Plugin.
     *
     * @param array $column_headers - List of Column Names
     * @return array $column_headers - The list of column names
     *
     * @hook wc_customer_order_csv_export_order_headers
     * @since 1.7
     */
    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 );
    }

    /**
     * Adds delivery date and time column content to CSV when order
     * is exported from Order/Customer CSV Export Plugin.
     *
     * @param array $order_data -
     * @param object $order - Order Details
     * @param object $csv_generator
     * @return array $new_order_data - Delivery data
     *
     * @hook wc_customer_order_csv_export_order_row
     * @since 1.7
     */
    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;
    }

    /**
     * Adds delivery date and time selected for an order in the invoices
     * and delivery notes from WooCommerce Print Invoice & Delivery Note plugin.
     *
     * @param array $fields - List of fields
     * @param object $order
     * @return array $fields - with the delivery data added
     *
     * @hook wcdn_order_info_fields
     * @since 1.7
     */
    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 );
    }
    
    /**
     * Adds delivery date and time selected for an order
     * in the prints from WooCommerce Print Orders plugin.
     *
     * @param object $order - Order Details
     *
     * @hook woocommerce_cloudprint_internaloutput_footer
     * @since 1.7
     */
    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;
    }
    
    /**
     * Adds delivery date and time selected for an order in the invoices
     * and delivery notes from WooCommerce Print Invoice/Packing list plugin.
     *
     * @param $type
     * @param $action
     * @param $document
     * @param object $order - Order Details
     *
     * @hook wc_pip_after_body
     * @since 1.7
     */
    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();
?>
API documentation generated by ApiGen