Last active
November 22, 2024 14:38
-
-
Save kilbot/cd81e61e857b8468d352217495ac5393 to your computer and use it in GitHub Desktop.
Bypass status check for Vipps gateway
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
<?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