mecachisenros / woocommerce_civicrm

GNU Affero General Public License v3.0
14 stars 16 forks source link

Transaction status is always Pending in CiviCRM #10

Closed cdhassell closed 7 years ago

cdhassell commented 7 years ago

The extension works well, except that the contributions created in CiviCRM are left in a Pending state even after the transaction is completed in woocommerce. Looking at the code, I see that there is a block of 7 order status update add_action() calls which are commented out. It appears that these were written to hook to woocommerce transaction updates. Can you explain why the code is commented out and if this could explain why the Civi transactions never complete? Should these lines be uncommented? Thanks.

cdhassell commented 7 years ago

I found a solution based on this by inserting this code near the top of woocommerce_civicrm.php:

//action to fire on order status change hook
add_action( 'woocommerce_order_status_changed', 'woocommerce_civicrm_change_order', 99, 3 );

function woocommerce_civicrm_change_order( $order_id, $old_status, $new_status ) {
    woocommerce_civicrm_update_order($order_id); 
}

Now it is updating the civicontribute record to Completed.

rajeshrhino commented 7 years ago

@cdhassell Thanks for the fix

Can you please create a PR with your fix?

rajeshrhino commented 7 years ago

@cdhassell Thanks for the PR

Issue is fixed with this PR https://github.com/veda-consulting/woocommerce_civicrm/pull/11