impress-org / givewp-snippet-library

A collection of code snippets to enhance or expand on the free Give WordPress Donation Plugin.
https://givewp.com
140 stars 90 forks source link

fix: make offline auto-accept snippet also reflect in goal progress bar #101

Closed Benunc closed 4 years ago

Benunc commented 5 years ago

Overview

This snippet works to set the status to complete automatically: https://github.com/impress-org/give-snippet-library/blob/master/gateway-customizations/offline-auto-complete.php

It does NOT reflect in the goal progress bar until the stats are recalculated using the tools at Donations > Tools > Data

Steps to replicate

  1. Create a form with a goal progress bar
  2. Install the custom snippet above in a helper plugin, mu-plugin, or the active theme functions.php
  3. Enable the offline gateway
  4. Submit the donation
  5. See that the status is correctly "complete" and the offline instructions are NOT sent.
  6. REload a page with the progress bar on it.

Possible solution

Somehow incorporate give_update_payment_status() into that function, to fully simulate the manual process of updating an offline donation to complete.

DevinWalker commented 4 years ago

I fixed the snippet - essentially I had to rewrite it using the proper hook to update the status so it reflects properly in the goal.

See snippet now: https://github.com/impress-org/givewp-snippet-library/blob/master/gateway-customizations/offline-auto-complete.php