correction
This commit is contained in:
parent
9c56e63820
commit
e14618aa10
@ -324,6 +324,51 @@ class PEPPOL_Woo_Helper {
|
||||
return array_values($vat_fields_found);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne les infos de paiement utiles pour Peppol.
|
||||
*
|
||||
* @param \WC_Order|int $order
|
||||
* @return array{payment_method:string,payment_method_title:string,payment_means_code:string,payment_terms:string}
|
||||
*/
|
||||
public static function esi_get_order_payment_data( $order ): array {
|
||||
if ( is_numeric( $order ) ) {
|
||||
$order = wc_get_order( $order );
|
||||
}
|
||||
|
||||
if ( ! $order instanceof \WC_Order ) {
|
||||
return [
|
||||
'payment_method' => '',
|
||||
'payment_method_title' => '',
|
||||
'payment_means_code' => '30',
|
||||
'payment_terms' => '',
|
||||
];
|
||||
}
|
||||
|
||||
$payment_method = (string) $order->get_payment_method();
|
||||
$payment_method_title = (string) $order->get_payment_method_title();
|
||||
|
||||
// Valeur par defaut : virement (code 30)
|
||||
$payment_means_code = '30';
|
||||
|
||||
$map = [
|
||||
'bacs' => '30', // virement bancaire
|
||||
'cheque' => '20',
|
||||
'cod' => '10', // cash on delivery
|
||||
];
|
||||
if ( isset( $map[ $payment_method ] ) ) {
|
||||
$payment_means_code = $map[ $payment_method ];
|
||||
}
|
||||
|
||||
$data = [
|
||||
'payment_method' => $payment_method,
|
||||
'payment_method_title' => $payment_method_title,
|
||||
'payment_means_code' => $payment_means_code,
|
||||
'payment_terms' => '',
|
||||
];
|
||||
|
||||
return apply_filters( 'esi_peppol_order_payment_data', $data, $order );
|
||||
}
|
||||
|
||||
public static function esi_is_wpo_wcpdf_installed(): bool {
|
||||
if (!function_exists('get_plugins')) {
|
||||
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user