Forum Replies Created

Viewing 15 replies - 1 through 15 (of 26 total)
  • Plugin Contributor Brian Watson

    (@bswatson)

    Hello!

    We still do monitor and fix issues as we can, but have not had a chance to actively test against the latest versions of WordPress or WooCommerce. If you run in to an issue, please submit a support request and we’ll either provide a workaround or get a fix in place.

    Thank you!

    Plugin Contributor Brian Watson

    (@bswatson)

    I have not had a chance to test this, so I apologize if it doesn’t work without some tweaking. Here’s an example plugin that you could try that would add a “Weekly at 5pm” option.

    Hope this helps get you going in the right direction!

    <?php
    /**
     * Plugin Name: Limit Orders for WooCommerce - Weekly Intervals at 5pm
     * Description: Add a "Weekly at 5pm" option to Limit Orders for WooCommerce.
     * Author:      Nexcess
     * Author URI:  https://nexcess.net
     */
    
    /**
     * Add "Annually" to the list of intervals.
     *
     * @param array $intervals Available time intervals.
     *
     * @return array The filtered array of intervals.
     */
    add_filter( 'limit_orders_interval_select', function ( $intervals ) {
    	// Return early if it already exists.
    	if ( isset( $intervals['weekly_at_5pm'] ) ) {
    		return $intervals;
    	}
    
    	$intervals['weekly_at_5pm'] = sprintf(
            /* Translators: %1$s is the first day of the week, based on site configuration. */
            _x( 'Weekly (resets every %1$s) at 5pm', 'order threshold interval', 'limit-orders' ),
            $wp_locale->get_weekday( get_option( 'start_of_week' ) )
        );
    
    	return $intervals;
    } );
    
    /**
     * Get a DateTime object representing the beginning of the week at 5pm.
     *
     * @param \DateTime $start    The DateTime representing the start of the current interval.
     * @param string    $interval The type of interval being calculated.
     *
     * @return \DateTime A DateTime object representing the top of the current hour or $start, if the
     *                   current $interval is not "weekly_at_5pm".
     */
    add_filter( 'limit_orders_interval_start', function ( $start, $interval ) {
    	if ( 'weekly_at_5pm' !== $interval ) {
    		return $start;
    	}
    
        $start = current_datetime();
    
        $start_of_week = (int) get_option( 'week_starts_on' );
        $current_dow   = (int) $start->format( 'w' );
        $diff          = $current_dow - $start_of_week;
    
        // Compensate for values outside of 0-6.
        if ( 0 > $diff ) {
            $diff += 7;
        }
    
        // A difference of 0 means today is the start; anything else and we need to change $start.
        if ( 0 !== $diff ) {
            $start = $start->sub( new \DateInterval( 'P' . $diff . 'D' ) );
        }
    
        return $start->setTime( 17, 0, 0 );
    }, 10, 2 );
    
    /**
     * Filter the DateTime at which the next interval should begin.
     *
     * @param \DateTime $start    A DateTime representing the start time for the next interval.
     * @param \DateTime $current  A DateTime representing the beginning of the current interval.
     * @param string    $interval The specified interval.
     *
     * @return \DateTime The DateTime at which the next interval should begin, or $start if the
     *                   current $interval is not "weekly_at_5pm".
     */
    add_filter( 'limit_orders_next_interval', function ( $start, $current, $interval ) {
    	if ( 'weekly_at_5pm' !== $interval ) {
    		return $start;
    	}
    
    	return $current->add( new \DateInterval( 'P7D' ) );
    }, 10, 3 );
    
    • This reply was modified 2 years, 8 months ago by Brian Watson.
    Plugin Contributor Brian Watson

    (@bswatson)

    Hello!

    Apologies for the delay, but we’ll check this out and see if we can replicate or get an idea what may be causing the issue.

    One question I have to help point us in the right direction –

    When you say it stops working, does that mean it continues to allow orders even after the limit has been reached, or does it stop allowing orders prior to the limit?

    Thank you!

    Plugin Contributor Brian Watson

    (@bswatson)

    Hello!

    Each time a customer goes through the checkout process, it counts as one order. The plugin does not restrict the number of items in an order, just the total amount of orders in a given time frame.

    You can test if this is working by completing four additional orders. When you go to make a 5th, you should then see the add to cart button removed and a message in its place.

    Thank you for checking out the plugin and let us know if you continue to see issues.

    Plugin Contributor Brian Watson

    (@bswatson)

    Hello and thank you for checking out the plugin!

    The plugin does not currently have the ability to restrict orders based on the dollar amount. The complexity when dealing with multiple product prices would make it difficult to target a specific amount.

    Number of items sold is not supported, but would be significantly easier to implement and we can evaluate if it would fit as part of this plugin.

    Our primary developer on this plugin is out for the week, but I’ll follow up next week after I have a chance to discuss with him.

    Plugin Contributor Brian Watson

    (@bswatson)

    @studioforonda,

    We’ll be releasing an update shortly that includes the ability to limit orders per hour.

    I’m not sure if it’ll be out today, but we’ll definitely have it available by the end of the week.

    Thanks for the suggestion!

    Plugin Contributor Brian Watson

    (@bswatson)

    @dunsterd

    At the moment, we’ve written it with support for the latest version of WooCommerce (4.0). WooCommerce has not supported PHP 5.6 since version 3.9, so we likely won’t be going back to implement compatibility with that version.

    Plugin Contributor Brian Watson

    (@bswatson)

    Great to hear!

    Plugin Contributor Brian Watson

    (@bswatson)

    We would likely need to build a custom integration with that plugin to make it work.

    Not saying that it can’t be done, but it would likely require more time than we currently have to allocate to this plugin.

    I see the WooCommerce Order Delivery plugin has a request board and it does look like that feature is the most frequently requested item.

    I’ve created a ticket in the GitHub project to track this, and will let you know if we work out a solution.

    Plugin Contributor Brian Watson

    (@bswatson)

    Great to hear!

    Plugin Contributor Brian Watson

    (@bswatson)

    Wanted to check in and see if things are working as expected now. Let us know if you continue to see any issues.

    Thanks!

    Plugin Contributor Brian Watson

    (@bswatson)

    Wanted to check in and see if things are working as expected now. Let us know if you continue to see any issues.

    Thanks!

    Plugin Contributor Brian Watson

    (@bswatson)

    @ehlanafoley,

    How do you set the delivery date within WooCommerce? Is it a custom field or are you using a plugin to handle that?

    Plugin Contributor Brian Watson

    (@bswatson)

    Hey @bizdata

    We were able to track down the cause of this and just released v1.1.2 to fix it. Please download the update and let me know if you continue to see any issues.

    Thanks!

    Plugin Contributor Brian Watson

    (@bswatson)

    I believe we’ve tracked the source of this to a default limit on one of the queries. We’re writing the automated test now to confirm it and the fix and should have a new release out later today.

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