Skip to content

Instantly share code, notes, and snippets.

@NiklasHogefjord
Last active October 19, 2017 12:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NiklasHogefjord/fb827bf838dd5444c309 to your computer and use it in GitHub Desktop.
Save NiklasHogefjord/fb827bf838dd5444c309 to your computer and use it in GitHub Desktop.
Filter the payTypeIdentifier sent to Specter
/**
* Specter for WooCommerce
* Filter the payTypeIdentifier sent to Specter
*
**/
add_filter('wc_specter_pay_type_identifier', 'my_wc_specter_pay_type_identifier', 10, 2);
function my_wc_specter_pay_type_identifier( $paytype, $order_id ) {
// Switches the paytype to D (cash payment) for all orders that uses Cach on Delivery (originally paytype P in the extension) as the payment method.
// See available paytypes here: http://docs.krokedil.com/se/documentation/specter-woocommerce/#10
if( 'P' == $paytype ) {
return 'D';
} else {
return $paytype;
}
}
@NiklasHogefjord
Copy link
Author

NiklasHogefjord commented Oct 19, 2017

Do change the paytype for a specific payment method you could do something like this:

function my_wc_specter_pay_type_identifier( $paytype, $order_id ) {
$order = wc_get_order( $order_id );
	if ( 'payson' === $order->get_payment_method() ) {
		$paytype = 'PCO';
	}
	return $paytype;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment