Created
January 30, 2022 22:03
-
-
Save reikjarloekl/c3c9b8b20ab528827cb3505cbb1e7b97 to your computer and use it in GitHub Desktop.
Reprocess Thrive Apprentice product access after adding a Thrive Product to a WooCommerce Product
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
/** | |
* Add a custom action to order actions select box on edit order page | |
* | |
* @param array $actions order actions array to display | |
* @return array - updated actions | |
*/ | |
function ta_wc_add_order_meta_box_action( $actions ) { | |
global $theorder; | |
// add "Reprocess TA product access" custom action | |
$actions['wc_reprocess_ta_access_action'] = 'Reprocess TA product access'; | |
return $actions; | |
} | |
add_action( 'woocommerce_order_actions', 'ta_wc_add_order_meta_box_action' ); | |
/** | |
* Reprocess TA product access | |
* | |
* @param \WC_Order $order | |
*/ | |
function ta_wc_reprocess_product_access_meta_box_action( $order ) { | |
global $tva_integrations; | |
// add the order note | |
$message = 'Reprocessed Thrive Apprentice product access.'; | |
$order->add_order_note( $message ); | |
$integration = $tva_integrations->get_integration('woocommerce'); | |
$integration->process_order($order->get_id(), $order->get_status(), $order->get_status(), $order); | |
} | |
add_action( 'woocommerce_order_action_wc_reprocess_ta_access_action', 'ta_wc_reprocess_product_access_meta_box_action' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment