Here's the code example that adds the file URL from Product Property into a custom macro created for our WooCommerce Custom Emails plugin.
At this example, you will see how it is possible to print the file URL for all the products in the order.
add_filter('rp_wcec_custom_macros', 'rp_wcec_add_custom_macros', 10, 2); function rp_wcec_add_custom_macros($custom_macros, $args) { // Configure the parameters $custom_macro_key = 'prop_file_macro'; $custom_macro_label = __('prop_file_macro'); $custom_macro_value = 'no value'; // default value // Get the order in args $order = $args['order']; // Check if order is actually an object if (is_object($order)) { $order_items = $order->get_items(); foreach ($order_items as $item_id => $item) { $product_id = $item->get_product_id(); $custom_value_array = wccf_get_values(array( 'key' => 'file_macro', 'context' => 'product_prop', 'item_id' => $product_id, 'include_meta' => true )); $file_url = WCCF_Files::get_file_download_link_html($custom_value_array['value'][0]) . '
'; if (!empty($file_url)) { if ($custom_macro_value == 'no value') { $custom_macro_value = $file_url; } else { $custom_macro_value .= $file_url; } } } } // Add custom macro and return the whole array $custom_macros[$custom_macro_key] = array( 'label' => $custom_macro_label, 'value' => $custom_macro_value, ); return $custom_macros; }