Last active
June 13, 2022 08:06
-
-
Save Awilson089/4a0698d8b8019852ea15cb98cf5e2991 to your computer and use it in GitHub Desktop.
Woocommerce Opayo Payments Custom VendorTXCode
This file contains 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
//This function adds last name and the time, then a random number afterwards | |
add_filter( 'woocommerce_opayopi_vendortxcode', 'custom_vendor_tx_code', 10, 2); | |
function custom_vendor_tx_code($vendortxcode, $order) { | |
$vendortxcode = time().$order->get_billing_last_name().rand(0,999 ); | |
$vendortxcode = preg_replace( '/[^0-9a-zA-Z_\-]/', "", $vendortxcode ); | |
// Make sure it's not over 40 characters | |
if ( strlen($vendortxcode) > 40 ) { | |
$vendortxcode = substr( $vendortxcode, 0, 40 ); | |
} | |
return $vendortxcode; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment