Developers – How to extend or add support for third party plugins

A Buy Now link, when all required information like, account details, addresses, payment information, available, it performs all checkout process in background & then finally redirects to Thank you page.

Sometimes, there are custom fields added by third party plugins, which is required to be filled up during checkout process, but Buy Now plugin don’t know about those fields, so it doesn’t process these values.

Therefore a hook buy_now_post_fields is provided in the plugin, which runs during the checkout process.

Third party plugin developers can extend this hook & can pass custom field’s values for processing during checkout.

Here’s a sample code for reference:

/**
 * To add/process custom field
 *
 * @param int $last_order_id
 * @param WP_User $current_user
 */
function process_custom_fields( $last_order_id, $current_user ) {
    /**
     * Write your code here
     */
}
add_action( 'buy_now_post_fields', 'process_custom_fields', 10, 2 );
« Back to WooCommerce Buy Now