• Resolved deemi24

    (@deemi24)


    Hi there,

    I am creating a WordPress + Woocommerce plugin. In my plugin I added 2 custom meta fields in

    Add New User screen

    And its working fine and saving the data also. But now I want to add custom field and save this data in new table (Not in post meta), but the field section or fields not creating.

    I tried a lot of codes (Hooks + Filters) but it didn’t work.

    Code Try 01

    add_action('woocommerce_after_checkout_shipping_form','wcsf_city_checkout_page');
            function wcsf_city_checkout_page() {
                echo '<div id="custom_checkout_field"><h2>' . esc_html__('Custom City','wcsf') . '</h2></div>';
            }

    Code Try 02

    add_filter('woocommerce_checkout_fields','wcsf_city_checkout_page');
            function wcsf_city_checkout_page() {
                echo '<div id="custom_checkout_field"><h2>' . esc_html__('Custom City','wcsf') . '</h2></div>';
    ????????}

    Code Try 03

    add_action('woocommerce_after_checkout_shipping_form','wcsf_city_checkout_page');
            function wcsf_city_checkout_page() {
                echo '<div id="custom_checkout_field"><h2>' . esc_html__('Custom City','wcsf') . '</h2></div>';
    ????????}

    Code Try 04

    add_filter('woocommerce_checkout_fields','wcsf_city_checkout_page');
        function wcsf_city_checkout_page($checkout) {
            $checkout['shipping']['custom_city'] = array(
                'label'     => __( 'Custom City', 'example' ),
                'type'      => 'text',
                'placeholder'   => _x( 'Type', 'placeholder', 'example'),
                'required'  => false,
                'class'     => array( 'custom_city' ),
                'clear'     => true
              );
              return $checkout;
    ????}

    None of above code are working, they didn’t show me the label on checkout page.

    Note: And also woocommerce plugin show me this kind of warning:

    Deprecated: Creation of dynamic property WC_Order_Item_Shipping::$legacy_package_key is deprecated in plugins\woocommerce\includes\class-wc-checkout.php on line 604
Viewing 4 replies - 1 through 4 (of 4 total)
  • Ahir Hemant

    (@hemant-ahir)

    Hi @deemi24

    Thanks for reaching out!

    I understand that you’re building a plugin to add a custom field on your site’s checkout page, correct?

    Have you checked our Checkout Field Editor? This premium extension provides you with an interface to add, edit, and remove fields shown on your WooCommerce checkout page.?Fields can be added and removed from the billing and shipping sections, as well as inserted after these sections next to the standard ‘order notes’. Core fields can also be moved around giving you more control over your checkout without touching the code.

    In addition, kindly be informed that if you want to try our products, it comes with a 30-day refund policy. If the product doesn’t work the way you need it or you think another product would work better, we are more than happy to offer a full refund. You can read more about our refund policy on our website here.

    Meanwhile, custom coding is not something we can assist with directly. However, I’ll keep this thread open for a bit to see if anyone from the community can lend a hand.

    If you have any other questions related to development or custom coding, don’t hesitate to reach out to some of the great resources we have available for support. The WooCommerce community is filled with talented open-source developers, and many of them are active on the channels listed below:

    Hope this helps!

    For me also its not working.
    I just download fresh wordpress abd setup with woocommerce. I used Astra theme for the website. But when i am trying to add a extra custom filed in checkout page through function.php or any plugins but it not display in checkout page. All the plugins and themes are updated. Please check and help me.

    Plugin Support ckadenge (woo-hc)

    (@ckadenge)

    Hello @soumyasipun,

    As per forum rules, I suggest that you start a new thread with your case, so that we don’t mix several troubleshooting sessions in one thread.

    Even if the symptoms are the same, perhaps the underlying problem is different in your case.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Adding custom field in checkout page not working’ is closed to new replies.