- This topic has 3 replies, 2 voices, and was last updated 12 years, 4 months ago by .
Viewing 4 posts - 1 through 4 (of 4 total)
Viewing 4 posts - 1 through 4 (of 4 total)
- You must be logged in to reply to this topic.
Support site for Tips and Tricks HQ premium products
by
Tips and Tricks HQ Support Portal › Forums › WP eStore Forum › WP eStore Tweaks › Getting error – Function integration in PHP
Hi, I’m using “More Fields” plugin to get custom date from the post. So I want to include the product id entered by the admin in more fields textbox. I’m using the below function in my template file.
<?php
$product_id = meta(‘product-id’);
echo show_wp_eStore_product_fancy($product_id,1,3);
?>
When I echo the $product_id separately, It prints the correct product id entered in text box. But when used in the function, It shows ” Looks like you have entered a product ID in the shortcode that doesn’t exist. Please check your product ID and the shortcode again! ” If I replace the “$product_id” with value, say 1, It will outputs the correct product.
How can I achieve this??
I don’t know how that plugin is returning that product ID (the format is most likely not correct) but you don’t need another plugin to retrieve custom fields data of a post. You can use WordPress’s default function to do that. This post has examples that might help:
https://support.tipsandtricks-hq.com/forums/topic/call-product-through-a-custom-field
Thank you so much. That was really helpful. Now it is working.
I got the code to call the “add to cart” button from that topic.
<?php echo get_button_code_for_product($product_id); ?>
I wants to include the products details at different places in my template. So How can I display a product’s name, price, availability separately with the product_id?
I tried to do this:
$product_name = $wpdb->query($wpdb->prepare( "SELECT name FROM wp_wp_eStore_tbl WHERE id ='$product_id'"));
echo $product_name;
But it is not working.
Got it.
$product_name = $wpdb->get_results( "SELECT * FROM wp_wp_eStore_tbl WHERE id ='$product_id'");
foreach ($product_name as $row)
{
echo $row->name;
}
Its working fine. Hope the usage is correct.