Skip to content

Instantly share code, notes, and snippets.

@growdev
Last active February 10, 2022 03:03
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save growdev/8674326 to your computer and use it in GitHub Desktop.
Save growdev/8674326 to your computer and use it in GitHub Desktop.
WooCommerce Payment Gateway actions after successful order.
<?php
// Add a note to the order. Put return code here if needed.
$order->add_order_note( __('Payment completed', 'woocommerce') );
// Mark the order as complete
$order->payment_complete();
// Empty the cart
$woocommerce->cart->empty_cart();
// Empty awaiting payment session
unset( $woocommerce->session->order_awaiting_payment );
// Return thank you redirect
return array(
'result' => 'success',
'redirect' => $this->get_return_url( $order )
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment