css
1 year ago
js
1 year ago
class-css.php
1 year ago
class-date.php
1 year ago
class-delivery-type.php
1 year ago
class-display-field.php
1 year ago
class-js.php
1 year ago
class-main.php
1 year ago
class-myaccount.php
1 year ago
class-order.php
1 year ago
class-pickup-location.php
1 year ago
class-shipping-method.php
1 year ago
class-time-range.php
1 year ago
class-time-slot.php
1 year ago
class-time.php
1 year ago
class-validate.php
1 year ago
class-woo-app.php
1 year ago
class-myaccount.php
77 lines
| 1 | <?php |
| 2 | |
| 3 | if ( ! defined( 'WPINC' ) ) { |
| 4 | die; |
| 5 | } |
| 6 | |
| 7 | class pisol_dtt_MyAccount{ |
| 8 | static $instance = null; |
| 9 | |
| 10 | public static function get_instance(){ |
| 11 | if(is_null(self::$instance)){ |
| 12 | self::$instance = new self(); |
| 13 | } |
| 14 | return self::$instance; |
| 15 | } |
| 16 | |
| 17 | function __construct(){ |
| 18 | add_action('woocommerce_account_orders_columns', array($this,'addOrderColumn')); |
| 19 | add_action('woocommerce_my_account_my_orders_column_pi_dtt', array(__CLASS__,'addOrderColumnContent'), 10, 1); |
| 20 | } |
| 21 | |
| 22 | function addOrderColumn($columns){ |
| 23 | $my_account_column_name = __('Order detail','pisol-dtt'); |
| 24 | if (array_key_exists('order-actions', $columns)) { |
| 25 | // Insert the new column just before the "Actions" column |
| 26 | $new_columns = array(); |
| 27 | foreach ($columns as $key => $value) { |
| 28 | if ($key === 'order-actions') { |
| 29 | $new_columns['pi_dtt'] = $my_account_column_name; // Add custom column before 'order-actions' |
| 30 | } |
| 31 | $new_columns[$key] = $value; // Add current column |
| 32 | } |
| 33 | }else{ |
| 34 | $new_columns = $columns; |
| 35 | $new_columns['pi_dtt'] = $my_account_column_name; |
| 36 | } |
| 37 | |
| 38 | return $new_columns; |
| 39 | } |
| 40 | |
| 41 | static function addOrderColumnContent($order){ |
| 42 | $order_id = $order->get_id(); |
| 43 | $order = wc_get_order($order_id); |
| 44 | $type = $order->get_meta( 'pi_delivery_type', true ); |
| 45 | |
| 46 | $delivery_type_label = esc_html__('Delivery type','pisol-dtt'); |
| 47 | |
| 48 | if($type == 'delivery'){ |
| 49 | $delivery_type = pisol_dtt_get_setting('pi_delivery_label', __('Delivery','pisol-dtt')); |
| 50 | }elseif($type == 'pickup'){ |
| 51 | $delivery_type = pisol_dtt_get_setting('pi_pickup_label', __('Pickup','pisol-dtt')); |
| 52 | }elseif($type == 'non-deliverable'){ |
| 53 | $delivery_type = ''; |
| 54 | } |
| 55 | |
| 56 | $dateLabel = __('Date','pisol-dtt'); |
| 57 | $timeLabel = __('Time','pisol-dtt'); |
| 58 | |
| 59 | $pickup_location_label = pisol_dtt_get_setting('pi_dtt_co_label_pickup_location_email', __('Pickup location','pisol-dtt')); |
| 60 | |
| 61 | $date = $order->get_meta( 'pi_system_delivery_date', true ); |
| 62 | $time = $order->get_meta( 'pi_delivery_time', true ); |
| 63 | |
| 64 | $location = $order->get_meta( 'pickup_location', true ); |
| 65 | |
| 66 | $html = ''; |
| 67 | $html .= $delivery_type ? '<div class="pi-delivery-type"><small><b>'.$delivery_type_label.'</b>: '.$delivery_type.'</small></div>' : ''; |
| 68 | $html .= $date ? '<div class="pi-delivery-date"><small><b>'.$dateLabel.'</b>: '.\pi_dtt_date::translatedDate($date).'</small></div>' : ''; |
| 69 | $html .= $time ? '<div class="pi-delivery-time"><small><b>'.$timeLabel.'</b>: '.\pisol_dtt_time::formatTimeForDisplay($time).'</small></div>' : ''; |
| 70 | $html .= $type == 'pickup' && $location ? '<div class="pi-delivery-location"><small><b>'.$pickup_location_label.'</b>: <span>'.$location.'</span></small></div>' : ''; |
| 71 | |
| 72 | $final_html = $html ? sprintf('<div class="pi-detail-container" style="margin-top:10px; margin-bottom:10px;">%s</div>', $html) : '-'; |
| 73 | echo wp_kses_post( apply_filters('pi_dtt_my_account_order_detail_col_content', $final_html, $order) ); |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | pisol_dtt_MyAccount::get_instance(); |