WooCommerce RFQ

Turning your online store into a lead generating machine has never been easier with the WooCommerce Request For Quotation Plugin for WordPress. As competition increases with everyone selling the same products online, merchants are beginning to use ecommerce stores as a means to generate inquiries for custom quoted products.

If you have restrictions from your manufacturer for published prices, this plugin in perfect for you to generate interest from potential customers, and turn them into sales. If you sell expensive goods that requires negotiating prices, this plugin will help you start selling online.

Turn all you products into quotable items or pick just a few and mix and match items that can be purchased online and items that need quotes. All you need to do is change the price to zero, and presto, you’ve got a quotable item.

Documentation

Ensure that you have WooCommerce installed. Then upload the contents of via ftp or ssh to the file directory of your wordpress site under wp-content/plugins/

Once installed, change the price of the items you want displayed as quotable items to ZERO. You will notice that on the front end, your quotable item buttons have changed.

Modify / Remove / And Add New Form Fields

List of fields to modify (based on wc checkout):

['billing']['billing_first_name']
['billing']['billing_last_name']
['billing']['billing_company']
['billing']['billing_address_1']
['billing']['billing_address_2']
['billing']['billing_city']
['billing']['billing_postcode']
['billing']['billing_country']
['billing']['billing_state']
['billing']['billing_email']
['billing']['billing_phone']
['order']['order_comments']

Modifying or removing existing fields;

// Hook in to form
add_filter( 'boopis_rfq_form_fields' , 'custom_override_rfq_fields' );

// Our hooked in function - $fields is passed via the filter!
function custom_override_rfq_fields( $fields ) {

    // Remove billing first and last name
    unset($fields['billing']['billing_first_name']);
    unset($fields['billing']['billing_last_name']);

    // Make phone number optional
    $fields['billing']['billing_phone']['required'] = false;

    // Modify name and class of postcode 
    $fields['billing']['billing_postcode'] = array(
        'label'     => __('Zip Code', 'woocommerce'),
        'placeholder'   => _x('Zip Code', 'placeholder', 'woocommerce'),
        'required'  => false,
        'class'     => array('form-row-wide'),
        'clear'     => true
    );

  return $fields;
}

Adding new custom fields

Add the new field:

// Add new custom field
add_action( 'boopis_rfq_after_order_notes', 'custom_select_referal_rfq' );

function custom_select_referal_rfq( $rfq ) {

    woocommerce_form_field( 'referal', array(
        'type'          => 'select',
        'class'         => array('form-row-wide'),
        'label'         => __('How did you hear about us?'),
        'required'        => true,
        'clear'           => false,
        'options'         => array(
            ''                        => __('Select Option', 'boopis-woocommerce-rfq' ),
            'friend'          => __('Friend', 'boopis-woocommerce-rfq' ),
            'coworker'        => __('Coworker', 'boopis-woocommerce-rfq' )
        ),
    ), $rfq->get_value( 'referal' ));

}

Validate the new field;

// Validate new custom field
add_action('boopis_rfq_process', 'custom_select_referal_rfq_process');

function custom_select_referal_rfq_process() {
  // Check if set, if its not set add an error.
    if ( empty($_POST['referal']) ) {
        wc_add_notice( __( 'You must select the referal field.' ), 'error' );
    }
}

Update the new field:

// Update new custom field
add_action( 'boopis_rfq_update_order_meta', 'custom_select_referal_update_order_meta' );

function custom_select_referal_update_order_meta( $order_id ) {
    if ( ! empty( $_POST['referal'] ) ) {
        update_post_meta( $order_id, 'Referal', sanitize_text_field( $_POST['referal'] ) );
    }
}