wc_get_order

ACTION woocommerce\includes\wc-order-functions.php (ligne 79) github
Main function for returning orders, uses the WC_Order_Factory class.
traduction française
Fonction principale pour le retour des commandes, utilise la classe WC_Order_Factory.

Paramètres

Entrée :
$the_order = false
Sortie :
@param mixed $the_order       Post object or post ID of the order.
@return bool|WC_Order|WC_Order_Refund

Utilisation

Récupérer et manipuler une commande

Obtenir l'objet WC_Order et accéder à ses données

order-flow technical
// Récupérer une commande et afficher ses informations
$order = wc_get_order(123); // ID de la commande

if ($order) {
    echo 'Statut: ' . $order->get_status();
    echo 'Total: ' . $order->get_total();
    echo 'Client: ' . $order->get_billing_email();
    
    // Parcourir les articles
    foreach ($order->get_items() as $item) {
        echo $item->get_name() . ' x' . $item->get_quantity();
    }
}

Actualités

Chargement des actualités...