Now i could use a shortcode in the plan price field to let woocommerce convert my plan price to other currencies.
Why? I want to allow another currency based on the WPML language setting. Sometimes it makes no sense to use WooCommerce products for service products and therefore i found the solution to use the filter 'wcml_formatted_price' with an own new shortcode to generate the right currency for the price list.
Yes you are right -> i could translate the page content with the manual typed price BUT we are in switzerland with German, French and Italian language and some of my customers are Expats with English and then if have customers in Germany with German and in Spain with Spanish -> now it makes sense to convert the daily conversion rate from Swiss Franks to Euro. It depends on the actual language and location which currency will be shown.
Therefore i wrote an own function for my custom shortcode and it works nicely. See screenshots.
To add support for shortcodes in Price field, you can add this code in functions.php of your child theme by targeting the plan_price attribute of Pricing Table element:
I tweaked the pricing table lab_pricing_table.php file in line 137 and added do_shortcode - now the new line is:
<p class="price"><?php echo do_shortcode( $atts['plan_price'] ); ?></p>
Now i could use a shortcode in the plan price field to let woocommerce convert my plan price to other currencies.
Why? I want to allow another currency based on the WPML language setting. Sometimes it makes no sense to use WooCommerce products for service products and therefore i found the solution to use the filter 'wcml_formatted_price' with an own new shortcode to generate the right currency for the price list.
Yes you are right -> i could translate the page content with the manual typed price BUT we are in switzerland with German, French and Italian language and some of my customers are Expats with English and then if have customers in Germany with German and in Spain with Spanish -> now it makes sense to convert the daily conversion rate from Swiss Franks to Euro. It depends on the actual language and location which currency will be shown.
Therefore i wrote an own function for my custom shortcode and it works nicely. See screenshots.
function kalium_currency( $atts ) {
$atts = shortcode_atts( array(
'price' => '0',
'base' => 'CHF',
'currency' => 'CHF'
), $atts, 'kalium_currency' );
$new_price = apply_filters( 'wcml_formatted_price', $atts['price'], $atts['currency'] ) . '<sup>*</sup>';
return $bws_price;
}
add_shortcode( 'kalium_sc_currency', 'kalium_currency' );
The shortcode for this example would be:
[kalium_sc_currency price="350"] for the base price
[kalium_sc_currency price="350" currency="EUR"] for the base price converted to Euro and so on
Attached files: Screenshot (245).png
Screenshot (246).png
Screenshot (247).png
Screenshot (248).png
Hi Andre,
To add support for shortcodes in Price field, you can add this code in functions.php of your child theme by targeting the plan_price attribute of Pricing Table element:
This way you will add minimal code and control the output of the element attributes.
Now you are able to use any kind of function/filter for all the attributes (even do_blocks).