// Shortcode affichage commandes avec filtre add_shortcode('wc_order_manager', function() { if (!is_user_logged_in()) return '

Connectez-vous pour voir vos commandes.

'; // Statuts affichés (personnalisés) $statuses = [ 'all' => 'Tous', 'wc-processing' => 'En préparation', 'wc-pending' => 'En attente', 'wc-cancelled' => 'Annulé', 'wc-completed' => 'Livré', 'wc-finished' => 'Terminé', ]; // HTML Nav-bar filtre $html = ''; // Container commandes (chargées par AJAX) $html .= '
Chargement des commandes...
'; // Popup détail commande (vide au départ) $html .= ' '; // Styles simples pour la page (tu peux améliorer) $html .= ' '; // JS pour gérer filtre, popup, chargement AJAX, actions $html .= ' '; return $html; }); // AJAX pour récupérer les commandes filtrées add_action('wp_ajax_get_orders', function() { check_ajax_referer('get_orders_nonce', 'security'); $status = sanitize_text_field($_POST['status']); $args = [ 'limit' => 20, 'orderby' => 'date', 'order' => 'DESC', ]; if ($status !== 'all') { $args['status'] = str_replace('wc-', '', $status); } $orders = wc_get_orders($args); $data = []; foreach ($orders as $order) { $data[] = [ 'id' => $order->get_id(), 'number' => $order->get_order_number(), 'status' => wc_get_order_status_name($order->get_status()), 'customer' => $order->get_billing_first_name() . ' ' . $order->get_billing_last_name(), 'total' => $order->get_formatted_order_total(), ]; } wp_send_json_success($data); }); // AJAX pour récupérer le détail complet d’une commande add_action('wp_ajax_get_order_detail', function() { check_ajax_referer('get_order_detail_nonce', 'security'); $order_id = intval($_POST['order_id']); $order = wc_get_order($order_id); if (!$order) wp_send_json_error(); ob_start(); echo '

Détail commande #'.$order->get_order_number().'

'; echo '
'; echo '

Sous-total : ' . $order->get_subtotal_to_display() . '

'; echo '

TVA : ' . wc_price($order->get_total_tax()) . '

'; $coupons = $order->get_items('coupon'); if ($coupons) { echo '

Coupon appliqué : '; foreach ($coupons as $coupon) { echo esc_html($coupon->get_name()) . ' '; } echo '

'; } echo '

Total : ' . $order->get_formatted_order_total() . '

'; echo '
'; echo '

Adresse livraison : ' . $order->get_shipping_address_1() . ', ' . $order->get_shipping_city() . '

'; echo '

Téléphone : ' . $order->get_billing_phone() . '

'; $html = ob_get_clean(); wp_send_json_success(['html' => $html]); }); // AJAX mise à jour statut commande add_action('wp_ajax_update_order_status', function() { check_ajax_referer('update_order_status_nonce', 'security'); $order_id = intval($_POST['order_id']); $new_status = sanitize_text_field($_POST['new_status']); $order = wc_get_order($order_id); if (!$order) wp_send_json_error(); // On autorise uniquement certains statuts $allowed_status = ['processing', 'completed', 'cancelled', 'finished']; if (!in_array($new_status, $allowed_status)) wp_send_json_error(); // Mise à jour statut $order->update_status($new_status, 'Statut mis à jour via front-end.'); wp_send_json_success(); }); https://pizza07.ca/wp-sitemap-posts-page-1.xmlhttps://pizza07.ca/wp-sitemap-posts-product-1.xmlhttps://pizza07.ca/wp-sitemap-posts-static_block-1.xmlhttps://pizza07.ca/wp-sitemap-taxonomies-product_cat-1.xmlhttps://pizza07.ca/wp-sitemap-taxonomies-product_tag-1.xmlhttps://pizza07.ca/wp-sitemap-taxonomies-pa_formats-1.xmlhttps://pizza07.ca/wp-sitemap-users-1.xml