• Resolved montseel

    (@montseel)


    Hi Marcel,

    One of my clients was interested in using the plugin. When she tested it, it wasn’t working – no emails were being sent.

    I did a little digging and I think I’ve found a bug: instead of the download id, the plugin should obtain the post id. I changed the code myself and got it working in a development environment.

    I’m not a WP coding expert, so there may be better solutions, but would you like me to share the code changes with you, so that you can take a look?

    Thanks in advance.

    Kind regards,

    Montse

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Marcel Pol

    (@mpol)

    Hello Montse,

    Thank you for the feedback. I would like to see the changes you made. Looking at the code, download_id is the same as post_id. But there might still be a bug somewhere. It did work for me, but that doesn’t always say much ??

    Code could be hosted on something like github, but email to [email protected] is fine too.

    Regards, Marcel

    • This reply was modified 1 year, 1 month ago by Marcel Pol.
    Thread Starter montseel

    (@montseel)

    Hi Marcel,

    Thanks a lot for looking into this. I’ve just sent you an email with the code.

    Best,

    Montse

    Plugin Author Marcel Pol

    (@mpol)

    Hi,

    I think you want to use the permalink here to obtain the post ID?
    That would mean that the download_id was not set correctly or not available in the callback function. So something there is going wrong.

    I just checked here when looking at the page html source, it has a download_id set in the javascript (based on get_the_ID() function, so it should be the post ID).

    function edd_add_email_on_update_submit_part( part, timeout ) {
    setTimeout( function() { // Use an object, arrays are only indexed by integers.
    var edd_email_on_update_ajax_data = {
    permalink: window.location.href,
    action: 'edd_email_on_update',
    part: part,
    security: 'ef502a4c7c',
    download_id: '26162',
    };

    When you look at the page source, is there an ID set for download_id?
    I am a bit confused where things are going wrong, where is the download_id getting lost.

    I would prefer to keep using the download_id (post ID) instead of using the permalink to get the post ID.

    Regards,
    Marcel

    Plugin Author Marcel Pol

    (@mpol)

    Just thought about this a bit.

    It could be that another plugin that has a metabox on the edit page has a bug, where it overwrites the post ID. That way the download_id in this plugin will have the wrong value. Since the metabox of this plugin is loaded quite late in the list of metaboxes, there is a bit of chance for that to happen.

    If you have a test setup and disable all plugins, except EDD and this plugin, does it have the correct download_id in the html source? And does the plugin work then?

    Regards, Marcel

    Thread Starter montseel

    (@montseel)

    Hi Marcel,

    Thanks for checking this. I’ll try to do some tests this week following your suggestions and I’ll get back to you.

    Montse

    Thread Starter montseel

    (@montseel)

    Hi Marcel,

    I’m sorry, but I haven’t had the time to look into this. As things stand right now, I don’t think I’ll be able to check it until December or so (luckily the end of November).

    Just wanted to let you know that I haven’t forgotten and that it’s going to take a while.

    I hope that’s okay.

    Thank you!

    Montse

    Thread Starter montseel

    (@montseel)

    Hi again, Marcel!

    Sorry for the long delay, but I couldn’t get back into this until today.

    After quite a lot of testing, I believe there are actually two bugs / issues. I’ll explain them following the order in which I think they’ll be easier to understand / solve.

    First issue

    On a clean WordPress instance, I installed:

    • EDD
    • Email Users on Update of Download for Easy Digital Downloads

    I activated both, and added some Downloads and “bought” them through the Store Gateway using one of my users.

    After doing so, when clicking on the Send Email to Customers, in order to notify them of a change, nothing happens (i.e. no email is sent, and there is no message either).

    <span style=”text-decoration: underline;”>How to solve this</span>

    In the file edd-email-user-admin-ajax.php, I changed the following condition in function edd_email_on_update_get_recipients($download_id):

    if (false === $recipients){

    to:

    if ( (false === $recipients) || (count($recipients) === 0 ) ) {

    Bear in mind that this bug only happens the first time you try to send an email to the customers of a certain Download. If an email is sent successfully for a certain Download, and then the code is reverted back to the original if condition, on the following attempts everything works correctly.

    I had already included this change when I first got in touch, but didn’t realise that this first-email issue was there.

    BTW, I tested this on a local WordPress install, using Local by Flywheel.

    Second issue

    I believe this second issue might be due to what you mentioned:

    It could be that another plugin that has a metabox on the edit page has a bug, where it overwrites the post ID. That way the download_id in this plugin will have the wrong value. Since the metabox of this plugin is loaded quite late in the list of metaboxes, there is a bit of chance for that to happen.

    I deactivated all plugins on a replica of my client’s website, and activated them in blocks, and I believe I found the culprit: Easy Media Gallery. When it’s active, no emails are sent because of the wrong ids. This happens under the following conditions:

    • Only active plugins are EDD + Email Users on Update… + Easy Media Gallery

    If I activate all plugins, except Easy Media Gallery, it works and emails are sent.

    However, when I tried to reproduce the issue on a clean install, with the bare minimum:

    • EDD
    • Email Users on Update of Download for Easy Digital Downloads
    • Easy Media Gallery

    Everything works properly.

    I’m quite baffled as to what is going on. Any idea of what could be wrong, and why the difference in behaviour? I’d like to figure it out, but at the same time, I’m not sure it’s worth it considering that it seems difficult to find the exact conditions under which it can be reproduced.

    BTW, the code I sent you a few months back seems to solve the issue.

    I think you want to use the permalink here to obtain the post ID?
    That would mean that the download_id was not set correctly or not available in the callback function.

    Yes, the id was wrong and I was trying to get the good one from the permalink.

    Thanks again for your time.

    Kind regards,

    Montse

    Plugin Author Marcel Pol

    (@mpol)

    Thank you for your effort.

    Issue 1 is fied as you suggested.

    Issue 2 is worked around. Easy Media Gallery does indeed overwrite the post_id in the admin_footer. I changed the code so this is no problem anymore. There will be other plugins with the same issue, so I guess this is fine.

    Does version 1.1.2 work for you?

    Thread Starter montseel

    (@montseel)

    Hi Marcel!

    Thanks a lot! Tried it in both testing and production environments, and it works ?? It’s great that you could fix issue 2.

    Best,

    Montse

    Plugin Author Marcel Pol

    (@mpol)

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Bug with $download_id’ is closed to new replies.