Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Scott DeLuzio

    (@scottdeluzio)

    Hey @defaultbetatester thanks for that suggestion. It didn’t exist in the plugin previously, but I just released an update with a new filter that offers custom conditions for the display of the leave at door option. The filter wc_leave_at_door_custom_display works like this:

    add_filter( 'wc_leave_at_door_custom_display', 'payment_option_display', 10, 2 );
     function payment_option_display( $valid, $session ) {
    	// By default $valid = true. Use conditional logic to set it to false when the leave at door option should not be displayed.
    	if ( in_array( $session->get( 'chosen_payment_method' ), array( 'cod', 'cheque', 'bacs' ) ) ) {
    		$valid = false;
    	}
    	return $valid;
     }

    I think ‘cod’, ‘cheque’, and ‘bacs’ are the only “in person” payment options available in WooCommerce, although there may be others that are added by other plugins. So what this code does is it will return “false” if any of those “in person” payment options are selected. Basically, if an online payment option is selected leave at door will be displayed. Otherwise it will not. You can modify the array as necessary.

    The code can go in your child theme’s functions.php or in a custom plugin.

    Thread Starter defaultbetatester

    (@defaultbetatester)

    Thx for this, will make my life easier

    Plugin Author Scott DeLuzio

    (@scottdeluzio)

    I’m glad to hear that @defaultbetatester

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Option only for online payment’ is closed to new replies.