• Resolved Warren

    (@rabbitwordpress)


    Hi There,

    We’re using this filter to restrict checkout to a minimum order amount.

    However users are able to bypass this by using the PayPal Express Checkout Button at the basket.

    Is there a way to set a minimum order in your plugin, in PayPal or even a way to hide the Check out with PayPal button until the minimum order amount is reached?

    Many thanks
    Warren

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author WebToffee

    (@webtoffee)

    Hi @rabbitwordpres,

    Please try replacing the snippet with the below-updated snippet in which we have added our plugin filter. You can get the updated snippet from here.

    Thread Starter Warren

    (@rabbitwordpress)

    Hi @webtoffee

    Yes that worked perfectly, thank you so much. Great support as always!

    Just wondering if there is a way to hide the Proceed to checkout button too?

    Many thanks
    Warren

    • This reply was modified 4 years, 8 months ago by Warren.
    Plugin Author WebToffee

    (@webtoffee)

    Hi @rabbitwordpress,

    We have developed a code snippet for this requirement. Please try using the code here.

    Thread Starter Warren

    (@rabbitwordpress)

    Hi @webtoffee

    Okay great thank you very much, I was still able to use Stripe.

    So I used your code from yesterday along with the code I already had to prevent users from getting past the basket page, please see below:

    // Minimum Spend £24 for Nick
    
    add_action( 'woocommerce_check_cart_items', 'required_min_cart_subtotal_amount' );
    function required_min_cart_subtotal_amount() {
        // Only run in the Cart or Checkout pages
       if( is_cart() || is_checkout() ) {
    
            // HERE Set minimum cart total amount
           $min_total = 24;
    
            // Total (before taxes and shipping charges)
           $total = WC()->cart->subtotal;
    
            // Add an error notice is cart total is less than the minimum required
           if( $total <= $min_total  ) {
                // Display an error message
               wc_add_notice( '<strong>' . sprintf( __("A minimum total purchase amount of %s is required to checkout."), wc_price($min_total) ) . '<strong>', 'error' );
           }
       }
    }
    
    /**
     * Set a minimum order amount for checkout
     */
    add_action( 'woocommerce_before_checkout_form', 'wc_minimum_order_amount' );
    add_action( 'woocommerce_checkout_process', 'wc_minimum_order_amount' );
    add_action( 'woocommerce_before_cart' , 'wc_minimum_order_amount' );
    
    function wc_minimum_order_amount() {
        // Set this variable to specify a minimum order value
        $minimum = 24;
    
        if ( WC()->cart->total < $minimum ) {
    
    		add_filter( 'wt_show_paypal_express_button_in_cart_page', 'wt_show_paypal_express_button_in_cart_page', 99 );
    		add_filter( 'wt_show_paypal_express_button_in_checkout_page', 'wt_show_paypal_express_button_in_checkout_page', 99 );
            if( is_cart() ) {
    
                wc_print_notice(
                    sprintf( 'Your current order total is only %s.' ,
                        wc_price( WC()->cart->total ),
                        wc_price( $minimum )
                    ), 'error'
                );
    
            } else {
    
                wc_add_notice(
                    sprintf( 'Your current order total is only %s.' ,
                        wc_price( WC()->cart->total ),
                        wc_price( $minimum )
                    ), 'error'
                );
    
            }
        }
    }
    
    function wt_show_paypal_express_button_in_cart_page($show){
    	$show = false;
    	return $show;
    
    }
    function wt_show_paypal_express_button_in_checkout_page($show){
    	$show = false;
    	return $show;
    
    }

    Please go ahead and close this ticket now and mark as resolved.

    Thanks again for your help!
    Best regards
    Warren

    Plugin Author WebToffee

    (@webtoffee)

    Hi @rabbitwordpress,

    If you are happy with our plugin and support please leave us a review here.

    Thread Starter Warren

    (@rabbitwordpress)

    Hi @webtoffee all done mate, hows that?

    Plugin Author WebToffee

    (@webtoffee)

    Hi @rabbitwordpress,

    Thank you so much for taking the time to leave us a 5-star review.

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

The topic ‘Minimum Spend Amount’ is closed to new replies.