• Resolved daniel0503

    (@daniel0503)


    Hi,

    I am using the WooCommerce Custom Product Addons Free plugin to allow customers to enter a custom text (“Wunschtext”) for certain products in my WooCommerce store (dergugl.de). The field appears correctly on the product page, and customers can enter their desired text without issues.

    Problem: I would like this custom text to be automatically transferred to the “Order Notes” section in the WooCommerce order details after checkout and also shown in the order in the backend. However, this does not happen. The text is stored in the order item metadata but is not visible under customer notes in the order details.

    What I Have Tried

    • Checked the database to confirm that the entered text is being saved as order item metadata.
    • Implemented a hook (woocommerce_checkout_update_order_meta) to transfer the text to customer notes – but it does not seem to work.
    • Verified that there are no relevant errors in WooCommerce logs.
    • Ensured no other plugin is interfering by testing in a clean WooCommerce environment.

    Question

    Is there a built-in way within the Custom Product Addons Free plugin to automatically transfer the entered custom text field value to the customer notes field in WooCommerce?
    Alternatively, do you have a recommended approach or a code snippet to ensure the field is correctly passed to the order notes?

    I appreciate your help and look forward to your response.

    Best regards,
    Daniel

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Vivek Acowebs

    (@viveke)

    We have reviewed your requirement and prepared the following code for you.

    add_action('woocommerce_checkout_update_order_meta', 'custom_update_order_notes_based_on_cart');

    function custom_update_order_notes_based_on_cart($order_id) {

    ? ? $order = wc_get_order($order_id);

    ? ? $order_notes = '';

    ? ? foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {

    ? ? ? ? $product_name = $cart_item['data']->get_name();

    ? ? ? ? $item_data = apply_filters( 'woocommerce_get_item_data', [], $cart_item );

    ? ? ? ? foreach($item_data as $key => $data) {

    ? ? ? ? ? ? if($data['name']=="text_2497282481") { // Replace the Coupon with the actual wcpa field name

    ? ? ? ? ? ? ? ? $addon = $data['value'];

    ? ? ? ? ? ? ? ? $order_notes .= "Product: $product_name | WCPA: $addon \n";

    ? ? ? ? ? ? }

    ? ? ? ? }

    ? ? }

    ? ? if (!empty($order_notes)) {

    ? ? ? ? $order->add_order_note($order_notes);

    ? ? }

    }

    Please try this approach and let us know if it resolves the issue.

    Thread Starter daniel0503

    (@daniel0503)

    Thank you very much for your quick reply. Unfortunately, it did not work with the code that the additional text appears in the backend.

    Plugin Support Vivek Acowebs

    (@viveke)

    We have tested the code and confirmed that it works.
    If it does not work for you, please check the debug log for any errors.
    To ensure effective troubleshooting, we kindly request you to visit our website and initiate a live chat with us directly.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.