Skip to content
Advertisement

Setting woocommerce customer note through functions.php not working

In Woocommerce I’m trying to modify the Customer Order note to say “Ship with this provider” when a customer billing/shipping address is a specific city.

WordPress 5.2.2 WooCommerce 3.6.5

I’m using the woocommerce_thankyou hook, getting the order data via order ID and get_customer_note(), set_customer_note().

JavaScript

The echo results display correctly.

JavaScript

When I check the order page the order note is only the original customer note.

JavaScript

It looks like the setter isn’t sending the changes to the database. Is there a method I need to call to make sure that my changes are added to the DB, or should I just do it directly via a wpdb query?

EDIT: Corrected echo results to reflect code.

Advertisement

Answer

Just add the follows code snippet to achieve to task –

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement