Skip to content

Instantly share code, notes, and snippets.

@webtoffee-git
Last active October 11, 2024 06:35
Show Gist options
  • Save webtoffee-git/df67edf82c073920b1653b74924bf25a to your computer and use it in GitHub Desktop.
Save webtoffee-git/df67edf82c073920b1653b74924bf25a to your computer and use it in GitHub Desktop.
Code to set the default order status for card payments to 'On Hold' - By WebToffee ( Stripe Payment Gateway)
<?php //Do not copy this line of code
add_action('woocommerce_thankyou', 'set_order_status_on_hold', 10, 1);
function set_order_status_on_hold($order_id) {
// Get the order object
$order = wc_get_order($order_id);
// Check if the order exists and if the payment method is your custom one
if ($order && $order->get_payment_method() === 'eh_stripe_pay') {
// Set the order status to 'on-hold'
$order->update_status('on-hold', __('Order status set to on hold by custom payment method.', 'payment_gateway_stripe_and_woocommerce_integration'));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment