Kevin.a Kevin.a - 8 days ago 5
PHP Question

PHP function returning error

I'm trying to make a function like this:

function simplicate () {

$organization = $SimplicateApi->makeApiCall('POST','/crm/organization',json_encode($org_payload));

}

// fetch the newly created organization id
$organization_id = $organization['data']['id'];

//after order is processed run simplicate function
add_action('woocommerce_checkout_order_processed', 'simplicate');


So i can use it like this:

//after order is processed run simplicate function
add_action('woocommerce_checkout_order_processed', 'simplicate');


But i get the following error:


Fatal error: Call to a member function makeApiCall() on a non-object
in
/var/www/vhosts/dexport.nl/httpdocs/wp-content/themes/jupiter-child/functions.php
on line 370

Answer

It had to do with the function scope. Apparently one of the variables was not inside the function i created.

Comments