Populate custom checkout fields with data from previous orders
-
I have created a few custom checkout fields using the WooCommerce documentation available here: https://woocommerce.com/document/tutorial-customising-checkout-fields-using-actions-and-filters/
My problem stems from the fact that these custom fields are saved on the order object. Because of this, when the client wants to make a new order, the custom fields are not populated.
The obvious solution would be to save the custom field data on the $user object, not only on the $order object, like WooCommerce does by default for some of the fields like Billing Name, Billing country etc. But I do not know how to do this for a custom field. Is there a canonical way to accomplish this?
I know I can get the current user, loop through his order history, take the latest order and get the values from there and populate the checkout field with them, but I was wondering if there is a proper way to do this, because it seems like a hack to me.
- The topic ‘Populate custom checkout fields with data from previous orders’ is closed to new replies.