Tips and Tricks HQ Support

Support site for Tips and Tricks HQ premium products

  • Home
  • Contact Us
  • Documentation
  • Forum Home
    • Forum
    • Forum Search
    • Forum Login
    • Forum Registration

Call product through a custom field

by

Tips and Tricks HQ Support Portal › Forums › WP eStore Forum › WP eStore Tweaks › Call product through a custom field

Tagged: custom field, custom themes, hacks, product

  • This topic has 3 replies, 2 voices, and was last updated 15 years, 6 months ago by amin007.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • November 10, 2009 at 7:27 am #408
    zac
    Member

    Any thoughts how I could have the product info called through a custom field ? Because of the way I am trying to design the template, this would be ideal for me as I want the products to not be a part of the_content. I just tried something like

    <?php if ( get_post_meta($post->ID, ‘productOne’, true) ) { ?>

    <?php echo get_post_meta($post->ID, “productOne”, $single = true); ?>”>

    <?php } ?>

    with this as the field : [wp_eStore:product_id:2:end]

    but it didnt work.. any way I could accomplish this ? Thanks.

    November 10, 2009 at 8:40 am #15910
    amin007
    Participant

    @Zac, the shortcodes work on wordpress post or page not on template files. So you need to call the PHP appropriate PHP file to create the Add to Cart button. Have a look at the available PHP function in the PHP function references list:

    http://www.tipsandtricks-hq.com/ecommerce/wp-content/uploads/2009/09/wp-estore-shortcodes.pdf

    Or you can use the do_shortcode() function and pass the shortcode through it.

    November 11, 2009 at 4:14 am #15911
    zac
    Member

    Thank you for the reply. Not quite what I need but closer… would it be possible you think for me to use the custom field just to put in the product id? Something like:

    <?php if ( get_post_meta($post->ID, ‘productOne’, true) ) { ?>

    <?php echo get_button_code_for_product(<?php echo get_post_meta($post->ID, “productOne”, $single = true); ?>”>); ?>

    <?php } ?>

    Then the custom field the client could just enter their product number.. would this work ??

    … well I know that doesnt work… but something like that.. I am not sure how to write the php… or if it is possible ??

    November 11, 2009 at 7:52 am #15912
    amin007
    Participant

    Yep, something like this should definitely work.. do a test like the following:

    <?php
    if (get_post_meta($post->ID, 'productOne', true))
    {
    //first check to make sure you are getting the product id of the product
    $product_id = get_post_meta($post->ID, 'productOne', true);
    echo $product_id;

    //then pass the product id to the function
    echo get_button_code_for_product($product_id); ?>
    }
    ?>

    This way you will be able to see which part isn’t working

    Another related post:

    https://support.tipsandtricks-hq.com/forums/topic/custom-fields-within-php-shortcodes

  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Log In

Forum Related

  • Forum Home
  • Forum Search
  • Forum Registration
  • Forum Login

Support Related Forms

  • Contact Us
  • Customer Support
  • Request a Plugin Update
  • Request Fresh Download Links

Useful Links

  • Plugin Upgrade Instructions
  • WP eStore Documentation
  • WP eMember Documentation
  • WP Affiliate Platform Documentation
  • Tips and Tricks HQ Home Page
  • Our Projects

Quick Setup Video Tutorials

  • WP eStore Video Tutorial
  • WP eMember Video Tutorial
  • WP Affiliate Platform Video Tutorial
  • Lightbox Ultimate Video Tutorial

Our Other Plugins

  • WP Express Checkout
  • Stripe Payments Plugin
  • Simple Shopping Cart Plugin
  • Simple Download Monitor

Copyright © 2025 | Tips and Tricks HQ