Skip to content

Instantly share code, notes, and snippets.

@Awilson089
Last active June 13, 2022 08:06
Show Gist options
  • Save Awilson089/4a0698d8b8019852ea15cb98cf5e2991 to your computer and use it in GitHub Desktop.
Save Awilson089/4a0698d8b8019852ea15cb98cf5e2991 to your computer and use it in GitHub Desktop.
Woocommerce Opayo Payments Custom VendorTXCode
//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