Forum Replies Created

Viewing 15 replies - 1 through 15 (of 61 total)
  • Plugin Author Brian Henry

    (@brianhenryie)

    Hey. It should already be doing so. If you view a WooCommerce order which is Pending Payment, and under Order Actions choose Email Invoice/Order Details to Customer…, Update, the email sent contains a link “Pay for this order” which has the autologin code added to it.

    If you install https://www.ads-software.com/plugins/wp-mail-logging/ you should be able to confirm this in the email sent.

    Plugin Author Brian Henry

    (@brianhenryie)

    There’s a filter you can use for that, autologin_urls_for_users, see class-wp-mail.php#L89-L100

    I haven’t tested this, but I think it should work, add it to your functions.php:

    /**
     * Check does the recipient user have the subscriber role, if not do not add autologin code in emails.
     *
     * @param bool     $should_add_autologin Variable to set to true/false to control the plugin behaviour.
     * @param \WP_User $user The WordPress user the email is being sent to.
     * @param array{to:string|array<string>, subject:string, message:string, headers?:string|array<string>, attachments:string|array<string>} $wp_mail_args The array of values wp_mail() functions uses: subject, message etc.
     */
    $only_add_autologin_urls_for_subscribers = function( bool $should_add_autologin, \WP_User $user, array $wp_mail_args ): bool {
    	return in_array( 'subscriber', $user->roles, true );
    };
    add_filter( 'autologin_urls_for_users', $only_add_autologin_urls_for_subscribers, 10, 3 );
    Thread Starter Brian Henry

    (@brianhenryie)

    Warning: Trying to access array offset on value of type bool in /path/to/wp-content/plugins/debug-log-manager/bootstrap.php on line 67

    where the bool is the default false return of get_option( 'debug_log_manager' ), so this could be fixed with get_option( 'debug_log_manager', array( <DEFAULT PTIONS> )

    Thread Starter Brian Henry

    (@brianhenryie)

    > (47 occurrences logged)

    I love it.

    I’ve been thinking about how to do that intentionally when logging myself. I was thinking of always using sprintf and passing the template into the log context so it could be used for filtering/de-duplication later.

    I’m also very happy with the JS/frontend logging. I had tried another plugin for that before, but it just logged to the standard debug.log, and obviously we both aren’t satisfied with that!

    A suggestion (and I’ll email you code how I did it) – the error logs are often too vague to be actionable, e.g. I see in this:

    > Function is_embed was called incorrectly. Conditional query tags do not work before the query is run…

    but I’ve no idea where that happened. So I catch all errors with a set_error_hander() and then force a backtrace and print that. I imagine it’s awful for performance, but I enable it for a few hours maybe once a month to make sure my error log is clean.

    I did just see a bug/bad UX in this plugin – when Auto-Refresh is enabled and I click to visit the second page I quickly get brought back to the first. I guess disable auto-refresh when a user navigates away from page 1.

    I’m going to use this for a while and dig into the code. I have a feeling this is going to be installed on every site I run!

    Yeah, I don’t see how the change I wrote is related to the real functionality of the sync.

    I changed:

    if(!session_id() && $this->is_allow_php_session()) {
        session_start();
    }

    to

    if(!session_id() && $this->is_allow_php_session() && !headers_sent()) {
        session_start();
    }

    Unfortunately, they just released a new version of the plugin without addressing this issue. There’ll be no 5 star review from me!

    Thread Starter Brian Henry

    (@brianhenryie)

    Hey,

    > You can try this on other WooCommerce Extensions and see how it behaves.

    Most WooCommerce extensions do not redirect me to a page that does not exist. Certainly none of the ones I have written: https://github.com/BrianHenryIE?tab=repositories&q=bh-wc

    You are redirecting to a page that says:

    Sorry, you are not allowed to access this page.

    A better way would be to NOT redirect at all, which you can do with this code:

    if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
        return admin_url( 'admin.php?page=wpm&section=main&subsection=google-ads' );
    } else {
        return false;
    }

    Better yet, check is this happening during bulk activation and do not redirect then either:

    woocommerce-google-adwords-conversion-tracking-tag/wgact.php:96

    // If we are bulk activating plugins, do not redirect.
    global $pagenow;
    if ( 'plugins.php' === $pagenow &&
         ( ( isset( $_REQUEST['activate-multi'] ) && 'true' === $_REQUEST['activate-multi'] )
         || ( isset( $_REQUEST['action'] ) && 'activate-selected' === $_REQUEST['action'] && isset( $_REQUEST['checked'] ) && count( $_REQUEST['checked'] ) > 1 ) )
         || ( isset( $_REQUEST['plugin'] ) && 'woocommerce-google-adwords-conversion-tracking-tag/wgact.php' !== $_REQUEST['plugin'] ) ) {
        return false;
        // If WooCommerce is not active, do not redirect.
    } elseif ( ! is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
        return false;
    } else {
        return admin_url( 'admin.php?page=wpm&section=main&subsection=google-ads' );
    }

    Just return false to not redirect. Surely that’s better than a redirection to a non-existent page. See vendor/freemius/wordpress-sdk/includes/class-freemius.php:3119 to see where Freeemius designed to facilitate this.

    Hope that helps.

    Thread Starter Brian Henry

    (@brianhenryie)

    It is certainly a bug.

    Here is your code:

    if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
        return admin_url( 'admin.php?page=wpm&section=main&subsection=google-ads' );
    } else {
        return admin_url( 'options-general.php?page=wpm&section=main&subsection=google-ads' );
    }

    With WooCommerce active, the plugin directs to a different, working, page than the one I mentioned.

    Without WooCommerce active, you are intentionally redirecting to a different page. A page which cannot be accessed.

    Sorry, you are not allowed to access this page.

    Let me ask: when you are on plugins.php and select multiple plugins to activate. Do you want them all to activate? Or do you want to be redirected to a different page and half the plugins to remain inactive?

    /**
     * Repeat Order for WooCommerce – show "Order Again" button for all statuses.
     *
     * @see https://www.ads-software.com/plugins/repeat-order-for-woocommerce/
     *
     * @hooked woocommerce_valid_order_statuses_for_order_again
     *
     * @param string[] $order_statuses The existing set of statuses whose orders the Order Again button will be shown beside.
     *
     * @return string[]
     */
    function allow_all_order_statuses( array $order_statuses ): array {
    
    	$unprefixed_order_statuses = array_map(
    		function( string $prefixed_status ) {
    			return str_replace( 'wc-', '', $prefixed_status );
    		},
    		array_keys( wc_get_order_statuses() )
    	);
    
    	return $unprefixed_order_statuses;
    }
    add_filter( 'woocommerce_valid_order_statuses_for_order_again', 'allow_all_order_statuses' );
    Thread Starter Brian Henry

    (@brianhenryie)

    Yes, everything looks normal on the order itself:

    Payment approved by Sezzle successfully.
    
    May 18, 2022 at 5:40 am
    Thread Starter Brian Henry

    (@brianhenryie)

    Merchant id, transaction id, order key, order id:

    2aecc54f-3114-4aaa-a080-f23ba458fcd6
    6284e60d864f3-197301
    wc_order_Q9SYVGaNcq3am
    197301

    We’ve had Sezzle orders since with no error logged. And I keep a reasonable eye on the logs and I don’t recall seeing this before.

    The plugin version was 4.0.4 at the time, but I don’t see anything in the changes that would be relevant.

    Thread Starter Brian Henry

    (@brianhenryie)

    Still a problem after the latest update.

    Obviously I fixed this problem locally, then the update reverted the fix back to the problem state. The update didn’t actually update anything, it was just so you could change the WordPress version Tested up to: 5.9.3.

    BTW, when changing that, you do not need to change your plugin version number.

    i.e. you can push a change to SVN that will help the www.ads-software.com website correctly show that it is tested up to ~~ but it won’t force everyone who has the plugin to download and install the otherwise unchanged plugin.

    Please fix this Undefined index: variations issue by adding this code at line 233:

    if( ! isset( $response->data['variations'] ) ) {
    	return $response;
    }
    • This reply was modified 2 years, 7 months ago by Brian Henry. Reason: Adding the fix

    I fixed it by changing the line to:

    if(!session_id() && $this->is_allow_php_session() && !headers_sent()) {

    I’m not immediately sure how to narrow down the source.

    The explanation is here:
    https://stackoverflow.com/questions/8028957/how-to-fix-headers-already-sent-error-in-php

    I don’t see why the plugin is running on the frontend anyway. Maybe it should just run on is_checkout(), cron and admin.

    Nobody wants a redirect after activation. It’s a nightmare when activating multiple plugins. Better practice is to display an admin notice until settings page has been visited / required settings have been added.

    Thread Starter Brian Henry

    (@brianhenryie)

    I didn’t manage to open a ticket. The company’s account password has been changed since I last needed it! I’ll try get to it soon.

    Thread Starter Brian Henry

    (@brianhenryie)

    Here’s some additional information.

    The error is occurring during the mw_qbo_sync_queue_cron_hook action.

    Line 380 is (recursively) calling the current method _asXML_v3 with arguments 2, "SalesItemLineDetail", null, null

Viewing 15 replies - 1 through 15 (of 61 total)