Skip to content

Instantly share code, notes, and snippets.

@kilbot
Last active November 22, 2024 14:38
Show Gist options
  • Save kilbot/cd81e61e857b8468d352217495ac5393 to your computer and use it in GitHub Desktop.
Save kilbot/cd81e61e857b8468d352217495ac5393 to your computer and use it in GitHub Desktop.
Bypass status check for Vipps gateway
<?php
/**
* Add this to your theme's functions.php file.
*/
function validate_pos_order_status($has_status, $order, $status ) {
if (
/**
* Only applies if these conditions are met
* - Only check for requests coming from the POS.
* - Must have 'pos-open' status.
* - Must be created via POS.
* - Must require payment.
* - Must use Vipps gateway.
*/
function_exists('woocommerce_pos_request') && woocommerce_pos_request() &&
$order->get_status() === 'pos-open' &&
$order->get_created_via() === 'woocommerce-pos' &&
$order->needs_payment() &&
$order->get_payment_method() === 'vipps'
) {
return true; // Allow 'pos-open' when all conditions are met.
}
return $has_status; // Allow default behavior if all conditions fail.
}
add_filter('woocommerce_order_has_status', 'validate_pos_order_status', 10, 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment