How to Add a Custom Payment Method in POS
OpenPOS lets cashiers split and mix payments on one order, for example cash, card and wallet, and it supports payment services such as Stripe Terminal, Square, Authorize.net and LayBuy. Many stores, however, also accept tenders that are not in the default list: a bank transfer, a gift voucher, a local mobile wallet, a cheque or a card terminal that is not connected to the POS. This guide shows how to add your own payment methods to the POS checkout with a short PHP snippet, so the cashier can select them and the order records how the customer paid.
How the snippet works
OpenPOS builds its list of payment methods through the WordPress filter op_pos_payment_method_list. The snippet hooks a function into that filter. The function receives the current list as $payment_methods, appends one array per new method and returns the extended list. The example adds two methods; you can remove the second block or copy it to add more.
For each method you normally only need to change three values, as the comments in the code point out:
code– the internal method code. Make it unique for every method (for examplebank_transfer) and use only lowercase letters, numbers and underscores.name– the label the cashier sees in the POS, for example “Bank transfer”.description– a short description of the method.
Keep the other keys (type, hasRef, partial, online_type, offline_transaction, offline_order) as they are in the example unless you have been told to change them. The function_exists check around the function prevents a fatal “cannot redeclare” error if the snippet is accidentally loaded twice.
if(!function_exists('custom_payment_op_login_format_payment_data'))
{
function custom_payment_op_login_format_payment_data($payment_methods){
//add 1st method
$payment_method_data = array(
'code' => 'payment_code_here', // change to your method code
'name' => 'Payment Method Name', // change to your method name
'type' => 'offline',
'hasRef' => true,
'partial' => false,
'description' => 'Payment Method Name description', // change to your method name description
'online_type' => 'external',
'offline_transaction' => 'yes',
'offline_order' => 'yes'
);
$payment_methods[] = $payment_method_data;
// add second method
$payment_method_data = array(
'code' => 'payment_code_here_2', // change to your method code
'name' => 'Payment Method Name 2', // change to your method name
'type' => 'offline',
'hasRef' => true,
'partial' => false,
'description' => 'Payment Method Name description 2', // change to your method name description
'online_type' => 'external',
'offline_transaction' => 'yes',
'offline_order' => 'yes'
);
$payment_methods[] = $payment_method_data;
//end
return $payment_methods;
}
}
add_filter('op_pos_payment_method_list','custom_payment_op_login_format_payment_data',10,1);
Add the payment method step by step
- Decide the code and the name for each payment method you need. Write them down before you edit any code.
- Choose where the snippet will live. You can add it to your theme’s
functions.phpor to a code snippets plugin. A child theme’sfunctions.phpis better than the parent theme’s, because a theme update overwrites the parent theme’s files. A code snippets plugin (for example “Code Snippets” from Plugins > Add New) keeps the code separate from the theme and lets you switch it off from the admin. - Back up the file or your site before editing. If you edit
functions.php, do it through SFTP or your host’s file manager so you can undo the change if the site stops loading. - Paste the snippet. In
functions.php, paste it below the existing code and do not add a second opening<?phptag. In a snippets plugin, create a new PHP snippet and set it to run everywhere, not only in the admin area. - Replace
payment_code_here,Payment Method Nameand the description with your own values. Remove the second method block if you only need one method, or duplicate a block for each extra method. - Save the file or activate the snippet.
- Open the POS, log out and log in again so the register loads the updated payment list.
- Test it: add a product to the cart, go to checkout, select the new payment method and complete the order. Then open the order in WooCommerce > Orders and check how the payment was recorded.
Troubleshooting
- The new method does not appear. Check that the snippet is saved and active, then log out of the POS and log in again. If you use a caching plugin or a CDN, clear its cache as well.
- The site shows a critical error or a blank page. This usually means a syntax error, such as a missing comma, quote or bracket. Remove or deactivate the snippet (through SFTP for
functions.php), fix the code and add it again. - Two methods behave as one. Every method needs its own unique
code. Make sure you did not copy a block without changing its code. - You need an online gateway rather than a manual tender. This snippet is meant for manual, external payments. For WooCommerce online payment gateways, see the related article below.