I am using the following nested shortcodes on a page which work just fine:
hidden link
[format_money price='[types field='price-2-day' format='FIELD_VALUE'][/types]']
[wpv-conditional if="( $(wpcf-multi-day) eq '1' )"][types field='price-2-day' format='FIELD_VALUE'][/types][/wpv-conditional]
But if I put the in a popup from https://wordpress.org/plugins/popup-maker/ . The nesting causes issues.
hidden link
Without nesting the shortcodes work fine in the popup:
hidden link
The format money shortcode is take form here: https://toolset.com/forums/topic/transforming-content-in-number-field-as-price/#post-611859
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Hello. Thank you for contacting the Toolset support.
Well - this does not seem to be issue from Toolset as all shortcodes render well when you are not using popup. It should be from popupmaker plugin.
However - as a workaround I'm sharing alternate solution here. I've added another shortcode at:
=> hidden link
function func_format_money_2day( $atts ) {
global $post;
extract( shortcode_atts( array(
'price' => '0'), $atts) );
$price = get_post_meta($post->ID,'wpcf-price-2-day',true);
$money = number_format($price, 0, '', '.').',− €';
return $money;
}
add_shortcode('format_money_2day', 'func_format_money_2day');
And I'm calling it within popup here:
=> hidden link
new shortcode == [format_money_2day]
I can see it works just fine:
=> hidden link
So, you should follow the above method to display values for your required fields.
Hi Minesh,
thanks for the first code work nice 🙂
I can't figure out the other myself... I am not able to evaluate if the mulitday checkbox is checked or not. And the value that is returned always says array rather then 0 or 1.
function func_format_2nd_date_price( $atts ) {
global $post;
if ( get_post_meta($post->ID,'wpcf-multi-day',true) != 0) {
$multi = get_post_meta($post->ID,'wpcf-multi-day',true);
echo "Is Multi " . $multi;
}
}
add_shortcode('format_2nd_date_price', 'func_format_2nd_date_price');
In addition I noticed something odd...
If a - minus/hyphen is placed between two shortcodes it becomes an – en-dash in the popup.
hidden link
No issue on a page:
hidden link
Michael
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Well - as for original issue I've shared the solution. Could you please close this ticket and we will continue with your each new question with new ticket.
I've split the ticket and created a new ticket with your new question.
Hello Minesh,
although the code you provided works fine on it's own inside a conditional check it shows just the shortcode.
please see...
hidden link
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Well - I already shared you the solution here:
=> https://toolset.com/forums/topic/split-issues-with-popupmaker-plugin-check-conditional-field/#post-1155993
Where wee are checking the "multi-day" field equal to 1 within the shortcode as you can see here:
=> https://toolset.com/forums/topic/split-issues-with-popupmaker-plugin-check-conditional-field/#post-1155993
So, you need to use that modified shortcode or adjust the shortcodes as per your need and feel free to close the tickets.
Hi Minesh,
there will be text in the conditional as well that should be editable without going to the php section.
e.g.
[wpv-conditional if="( $(wpcf-multi-day) eq '1' )"]2-Day Course Price [format_money_2day][/wpv-conditional]
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
So - the shortcode should look like:
function func_format_2nd_date_price( $atts ) {
global $post;
$multi_day = get_post_meta($post->ID,'wpcf-multi-day',true);
if ( $multi_day == 1) {
$price = get_post_meta($post->ID,'wpcf-price-2-day',true);
return "2-Day Course Price ".$price;
}
return 0;
}
add_shortcode('format_2nd_date_price', 'func_format_2nd_date_price');
And you need to just call the shortcode without conditional statements as given under:
I might need this shortcode in other context without that text but in a conditionals. Thats why I said if possible I don't want to "hardcode" it to the php. Is this possible somehow?
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Ok - so, I've adjusted the shortcode so you can pass the required text to display or even skip it.
function func_format_2nd_date_price( $atts ) {
global $post;
$multi_day = get_post_meta($post->ID,'wpcf-multi-day',true);
$custom_text = '';
if(isset($atts['text']) and $atts['text']!= ''){
$custom_text = $atts['text'].' ';
}
if ( $multi_day == 1) {
$price = get_post_meta($post->ID,'wpcf-price-2-day',true);
return $custom_text.$price;
}
return 0;
}
add_shortcode('format_2nd_date_price', 'func_format_2nd_date_price');
And you can use it as given under:
With text == [format_2nd_date_price text='2-Day Course Price']
without text == [format_2nd_date_price]
Lovely 🙂
My issue is resolved now. Thank you!