Tips and Tricks HQ Support Portal › Forums › WP eStore Forum › Adding Category name to Description in wp_eStore_show_all_products style=2
- This topic has 2 replies, 2 voices, and was last updated 12 years, 7 months ago by dichotomy.
-
AuthorPosts
-
September 3, 2011 at 6:00 pm #4226dichotomyMember
I have a page to show all products using style 2 (wp_eStore_show_all_products style=2)
I would like to add the name(s) of the categories each item is in.
I tried adding the output code below (between the ****, obviously the **** are not in the actual code), but it’s not printing anything. I’m sure it’s fairly easy for someone more familiar with getting database info, but that ain’t me.
Any help is greatly appreciated! THANKS!
function show_product_fancy_style2($id,$button_type=1,$show_price=1,$restriction='')
{
global $wpdb;
$products_table_name = WP_ESTORE_PRODUCTS_TABLE_NAME;
$ret_product = $wpdb->get_row("SELECT * FROM $products_table_name WHERE id = '$id'", OBJECT);
$output = '<div class="eStore-product-fancy2">';
$output .= get_thumbnail_image_section_code($ret_product);
if(!empty($ret_product->product_url))
{
$output .= '<div class="eStore-product-description"> <div class="eStore-fancy2-product-name"><a>product_url.'">'.$ret_product->name.'</a></div>';
}
else
{
$output .= '<div class="eStore-product-description"> <div class="eStore-fancy2-product-name">'.$ret_product->name.'</div>';
}
//$output .= '<div class="eStore-product-description"> <div class="eStore-product-name">'.$ret_product->name.'</div>';
$output .= html_entity_decode($ret_product->description, ENT_COMPAT,"UTF-8");
*****************************************
$output .= '<a>cat_url.'">'.'<strong>'.$wp_eStore_cat_db->cat_name.'</strong></a>';
*****************************************
if (!empty($ret_product->available_copies))
$output .= '<stron g>'.ESTORE_AVAILABLE_QTY.': </strong>'.$ret_product->available_copies;
$output .= '</div></div>';September 4, 2011 at 1:42 am #36216adminKeymasterThe category name is kept in a relations table (this is the most efficient way to relate products to categories since there can be multiple categories per product). So you need to make a query to the category and products relations table and find out the category IDs for a particular product then you can query the category table to find more details for a particular category. If you look at the eStore_installer.php file you will be able to see the structure of the table that I am talking about.
The change you are asking for is not a simple 2 or 3 line code otherwise I would give you an example.
September 13, 2011 at 4:05 pm #36217dichotomyMemberThank you. I fully understand the concept, I’m just not good enough with queries to write it myself. I reckon I’ll give it a try though… That’s how we learn…
-
AuthorPosts
- You must be logged in to reply to this topic.