Add custom fields to quote requests

Note: This article is a custom coding article and it requires coding knowledge and knowledge of PHP / JavaScript specifically. It is intended for advanced users and programmers. Please note that customization or custom coding is not supported under Envato terms and it is not something we can assist with.

To modify the plugin and add an extra field to quote requests: #

Specifically, the relevant information for a developer is:

1) You can find the HTML TEMPLATE fields in class-b2bking-public.php, inside the b2bking_add_request_quote_button() function

2) The quote request is processed in public.js inside:

/* Request a custom quote START*/ // On clicking "Request a Custom Quote" button $('#b2bking_request_custom_quote_button').on('click', function(){

In public.js, add a row here:

2250784195.png

Basically you need to take the value from the field you added and pass it along to the AJAX.

If you add a row saying mycustomfield: $('#myfield').val()

in the AJAX processing function you will have $_POST['mycustomfield'] available with the value of your field.

3)

The ajax processing function is inside includes/class-b2bking.php inside the function b2bkingrequestquotecart(){

$myfield = sanitize_text_field($_POST['mycustomfield']);

You can then add that variable to the $message or anything else you need to do with it.

Powered by BetterDocs