Last active
November 26, 2020 11:16
-
-
Save hedqvist/591bedcce813c1882f8229df47fe9397 to your computer and use it in GitHub Desktop.
Set TermsOfPayment depending on payment method
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 - Fortnox plugin by Redlight Media - Set TermsOfPayment depending on payment method via functions.php | |
* @author Redlight Media AB / Christopher Hedqvist | |
* @compatible WooCommerce 3.2.5 | |
*/ | |
function redlight_fortnox_payment_method_TermsOfPayment($orderData, $order_id) { | |
$order = wc_get_order($order_id); | |
$order_payment_method = $order->get_payment_method(); | |
switch( $order_payment_method ) { | |
case 'klarna': | |
case 'klarna_account': | |
case 'klarna_special_campaign': | |
case 'klarna_invoice': | |
case 'klarna_part_payment': | |
case 'klarna_checkout': | |
$orderData['Order']['TermsOfPayment'] = 'KLARNA' ; | |
break; | |
case 'dibs': | |
case 'dibs_invoice': | |
case 'dibs_masterpass': | |
case 'dibs_mobilepay': | |
$orderData['Order']['TermsOfPayment'] = 'DIBS' ; | |
break; | |
case 'redlight_swish': | |
case 'redlight_swish-ecommerce': | |
$orderData['Order']['TermsOfPayment'] = 'SWISH' ; | |
break; | |
default: | |
$orderData['Order']['TermsOfPayment'] = '' ; | |
} | |
return $orderData; | |
} | |
add_filter('obj_fortnox_order_data', 'redlight_fortnox_payment_method_TermsOfPayment', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment