Last active
April 16, 2020 14:53
-
-
Save rvdsteege/9d618a5f5b86a554da2100563c051993 to your computer and use it in GitHub Desktop.
Usage example for Pronamic Pay `pronamic_pay_adyen_payment_metadata` filter.
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 | |
/** | |
* Pronamic Pay Adyen payment metadata. | |
* | |
* @param array $metadata Metadata. | |
* @param Payment $payment Payment. | |
* | |
* @return array | |
*/ | |
function pronamic_pay_woocommerce_adyen_payment_metadata( $metadata, $payment ) { | |
// Check for WooCommerce source. | |
if ( 'woocommerce' !== $payment->get_source() ) { | |
return $metadata; | |
} | |
$order = \wc_get_order( $payment->get_source_id() ); | |
if ( $order instanceof \WC_Order ) { | |
/* | |
* Your metadata here... | |
* | |
* Note: max key length and number of metadata items are both 20. | |
*/ | |
$metadata['WC Order Country'] = $order->get_billing_country(); | |
} | |
return $metadata; | |
} | |
add_filter( 'pronamic_pay_adyen_payment_metadata', 'pronamic_pay_woocommerce_adyen_payment_metadata', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment