Render custom fields in the Email Template
-
Hello, I want to be able to manually add a shipping link from the order page like I did in this example with google.com and eventually this field be rendered in an href tag in the Email Template.
I’ve added a custom snippet below which creates the Shipping link input you can see above
// Add a custom field to the WooCommerce order edit page add_action( 'woocommerce_admin_order_data_after_order_details', 'add_shipping_link_metafield' ); function add_shipping_link_metafield( $order ) { $shipping_link = get_post_meta( $order->get_id(), '_shipping_link', true ); ?> <div class="order_data_column"> <h4><?php _e( 'Shipping Link', 'textdomain' ); ?></h4> <input type="text" name="shipping_link" value="<?php echo esc_attr( $shipping_link ); ?>"> </div> <?php } // Save the custom field value add_action( 'woocommerce_process_shop_order_meta', 'save_shipping_link_metafield' ); function save_shipping_link_metafield( $post_id ) { $shipping_link = isset( $_POST['shipping_link'] ) ? sanitize_text_field( $_POST['shipping_link'] ) : ''; update_post_meta( $post_id, '_shipping_link', $shipping_link ); }
The problem is the Plugin is not rendering the custom field at all
Here’s what I added in the Template EditorHow can I display my custom field here?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Render custom fields in the Email Template’ is closed to new replies.