pronamic / wp-pay-core

Core components for the WordPress payment processing library. This library is used in the WordPress plugin Pronamic Pay: https://www.pronamicpay.com/, but also allows other plugin developers to set up a payment plugin.
https://www.wp-pay.org/
GNU General Public License v3.0
27 stars 3 forks source link

Discrepancy in the payment count #58

Closed knit-pay closed 2 years ago

knit-pay commented 2 years ago

Hello Team

One of my clients reported a Discrepancy in the payment count on the payment page. On the top, it's mentioned that there are 42 Pending Payments, but after clicking it, it's showing only 19 payments on the bottom. Due to some confidential data in this WordPress website, he is not ready to share admin login details. So I was not able to figure out the exact issue. Do you have any idea about the same, What could be the possible reason for this issue?

Whats-App-Image-2022-02-28-at-2-45-59-PM

remcotolsma commented 2 years ago

We do know that WordPress caches the number of posts for each status, this is handled in the wp_count_posts() function: https://developer.wordpress.org/reference/functions/wp_count_posts/. Maybe there is a caching issue or another plugin is causing a conflict? You could ask your client to execute the following query via phpMyAdmin:

SELECT post_status, COUNT( id ) FROM wp_posts WHERE post_type = 'pronamic_payment' GROUP BY post_status;

If the results of this query match the actual number of payments, there must be a cache issue or plugin conflict. Another possibility is that the logged in user is not allowed to view all payments. As far as I know, the number of payments per status is not tracked at the user level.

knit-pay commented 2 years ago

Thanks for the reply @remcotolsma

I will get this checked and update you.

knit-pay commented 2 years ago

After running the provided query, the pending payment count is 42 and in the list, it's still showing only 19 payments.

rvdsteege commented 2 years ago

Then, as @remcotolsma said:

If the results of this query match the actual number of payments, there must be a cache issue or plugin conflict.

You can check for example if there is a file /wp-content/object-cache.php and temporarily rename the file, so it will not be used. Does that resolve the issue? If so, then the object cache of the website is not functioning properly or needs to be cleared.

remcotolsma commented 2 years ago

I suspect it's caused by another plugin, the filter options at the top left don't seem to be WordPress by default. Maybe ask if the problem also occurs if the plugin that adds those filter options is disabled? I am not familiar with the Add Filter and Reset Settings buttons.

knit-pay commented 2 years ago

Thanks for your feedback. As client could not share access to website, there is nothing much we can do to find the exact issue. For now I am closing the ticket, will let you know if any other client will report same issue.

knit-pay commented 2 years ago

Hello @remcotolsma and @rvdsteege

The client himself found the cause of the issue. After clicking the Pending payment filter, when they choose to sort by customer name or sort by transaction id option, some payments get hidden. I think this is due to a blank transaction id or blank customer name in some payments. Ideally, payments with a blank customer name or transaction id should also be visible even after sorting. Can this be fixed?

rvdsteege commented 2 years ago

Thanks for the update, @knit-pay. I did some testing, and was able to reproduce the issue you mentioned.

Apparently, sorting by customer name doesn't work at all anymore, because the meta key needed for this is no longer stored for recent payments (has been removed with all the changes to store less data in post meta).

We could fix sorting for the transaction ID, but that requires an extra JOIN in the SQL query. We've now experiences this can get difficult in sites with many payments.

We're now thinking of removing the sorting functionality of the Transaction and Customer columns. Search can be used instead, when looking for a payment with a specific transaction ID.

Do you have any use cases for sorting or would it be fine to remove the sorting for these columns?

knit-pay commented 2 years ago

Thanks for the update. yes, you are right, It will be a good idea to remove sorting by transaction id and customer name. I also think it's useless.