Last active
April 9, 2023 13:15
-
-
Save hedqvist/378a5ff37fc126611f5a5c8acaa1a984 to your computer and use it in GitHub Desktop.
Sätter Fakturatyp och Betalsätt baserat på betalsätt i WooCommerce :)
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
| <?php | |
| /** | |
| * @snippet WooCommerce - Fortnox plugin by Redlight Media - Set InvoiceType depending on payment method via functions.php | |
| * @author Redlight Media AB / Christopher Hedqvist | |
| * @compatible WooCommerce 3.2.5 | |
| */ | |
| function redlight_fortnox_payment_method_invoicetype($invoice, $order_id) { | |
| $order = wc_get_order($order_id); | |
| $order_payment_method = $order->get_payment_method(); | |
| switch( $order_payment_method ) { | |
| case 'dibs': | |
| case 'dibs_invoice': | |
| case 'dibs_masterpass': | |
| case 'dibs_mobilepay': | |
| $invoice['Invoice']['InvoiceType'] = 'CASHINVOICE' ; | |
| $invoice['Invoice']['TermsOfPayment'] = 'DIBS' ; | |
| $invoice['Invoice']['PaymentWay'] = 'CARD' ; | |
| break; | |
| case 'dibs': | |
| case 'stripe': | |
| $invoice['Invoice']['InvoiceType'] = 'CASHINVOICE' ; | |
| $invoice['Invoice']['TermsOfPayment'] = 'STRIPE' ; | |
| $invoice['Invoice']['PaymentWay'] = 'CARD' ; | |
| break; | |
| case 'redlight_swish': | |
| case 'redlight_swish-ecommerce': | |
| $invoice['Invoice']['InvoiceType'] = 'CASHINVOICE'; | |
| $invoice['Invoice']['TermsOfPayment'] = 'SWISH'; | |
| $invoice['Invoice']['PaymentWay'] = 'CASH'; | |
| break; | |
| default: | |
| $invoice['Invoice']['InvoiceType'] = 'INVOICE' ; | |
| } | |
| return $invoice; | |
| } | |
| add_filter('obj_fortnox_update_invoice_params', 'redlight_fortnox_payment_method_invoicetype', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment