Refer to 3 items on a template

WordPress
4 May, 2021 00:52:04
M-SOIGNER
Topics: 2
Messages: 4
Hi,
In my template, I use the item "Order". I need to access the "Product" item, contained in the "Order". I found this code on another topic :

add_filter('e2pdf_model_shortcode_e2pdf_wp_response', 'e2pdf_model_shortcode_e2pdf_wp_response_key2', 10, 3);

function e2pdf_model_shortcode_e2pdf_wp_response_key2($response, $atts, $value) {

if (isset($atts['key2']) && $atts['key2']) {
$post_meta = false;
if ($response) {
$post_meta = get_post_meta($response, $atts['key2'], true);
}
if ($post_meta !== false) {
$response = $post_meta;
} else {
$response = '';
}
}
return $response;
}

it works, but now I also need to acces the item "Course", which is the first object contained in the array "Courses" in the product. Could you help me with the code that I need to add "key3" and "path2" in the shortcodes please ?
4 May, 2021 04:33:45
E2Pdf
Support
Topics: 7
Messages: 3188
Hi,

Can you please clarify some information so we can understand the structure of page and PDF data:

1. What is the shortcode that you are using now? and what is its output? As we understand from your description you are getting some product meta value which is stored in meta value of order and you are using something like this: [e2pdf-wp key="key" key2="key2" path="path" meta="true"]. "key" is meta key where stored product ids and "key2" is meta value of product.

2. Which is the new shortcode expected to be used to output needed course info?

If you will modify filter to: https://codeshare.io/GL1xz7 and will use under "key2" meta key of "courses" will it output anything?:

[e2pdf-wp key="key" key2="COURSES_META_KEY" path="path" meta="true"].

We remain at your service.
We would really appreciate your feedback at WordPress.org!