ARTICLE AD BOX
The problem:
I was designing an online store and needed to perform a simple mathematical calculation between meta fields of custom post types (CPTs). Since there is no clear documentation on how to do this using the native JetEngine tools embedded into your Elementor plugin, I resorted to the old-fashioned way by adding a PHP custom code. In this case, I modified the theme’s functions.php file. I then assigned the required variables to the native WordPress shortcodes and attempted to display them in JetEngine listings, popups, and custom posts. Here's where the issue begins:
If the value I’m trying to display via the WordPress shortcode is static and not fetched from the CPTs using $var = jet_engine()->listings->data->get_meta($var2) it somewhat works for all the listed elements, though not without issues.
However, if I try to fetch data using $var = jet_engine()->listings->data->get_meta($var2); and perform calculations or simply assign the fetched data to the native WordPress shortcode, and then try to display this value on JetEngine listings, popups, or custom posts, the shortcodes only work properly for custom posts. For Jet listings and popups, I cannot get them working correctly at all.
I've created a separate WP test site to show the problem I cannot solve that it would look more understandable for you.
Steps to Reproduce the problem:
1. Create a CPT with multiple meta fields (shown in the screenshot):



2. Create multiple posts for this CPT (I created 5 posts for better visibility). Then, add 5 dynamic field widgets with the corresponding text in the fallback area. Also add tooltips to each dynamic field with the same text (the last tooltip has a different text to display multiple shortcodes). Add a button for the Jet popup for each post. I've attached screenshots:




3. Create the listing according to the screenshot (don’t forget to make it clickable so users are redirected to the main post by clicking on the listing element). Add 5 dynamic field widgets with the corresponding text in the fallback area, and add the button for the Jet popup. Also add tooltips to each dynamic field with the same text (the last tooltip has a different text to display multiple shortcodes):


4. Create a popup as shown in the screenshot and add 5 dynamic field widgets with the corresponding text in the fallback. Don't forget to also add tooltips as we've already done for posts and listings:

5. Copy the following code that I’ve written for this example into the functions.php file of the native Elementor theme or to a php snippet area and update it:
// SC code for jetengine croco test add_shortcode("sc_rat", function () { $purchased_field = 'sold'; // The ID of the "sold" field $replaced_field = 'replaced'; // The ID of the "replaced" field // Fetch the values of the "sold" and "replaced" fields from the current post $purchased_value = jet_engine()->listings->data->get_meta( $purchased_field ); $replaced_value = jet_engine()->listings->data->get_meta( $replaced_field ); // Initialize the percentage result $percentage = 0; // Ensure that the "sold" value is greater than 0 to avoid division by zero if ( $purchased_value > 0 ) { // Calculate the percentage of replaced items relative to sold items $percentage = ( $replaced_value / $purchased_value ) * 100; } $percentage_display = number_format_i18n($percentage, 2); return "$percentage_display %"; }); // SC code for jetengine - test % - car model add_shortcode("car_model_sc", function () { $carmodelvalue = 'car_model'; // Define the car model key // Fetch the car model value using JetEngine's dynamic meta handling $carmodel_var = jet_engine()->listings->data->get_meta($carmodelvalue); // Ensure the car model value is not empty before returning it if ($carmodel_var) { return $carmodel_var; // Return the car model value } else { return 'No data'; // Return a fallback message if no value is found } }); // SC code for jetengine - test % - price add_shortcode("car_price_sc", function () { $car_price_value = 'price'; // Define the car model key // Fetch the value of the "car_model" field using JetEngine $car_price_var = jet_engine()->listings->data->get_meta($car_price_value); // Ensure the car model value is not empty before returning it if ($car_price_var) { return $car_price_var; // Return the car model value } else { return 'No data'; // Return a fallback message if no value is found } }); // SC code for JetEngine - Car Sold add_shortcode("car_sold_sc", function () { $car_sold_key = 'sold'; // Define the key for the "sold" field // Fetch the value of the "sold" field using JetEngine $car_sold_var = jet_engine()->listings->data->get_meta($car_sold_key); // Ensure the car sold value is not empty before returning it if ($car_sold_var) { return $car_sold_var; // Return the car sold value } else { return 'No data'; // Return a fallback message if no value is found } }); // SC code for JetEngine - Car Replaced add_shortcode("car_replaced_sc", function () { $car_replaced_key = 'replaced'; // Define the key for the "replaced" field // Fetch the value of the "replaced" field using JetEngine $car_replaced_var = jet_engine()->listings->data->get_meta($car_replaced_key); // Ensure the car replaced value is not empty before returning it if ($car_replaced_var) { return $car_replaced_var; // Return the car replaced value } else { return 'No data'; // Return a fallback message if no value is found } }); // SC code for JetEngine - end of the test code for crocoHere’s the text for the metafields so you don’t have to write it manually - just copy and paste it:
Car models:
06 LCI, F7x 1 Series, i5 (G60E), i4 (G26E), i3
Text for the dynamic field widget to paste into the fallback field:
Car model: [car_model_sc] Car price: [car_price_sc] Car sold: [car_sold_sc] Car replaced: [car_replaced_sc] Replaced ratio: [sc_rat]For text in the last tooltip (the tooltip text for the first 4 fields is the same as the text for the fallback field):
We replaced [car_replaced_sc] cars out of [car_sold_sc] cars sold. This is a [sc_rat] replacement ratio.6. Don’t forget to clear the Elementor Cache and Sync the Library.
Now let's view the results:
1. Open the page with the Jet listing, and you’ll notice that none of the native WordPress shortcodes are displaying the values assigned to them. However, if you hover over the dynamic field, you’ll see that the native WordPress shortcodes are correctly fetching data in the tooltip, including the last tooltip where the shortcodes display the results of calculations:

----->>> Here is a gif image for better explanation <<<-----
2. If you click the popup button on any listing element to open the popup, you’ll see that it has the same issue with native WordPress shortcodes as the listings in point 1:
----->>> Here is a gif image for better explanation <<<-----
3. However, if you open a single post by clicking on the corresponding listing element, all the shortcodes will work perfectly:
----->>> Here is a gif image for better explanation <<<-----
4. For the listing and popup elements, the shortcodes will start working **if you switch the cache settings in the advanced tab of each dynamic field widget to "active."
However, for the listings, even this temporary solution won't fix the problem entirely, because with this "fix" the shortcodes will only work for the dynamic fields, not for the tooltips on them. In the tooltips, the shortcodes will be stuck displaying the values from the first listing for all of them. Try it, and you’ll see the change. But don't forget to clear the Elementor Cache and Sync the Library after making these changes.
Here's a gif showing what I meant:

----->>> Here is a gif image for better explanation <<<-----
Conclusion:
I might be missing something here, but I haven't been able to find a solution to these issues. I’d appreciate any help from you all to work around these problems and get the shortcodes to function properly in the cases mentioned above.
Thank you!
