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

Packages

  • None
  • Product-Delivery-Date-Pro-for-WooCommerce
    • Addon
    • Admin
      • Settings
        • Field-Labels
        • General
        • Google-Sync
      • View-Deliveries
    • Calendar
    • Common-Functions
    • Configuration
    • Delivery-Charges
    • Edit-Deliveries
    • Emails
    • Frontend
      • Cart
      • Checkout
    • Google-Calendar
    • Languages
    • License
    • Reschedule-Deliveries
    • View-Deliveries

Classes

  • EDD_PRDD_Plugin_Updater
  • prdd_addon_compatibility_class
  • prdd_admin_deliveries
  • prdd_adminevent_jsons
  • prdd_box_class
  • prdd_cart
  • prdd_checkout
  • prdd_common
  • prdd_delivery_labels_settings
  • prdd_delivery_settings
  • prdd_edit_deliveries_class
  • PRDD_Email_Delivery_Rescheduled
  • PRDD_Email_Delivery_Rescheduled_Admin
  • PRDD_Email_Manager
  • prdd_estimate_delivery
  • prdd_global_menu
  • prdd_ics
  • prdd_license
  • prdd_process
  • prdd_rescheduled_order_class
  • prdd_special_delivery_price
  • prdd_timeslot_price
  • prdd_validation
  • PRDD_View_Deliveries_Table
  • ts_google_calendar_sync
  • ts_google_calendar_sync_settings
  • TsGcal
  • view_deliveries
  • woocommerce_prdd

Functions

  • is_prdd_active
  • prdd_get_dateToCal
  • prdd_get_delivery_arrays
  • prdd_get_delivery_t
  • prdd_get_escapeString
  • prdd_woocommerce_delete
  • ts_get_option
  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 
<?php 
/**
 * Product Delivery Date Pro for WooCommerce
 *
 * Handles the JSON output for deliveries to be displayed in Calendar View for admin.
 *
 * @author   Tyche Softwares
 * @package  Product-Delivery-Date-Pro-for-WooCommerce/Calendar
 * @since    1.0
 */
include_once( 'prdd-common.php' );

if ( !class_exists( 'prdd_admin_deliveries' ) ) {
    /**
     * Class for deliveries for Calendar view
     *
     * @since 1.0
     */   
    class prdd_admin_deliveries {
        
        public function __construct() {

            // Add the Edit Delivery link in Woo->Orders edit orders page
            add_action( 'woocommerce_admin_order_item_headers', array( $this, 'prdd_link_header' ) );
            add_action( 'woocommerce_admin_order_item_values', array( $this, 'prdd_link' ), 10, 3 );
        }
        
        /**
         * Create a column in WooCommerce->Orders->Edit Orders page for each item
         *
         * @hook woocommerce_admin_order_item_headers
         * @since 1.0
         */
        function prdd_link_header() {
           ?><th>&nbsp;</th><?php
        }
        
        /**
         * Display Edit Delivery Link. Add the Edit Delivery Link for a given item in WooCommerce->orders Edit Orders page.
         * 
         * @hook  woocommerce_admin_order_item_values
         * @param object $_product Product
         * @param array $item The item being displayed
         * @param int $item_id The id of the item being displayed
         * @global object $wpdb Global wpdb object
         * @since 1.0 
         */
        function prdd_link( $_product, $item, $item_id ) {
            global $wpdb;
            
            if ( isset( $_product ) && !empty( $_product ) ) {
                $product_id = $_product->get_id();
                $product_type = $_product->get_type();
                
                if( $product_type == 'variation' ) {
                    if( version_compare( get_option( 'woocommerce_version ' ), '3.0.0', ">=" ) ) {
                        $product_id = $_product->get_parent_id();
                    } else {
                        $product_id = $_product->parent_id;    
                    }
                }
                // get the booking settings for the product
                $prdd_settings = get_post_meta( $product_id, 'woocommerce_prdd_settings', true );

                // order ID
                $query_order_id = "SELECT order_id FROM `". $wpdb->prefix."woocommerce_order_items`
                            WHERE order_item_id = %d";
                $get_order_id = $wpdb->get_results( $wpdb->prepare( $query_order_id, $item_id ) );
                
                $order_id = 0;
                if ( isset( $get_order_id ) && is_array( $get_order_id ) && count( $get_order_id ) > 0 ) {
                    $order_id = $get_order_id[0]->order_id;
                }

                $order = new WC_Order ( $order_id );

                if ( isset( $prdd_settings[ 'prdd_enable_date' ] ) && $prdd_settings[ 'prdd_enable_date' ] == 'on' ) {
                    //$args = array( 'post' => $booking_post_id, 'action' => 'edit' );
                    echo "<td>";
                         $prdd_details = array(
                            'date' => '',
                            'hidden_date' => '',
                            'price' => '' );

                        foreach ( $item->get_meta_data() as $meta_index => $meta ) {
                            if ( $meta->key === get_option( 'delivery_item-meta-date' ) ) {
                                $prdd_details[ 'date' ] = $meta->value;
                            } elseif ( $meta->key === '_prdd_date' ) {
                                $hidden_date = explode( '-', $meta->value );
                                $prdd_details[ 'hidden_date' ] = $hidden_date[2] . '-' . $hidden_date[1] . '-' . $hidden_date[0];
                            } elseif ( $meta->key === get_option( 'delivery_item-meta-time' ) ){
                                $prdd_details[ 'time_slot' ] = $meta->value;
                            }
                        }

                        if( $prdd_details[ 'date' ] != '' ) {
                            printf( '<a href="javascript:void(0)" onclick="prdd_edit_delivery_class.prdd_edit_deliveries(%d,%s)">%s</a>',  $item->get_product_id( 'view' ), $item_id, __( 'Edit Delivery', 'woocommerce-prdd' ) );
                            do_action( 'prdd_woo_order_item_values', $_product, $item, $item_id );
                            
                            $localized_array = array( 
                                'prdd_delivery_params' => $prdd_details,
                                'prdd_cart_item' => $item,
                                'prdd_cart_item_key' => $item_id,
                                'prdd_order_id' => $order->get_id(),
                                'prdd_page_type' => 'view-order'
                            );

                            
                            prdd_edit_deliveries_class::prdd_load_template( 
                                $prdd_details, 
                                $item->get_product(), 
                                $item->get_product_id( 'view' ), 
                                $localized_array,
                                $item_id,
                                $item->get_variation_id( 'view' ) );    
                        }
                    echo "</td>";
                } else {
                    echo '<td></td>';
                }
            } else {
                echo '<td></td>';
            }
        }
    }
}
$prdd_admin_deliveries = new prdd_admin_deliveries();
?>
API documentation generated by ApiGen