I have a nimble question that i am not getting any answer of. I have added a custom field using "Checkout Field Editor" in Woocommerce Checkout fields. The field is given below and seems to be working fine.
<input class="input-text " name="wc_order_field_7542" id="wc_order_field_7542" placeholder="Pickup Date" value="" type="text">
However, now I am working on a plugin and want to get value inputted in this specific field and cannot seem to figure out. For the other fields I am simply doing the following as I am doing for "billing email" and it is working:
public function get_billing_email() {
$billing_email = $this->order->billing_email;
return apply_filters( 'xc_woo_cloud_print_billing_email', $billing_email, $this );
}
public function billing_email() {
echo $this->get_billing_email();
}
I am sure I am forgetting something and not doing something right.
Any help is appreciated.
For a custom field in your plugin, as $this->order
seems to be the instance of the WC_Order
object, you will try to use $this->order->get_id()
to get the order ID.
Now you can try something using WordPress get_post_meta()
to get your custom field value, this way:
$pickup_date = get_post_meta( $this->order->get_id(), 'wc_order_field_7542', true );`
But check in
wp_postmeta
database table for themeta_key
'wc_order_field_7542'
that should exist for your orders. If it's not the case, you will have to find out the correctmeta_key
that is handling the pickup date data...