Refer to 3 items on a template

WordPress
May 04, 2021 07: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 ?
May 04, 2021 11:33:45
E2Pdf
Topics: 7
Messages: 3617
Support
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!
Get News and Updates
Our monthly newsletter keeps you in the loop, so you'll always be up to date with the latest news and updates about E2Pdf.
* You can update your email subscription preferences here.
All trademarks, service marks, trade names, product names, and logos appearing on this website are the property of their respective owners. The use of trademarks such as Formidable Forms®, Forminator Forms®, Gravity Forms®, JetFormBuilder®, WordPress®, WooCommerce®, WPForms® and others is solely for identification purposes (nominative use) and does not imply any affiliation, sponsorship, or endorsement by the respective trademark holders.
© 2017 - 2026, https://e2pdf.com

We use cookies to collect and analyse information on site performance and usage, to provide social media features and to enhance and customise content and advertisements. By clicking "Accept Selected", you consent to use of selected cookies according to our Cookie Policy.