43 lines
1.2 KiB
PHP
43 lines
1.2 KiB
PHP
<?php
|
|
if (!defined('ABSPATH')) exit;
|
|
|
|
class Fusion_WooDoo_Order_Timeline {
|
|
|
|
/**
|
|
* Timeline stages in order. Key = _odoo_order_status value(s) that map to this stage.
|
|
*/
|
|
const STAGES = [
|
|
'confirmed' => 'Confirmed',
|
|
'processing' => 'Processing',
|
|
'shipped' => 'Shipped',
|
|
'delivered' => 'Delivered',
|
|
'done' => 'Completed',
|
|
];
|
|
|
|
public function __construct() {
|
|
add_action('woocommerce_order_details_after_order_table', [$this, 'render_timeline']);
|
|
}
|
|
|
|
public function render_timeline(WC_Order $order): void {
|
|
$odoo_status = strtolower((string) $order->get_meta('_odoo_order_status'));
|
|
|
|
if (empty($odoo_status)) {
|
|
return;
|
|
}
|
|
|
|
$tracking_number = $order->get_meta('_odoo_tracking_number');
|
|
$shipping_carrier = $order->get_meta('_odoo_shipping_carrier');
|
|
|
|
$stage_keys = array_keys(self::STAGES);
|
|
$current_index = array_search($odoo_status, $stage_keys);
|
|
if ($current_index === false) {
|
|
$current_index = 0;
|
|
}
|
|
|
|
$template = FUSION_WOODOO_PLUGIN_DIR . 'templates/my-account/order-timeline.php';
|
|
if (file_exists($template)) {
|
|
include $template;
|
|
}
|
|
}
|
|
}
|