• Resolved arkimaison

    (@arkimaison)


    Hi, I have a problem that I can’t solve.
    I installed the WooCommerce Checkout Manager plugin, to be able to add other fields on the Checkout page.
    These fields that I entered do not appear to me, in any way.
    I tried replacing the theme… to no avail
    I tried replacing with other Checkout Manage plugins… to no avail
    I tried many other tests… to no avail
    My site is https://www.ar-ki.it/checkout/, but it is currently under maintenance
    On an old site that I updated, strangely it’s still working… milani6.com
    How can I add other fields such as VAT or other?

Viewing 5 replies - 1 through 5 (of 5 total)
  • If the plugin is not working for you, and you don’t mind a bit of coding you could try adding the following code to your functions.php:

    // Add VAT field to the Checkout Page
    add_action('woocommerce_after_order_notes', 'add_custom_checkout_field');
    
    function add_custom_checkout_field($checkout) {
        echo '<div id="custom_checkout_field"><h2>' . __('VAT Number') . '</h2>';
        woocommerce_form_field('vat_number', array(
            'type'          => 'text',
            'class'         => array('vat-number-field form-row-wide'),
            'label'         => __('Enter VAT Number'),
            'placeholder'   => __('VAT Number'),
            'required'      => true,
        ), $checkout->get_value('vat_number'));
        echo '</div>';
    }
    
    // Validate the VAT number field
    add_action('woocommerce_checkout_process', 'validate_custom_checkout_field');
    function validate_custom_checkout_field() {
        if (!$_POST['vat_number'] || empty($_POST['vat_number']))
            wc_add_notice(__('Please enter your VAT number.'), 'error');
    }
    
    // Save the VAT number to order meta
    add_action('woocommerce_checkout_update_order_meta', 'save_custom_checkout_field');
    function save_custom_checkout_field($order_id) {
        if (!empty($_POST['vat_number'])) {
            update_post_meta($order_id, 'VAT Number', sanitize_text_field($_POST['vat_number']));
        }
    }
    

    @rafaelminuesa

    Is this solution for the traditional checkout or for the woocommerce blocks checkout?

    This would work for the traditional WooCommerce checkout. The WooCommerce Blocks checkout, which uses a block-based system, would require a more complex approach due to its architecture and compatibility issues with many existing plugins and custom code solutions.

    You could create custom block variations for the WooCommerce checkout block. This involves using React and the WordPress blocks API to define new block types that include your custom fields.

    Or you could try the Experimental Additional Checkout Fields API:
    https://github.com/woocommerce/woocommerce/blob/trunk/plugins/woocommerce-blocks/docs/third-party-developers/extensibility/checkout-block/additional-checkout-fields.md

    Or the ‘Simple Custom Fields for WooCommerce Blocks Checkout’ plugin:
    https://ptwooplugins.com/product/simple-custom-fields-for-woocommerce-blocks-checkout/

    Hi there @arkimaison,

    Could you please share with us the direct link to the exact plugin you are using?

    Once we are aware of the plugin, we will be able to provide further steps to take.

    Hi ?? We haven’t heard back from you in a while, so I’m going to mark this as resolved – we’ll be here if and/or when you are ready to continue.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘plugin WooCommerce Checkout Manager’ is closed to new replies.