Skip to content

Instantly share code, notes, and snippets.

Last active Jul 27, 2021
What would you like to do?
Function to programmatically run a specific workflow for a specific order
* Run a specific workflow for a specific order.
* @param int $workflow_id
* @param int $order_id
* @throws \Exception
function automatewoo_run_order_workflow( int $workflow_id, int $order_id ) {
$order = wc_get_order( $order_id );
if ( ! $order ) {
throw new \Exception;
$customer = \AutomateWoo\Customer_Factory::get_by_order( $order );
// If the required data items for the trigger are not set here the workflow will not run
$workflow_data = new Data_Layer(
\AutomateWoo\DataTypes\DataTypes::ORDER => $order,
\AutomateWoo\DataTypes\DataTypes::CUSTOMER => $customer
$workflow = \AutomateWoo\Workflows\Factory::get( $workflow_id );
if ( ! $workflow ) {
throw new \Exception;
$workflow->maybe_run( $workflow_data );
Copy link

rayice commented Jul 27, 2021

Is it possible to manually assign the credit to advokat with functions or workflow ?. Because one of our advokat reffered person outside of web network to our shop but we want to credit him store credit to his advokat account on website which he can use in web shop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment