Cart66 lite add_to_cart shortcode in template file (2 posts)

  1. kiets
    Posted 4 years ago #

    I would like to add the cart66 shortcode to my template file as such:

    <?php echo do_shortcode( '[add_to_cart item="1"]' ) ?>

    However, as you can see it will always then call item no. 1. Instead i want it to get the item number from the post so i can have a universal shortcode. For example, <?php echo do_shortcode( '[add_to_cart item="GETTHECUSTOMVALUE"]' ) ?>

    Any idea how to do this?

  2. kiets
    Posted 4 years ago #

    I've managed to solve it.
    What i did was pretty ingenius.
    add a custom field scode and include the shortcode in it.

    then anywhere in a template file, just run this

    if ( get_post_meta($post->ID, 'scode', true) )
    echo do_shortcode(get_post_meta($post->ID, 'scode', $single = true));

    hope it helps anyone else out there.

Topic Closed

This topic has been closed to new replies.

About this Topic