Make Purchase Order Number Required

[ad_1]

Hi there, @rwps.

Yes, you can. The current version of the plugin doesn’t have the setting to do so. But, we’ve made a custom snippet below for you to make the PO Number required instead of optional.

add_action( 'woocommerce_after_checkout_validation', 'igfw_po_number_required_on_checkout', 10, 2 );
function igfw_po_number_required_on_checkout( $data, $errors ){
    if (
        $data['payment_method'] === 'igfw_invoice_gateway' &&
        get_option('igfw_enable_purchase_order_number') == 'yes' &&
        ( ! isset( $_POST['igfw_purchase_order_number'] ) || empty( $_POST['igfw_purchase_order_number'] ) )
    ) {
        $errors->add( 'billing_po_number_error', __( 'Please enter a PO Number.', 'invoice-gateway-for-woocommerce' ) );
    }
}

add_filter( 'igfw_purchase_order_number_title', 'igfw_po_number_title_on_checkout' );
function igfw_po_number_title_on_checkout( $title ){
    return __( 'Purchase Order (required)', 'invoice-gateway-for-woocommerce' );
}

Also, thanks for using our plugin and let me know how it goes.

Cheers!

Hi @rwps,

Currently, there is no option to make the PO field required or modify available filters. So, unfortunately, I am unable to provide custom snippets.

I’ll raise a feature request for this with our development team but please keep in mind that we aren’t able to provide any ETAs when it’ll be developed or made.

In the meantime, let us know if you have other questions.

Cheers,

Thread Starter
ssrw

(@rwps)

@harirymera

Thank you! That worked well!

I have another question but I’ll start a new topic for that.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer