Forum Replies Created

Viewing 10 replies - 1 through 10 (of 10 total)
  • Thread Starter nolabelstudios

    (@nolabelstudios)

    We are using Version 2.0.6.12 of “WooCommerce AJAX Products Filter”.

    Thread Starter nolabelstudios

    (@nolabelstudios)

    We are using WP Job Manager and add-ons which allow users to create jobs, resumes etc from the front end. These forms are powered by WP Job Manager and the extensions.

    Thread Starter nolabelstudios

    (@nolabelstudios)

    Update: When viewing all “Saved Templates” this is what I see… https://prnt.sc/yArzfsfYediE

    Please fix this as it is a great feature, but clearly wasn’t styled up before release.

    Thread Starter nolabelstudios

    (@nolabelstudios)

    I tried every option and nothing works. If everything else is correct I guess it could be a plugin conflict.

    I’ll try to resolve this later.

    Thread Starter nolabelstudios

    (@nolabelstudios)

    1. Great, it sounds like it just works out of the box that way.

    2. I’ll use that code and report back if I notice anything weird.

    3. I changed the code to use the class name of the button on my frontend page but it didn’t hide the button. It could be because I can’t seem to get the limits to apply anymore. See below…

    For some reason I can’t get the limits to work at all now. It just says “unlimited” in the WordPress Dashboard widget. This is what I see.

    https://e1.pcloud.link/publink/show?code=XZeBfpZEEUDjjgpH5mH7c8Je7bIULdFXYck

    To confirm my functions.php code has this code in it. Perhaps I copied it wrong – but then again WordPress never flagged an error in the code.

    // User post limits - limit total products and total orders - orders are disabled if limit reached
    
    add_filter( 'upl_query', 'upl_limit_total_posts' );
    add_filter( 'upl_rule_limit_current_user_role_check', 'upl_disable_user_role', 10, 2 );
    
    function upl_limit_total_posts( $args ) {
    	$post_types = [ 'shop_order', 'product' ];
    	if ( in_array( $args['post_type'], $post_types ) ) {
    		unset( $args['author'] );
    	}
    	return $args;
    }
    
    function upl_disable_user_role( $check, $i ) {
    	$post_type = 'shop_order';
    	return $post_type === get_option( 'upl_posts_type' )[ $i ] ? true : $check;
    }
    
    add_filter( 'pre_delete_post', 'upl_restrict_post_deletion', 10, 2 );
    function upl_restrict_post_deletion( $check, $post ) {
    	return ! current_user_can( get_option( 'upl_manage_cap' ) ) && 'shop_order' === get_post_type( $post ) && 'wc-completed' === get_post_meta( $post->ID, '_wp_trash_meta_status', true ) && strtotime( get_the_date( 'Y-m-d', $post ) . ' + 1 month' ) > strtotime( date( 'Y-m-d' ) ) ? false : $check;
    }
    
    // Hide Order System order button from frontend if order limit reached in current cycle
    add_action( 'wp_head', 'upl_hide_button' );
    function upl_hide_button() {
    	echo do_shortcode( '[upl_hide type="shop_order" message="<style>button.orderable-button.orderable-product__add-to-order{ display: none !important; }<style>"][/upl_hide]' );
    }

    I’m very thankful for your support so far especially since this plugin is free. Hopefully you can help me get these final issues ironed out and I’ll leave you be for a while ??

    Thread Starter nolabelstudios

    (@nolabelstudios)

    Happy to clarify…

    1. If a customer receives orders in the cycle/month and does not delete them will those same orders be counted in the next cycle/month? If they are can those orders NOT be counted in the next cycle/month?

    2. What I need here is a way of preventing shop owners from deleting “completed” orders that were received in the current cycle/month. When the next cycle/month begins I want shop owners to be able to delete previous cycle/months orders.

    3. I can’t wrap the add to cart button in a shortcode (I assume that’s how this should work). Is there a different way of hiding the button if the order limit is reached? For example if I use the adjusted code below it hides the button 100% of the time. Can it be adjusted to only run when the order limit is reached?

    add_action( 'wp_head', 'upl_hide_button' );
    function upl_hide_button() {
    	echo ( '<style>.button{ display: none !important; }<style>' );
    }
    Thread Starter nolabelstudios

    (@nolabelstudios)

    @condless thank you so much for the adjusted code. It worked lovely. I do see some flaws in my setup that require additional help. Apologies for only discovering these now.

    1. Can the code be adjusted so that if an order is set to “Completed” this is no longer counted towards their order limit but only when the next cycle begins?

    2. Likewise, if an order is received, marked as “Completed” and then purged from the “Trash” before the next cycle begins can we still count those deleted items in their shop_order limit for the current cycle? I would only want this to apply for orders who’s status is set to “Completed” before being moved to the trash and purged. Orders that are not set to “Completed” before being deleted should not count towards the total shop_order in the current cycle.

    Bonus question – Is there any way of preventing customers from adding items to their basket and/or getting to the checkout page once the shop_order is reached for the current cycle? I don’t want customers to be able to create an order, which likely takes time and effort, only to be disappointed when the checkout fails and no error is shown to confirm why.

    Perhaps we could hide a certain class or id from the front end to prevent customers clicking the “add to cart” button. Is that possible once the total shop_order limit is reached in the current cycle? The frontend element is:

    button.orderable-button.orderable-product__add-to-order

    Thread Starter nolabelstudios

    (@nolabelstudios)

    Also, this setting doesn’t actually stop someone placing an order on the front end of the site. It only stops backend order creation.

    Thread Starter nolabelstudios

    (@nolabelstudios)

    Hi,

    I’ve added the code and it works well. What if I need to limit the total number of sitewide posts for 3 post types?

    The code I have running at the moment is this:

    add_filter( 'upl_query', 'upl_limit_total_posts' );
    function upl_limit_total_posts( $args ) {
    	$post_type = 'shop_order';
    	if ( $post_type === $args['post_type'] ) {
    		unset( $args['author'] );
    	}
    	return $args;
    }

    Thank you for your continued help.

    Thread Starter nolabelstudios

    (@nolabelstudios)

    @condless do I apply this to my functions.php file? Please confirm.

Viewing 10 replies - 1 through 10 (of 10 total)