Created
December 13, 2017 22:24
-
-
Save hedqvist/c8da267b255de6699430f3154f6b4b22 to your computer and use it in GitHub Desktop.
Klarna reference to Fortnox ExternalInvoiceReference1 & ExternalInvoiceReference2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
/** | |
* @snippet WooCommerce - Adds Klarna Invoice and ordernumber to Fortnox ExternalInvoiceReference1 & ExternalInvoiceReference2 fields | |
* @author Redlight Media AB / Christopher Hedqvist | |
* @compatible WooCommerce 3.2.5 | |
*/ | |
function redlight_fortnox_klarna_invoice_order_reference( $orderData, $order_id) { | |
$order = new WC_Order($order_id); | |
if($order->get_payment_method() == 'klarna_checkout'){ | |
$klarna_invoice_number = get_post_meta( $order->get_id(), '_klarna_invoice_number', true ); | |
$klarna_order_reservation = get_post_meta( $order->get_id(), '_klarna_order_reservation', true ); | |
$orderData['Order']['ExternalInvoiceReference1'] = $klarna_invoice_number; | |
$orderData['Order']['ExternalInvoiceReference2'] = $klarna_order_reservation; | |
} | |
return $orderData; | |
} | |
add_filter('obj_fortnox_order_data', 'redlight_fortnox_klarna_invoice_order_reference', 10, 2 ); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment