• Resolved toolsavvy

    (@toolsavvy)


    Hi,

    I use your other plugin (WP Currency switcher). It has a shortcode to use if you want to use currency switcher with a price from a meta value. I was using Advanced Custom Fields plugin and had a meta value fora price of base_price. So I use the following shortcode…

    [wpcs_price meta_value="base_price"]

    I am switching my site to woocommerce and I wanted to use woocs, but I cannot find a shortcode to use meta value. I tried…

    [woocs_price meta_value="base_price"]

    ..but that doesn’t work. Is there another shortcode I can use for price from a meta value?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter toolsavvy

    (@toolsavvy)

    I just found a way!!! If you have another way, I would like to know what it is.

    With my way, you have to use:

    ? [woocs_price meta_value=”x”] shortcode

    ? Advanced Custom field “get_field” and

    ? do_shordcode() BUT you have to switch around the single and double quotes on the do_shortcode() form it’s normal syntax.

    So in my case, I have an ACF meta key called “base_price”, so this is what my code looks like…

    <?php 
    $base_price = get_field('base_price', $post_id);
    echo do_shortcode( "[woocs_show_custom_price value='$base_price']" );
    ?>

    This works for me. I hope it helps someone else. Again, please post here if there is another way.

    • This reply was modified 5 years, 11 months ago by toolsavvy.

    Hello

    Thank you for cooperation!

    Yes! It’s the right way!

    Thread Starter toolsavvy

    (@toolsavvy)

    Thank you for your reply

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Shortcode for meta value?’ is closed to new replies.