Tips and Tricks HQ Forum

Support Forum for Tips and Tricks HQ Products

Register or log in - lost password? (Having an issue with the forum login?)

Search the Forum

Tips and Tricks HQ Forum » WP eStore Forum

Adding Category name to Description in wp_eStore_show_all_products style=2

(3 posts) (2 voices)
  • Started 8 months ago by dichotomy
  • Latest reply from dichotomy
  • Possible Solutions (Related Topics):
    1. Adding facebook like link to wp_eStore_show_all_products style=2
    2. Adding Product Description to Categories Style 3?
    3. Getting the following error - Error establishing a database connection
    4. Fancy2 offset using [wp_eStore_category_products_fancy id=8 style=2 order=1]
    5. Umlaut / vowel mutation in Category description

Tags:

  • category
  • fancy 2
  1. dichotomy
    Member

    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>';
    Posted 8 months ago #
  2. admin
    Key Master

    The 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.

    Posted 8 months ago #
  3. dichotomy
    Member

    Thank 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... :D

    Posted 8 months ago #

RSS feed for this topic

Reply

You must log in to post.

Tips and Tricks HQ  | WP Shopping Cart  | WP Affiliate Software  | WordPress Membership Plugin