WordPress.org

Ready to get started?Download WordPress

Forums

shortcode in custom field (7 posts)

  1. betzy
    Member
    Posted 2 years ago #

    can someone help me parse this shortcode [wp_cart:PRODUCT-NAME:price:PRODUCT-PRICE:end] into custom field ?

  2. vtxyzzy
    Member
    Posted 2 years ago #

    Are you storing the shortcode string you showed in the custom field? Are you already retrieving the custom field?

    If the answer to both is 'yes', then you can use code like the following (assuming the custom field is 'cart-info'):

    $cart_info = get_post_meta($post->ID, 'cart-info', true);
    echo do_shortcode($cart_info);
  3. betzy
    Member
    Posted 2 years ago #

    well it”s like this

    above the loop i”ve put this
    <?php $price = get_post_meta( $post->ID, ‘price’, true ); ?>

    and i want to display the add to cart button i have this
    <?php echo print_wp_cart_button_for_product($name, $price); ?>

    it”s not working right

    the add to cart button apear on every post, when u press it it add product in cart with no name and no price
    when i sdd key=price and value= 25 it add to cart same noname and noprice product :(

  4. vtxyzzy
    Member
    Posted 2 years ago #

    above the loop i”ve put this
    <?php $price = get_post_meta( $post->ID, ‘price’, true ); ?>

    Is the post ID available above the loop?

  5. betzy
    Member
    Posted 2 years ago #

    i have no idea :)

  6. vtxyzzy
    Member
    Posted 2 years ago #

    You might need to hire someone to help with this. You can post a free job request on jobs.wordpress.net.

  7. betzy
    Member
    Posted 2 years ago #

    this is how u do it

    <?php $price = get_post_meta( $post->ID, 'price', true ); ?>
    <?php $name = get_the_title(); ?> <?php echo print_wp_cart_button_for_product($name, $price); ?>

    that code display the add to cart button

    Price: <?php echo get_post_meta($post->ID, 'price', true); ?> $
    and that”s for the price to be displayed

    have fun

Topic Closed

This topic has been closed to new replies.

About this Topic