• Resolved tp911

    (@tp911)


    I am using Paypal Express checkout for my Woocommerce shop. We deliver pizzas, so I need to check the total of the order in Checkout page and need to deliver error message to customer when they try to place an order which has less total amount than the minimum order amount for his postcode. This is how i developed my store. So we almost deliver to 4 or 5 postcodes and each post code has minimum order amount.

    When the user tried to pay by “Cash by hand” method, the error message is displaying perfect but when the user tried to pay through PayPal express check out , the user gets only error mark and the red line(Woocommerce default error style), my custom message is not displaying. Here is the code i am using to display custom error messages.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Contributor AW a11n

    (@slash1andy)

    Automattic Happiness Engineer

    Hey there!

    It looks like the code you were trying to send got stripped out.

    Try using the code block in the editor here (above the text field to respond).

    Hopefully that helps! Have a great one!

    Thread Starter tp911

    (@tp911)

    Below is my code…

    add_action( 'woocommerce_checkout_process' , 'required_min_cart_subtotal_amount');
    // Only run in the Cart or Checkout pages
    function required_min_cart_subtotal_amount() {
       
    	if( is_checkout()) {
    		global $woocommerce;
    
    		// Set the minimum order amount and shipping zone before checking out
            $minimum = 12;
    	  	$county1 	= array(000001);
    		$county2 	= array(000002);
    			
    		// Defining var total amount      
            $cart_tot_order = WC()->cart->total;
            
    		if( $cart_tot_order < 8 && in_array( WC()->customer->get_shipping_postcode(), $county1 )  ) {
    			// Display error message
    			 wc_add_notice( sprintf( '<strong>Eine Mindestbestellmenge von $% s ist erforderlich, um an Ihre Adresse zu liefern.</strong>' 
    	        	. '<br />Aktueller Auftrag: $%s.',
    	        	8,
                    $cart_tot_order	),
    	        'error' );
    	        
    		} elseif( $cart_tot_order < 10 && in_array( WC()->customer->get_shipping_postcode(), $county2) ) {
    				// Display error message
    	        wc_add_notice( sprintf( '<strong>Eine Mindestbestellmenge von $% s ist erforderlich, um an Ihre Adresse zu liefern.</strong>' 
    	        	. '<br />Aktueller Auftrag: $%s.',
    	        	10,
                    $cart_tot_order	),
    	        'error' );
    			}
    }
    • This reply was modified 4 years, 2 months ago by tp911.

    Hi @tp911 ,

    This is a fairly complex development topic. I’m going to leave it open for a bit longer to see if anyone is able to chime in to help you out.

    I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    Since this topic has not had any new responses in the past week, I’m going to set this to resolved. We encourage you – @tp911 – to check out the links posted by Mike above.

    – Joey

    I have a similar problem and I can confirm it.

    I use the woocommerce_after_checkout_validation hook to validate some checkout data and a call to wc_add_notice('XXX', 'error') interrupts the checkout process but the error is not displayed.

    Hello, I had the same problem. Solved by adding this lines into the validation action:

    //Print custom errors on PayPal payment
    if($_POST['payment_method']=='ppec_paypal') 
    wp_send_json_error( array( 'messages' => '<div class="woocommerce-info">'.$error.'</div>' ) );

    Hope this helps.

    Plugin Support Saravanan S, a11n

    (@simplysaru)

    @gustavotroisi

    Thanks for posting your solution here.

    Thank you very much Gustavo!! You saved me!!!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Paypal Express checkout is hiding WC notice’ is closed to new replies.