WordPress.org

Support

Support » Plugins and Hacks » Cart66 lite add_to_cart shortcode in template file

Cart66 lite add_to_cart shortcode in template file

  • kiets
    Participant

    @oomskaap

    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?
    Thanks

Viewing 1 replies (of 1 total)
  • kiets
    Participant

    @oomskaap

    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

    <?php
    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.

Viewing 1 replies (of 1 total)
  • The topic ‘Cart66 lite add_to_cart shortcode in template file’ is closed to new replies.