Need help for function
-
i am using wpstore theme
in homepage it shows
image
title
price
add to carti want to show description also after title similar to single product view
here is the function for home page product
function display_homepage_products(){ global $wpdb; $homepage_products_ids = $wpdb->get_results("SELECT * FROM <code>".WPSC_TABLE_PRODUCT_CATEGORIES."</code> WHERE name = 'homepage products' LIMIT 0 , 30" ,ARRAY_A); if($homepage_products_ids != null){ foreach($homepage_products_ids as $homepage_products_id) { $id = $homepage_products_id['id']; } }else{ $id = ''; } $homepage_products = $wpdb->get_results("SELECT <code>".WPSC_TABLE_PRODUCT_LIST."</code>.id AS Pid, <code>".WPSC_TABLE_PRODUCT_LIST."</code>.name AS Pname, <code>".WPSC_TABLE_PRODUCT_LIST."</code>.price AS Pprice,<code>".WPSC_TABLE_PRODUCT_LIST."</code>.special_price AS Pspecial_price,<code>".WPSC_TABLE_PRODUCT_LIST."</code>.notax AS Pnotax FROM <code>".WPSC_TABLE_PRODUCT_LIST."</code> INNER JOIN <code>".WPSC_TABLE_ITEM_CATEGORY_ASSOC."</code> ON <code>".WPSC_TABLE_PRODUCT_LIST."</code>.id = <code>".WPSC_TABLE_ITEM_CATEGORY_ASSOC."</code>.product_id AND <code>".WPSC_TABLE_ITEM_CATEGORY_ASSOC."</code>.category_id = ".$id." And <code>".WPSC_TABLE_PRODUCT_LIST."</code>.active = 1 ORDER BY RAND() LIMIT 12",ARRAY_A); if(get_option('permalink_structure') != '') { $seperator ="?"; } else { $seperator ="&"; } $output = ""; if($homepage_products != null){ foreach($homepage_products as $homepage_product) { $Pid = $homepage_product['Pid']; $product_image_id = $wpdb->get_row("SELECT id FROM <code>".WPSC_TABLE_PRODUCT_IMAGES."</code> WHERE product_id = ".$homepage_product['Pid']." order by id desc LIMIT 1 " ,ARRAY_A); $image_id = $product_image_id['id']; $output .= "<li class='homepage_product'>"; $output .= "<form id='product_".$homepage_product['Pid']."' name='product_".$homepage_product['Pid']."' method='post' action='".get_option('product_list_url').$seperator."category=".$_GET['category']."' enctype='multipart/form-data'' class=''product_form' onsubmit='submitform(this);return false;'>"; $output .= "<input type='hidden' name='wpsc_ajax_action' value='add_to_cart'/> "; $output .= "<input type='hidden' name='product_id' value='".$homepage_product['Pid']."' />"; $output .= "<a href='".wpsc_product_url($homepage_product['Pid'])."' /><img class='product_image' src='index.php?image_id=".$image_id."&width=118&height=118' title='".$homepage_product['Pname']."' alt='".$homepage_product['Pname']."' /></a><br />\n\r"; $output .= "<div class='product_info'><a href='".wpsc_product_url($homepage_product['Pid'])."' />".$homepage_product['Pname']."</a><br />"; $output .= nzshpcrt_currency_display(($homepage_product['Pprice'] - $homepage_product['Pspecial_price']), $homepage_product['Pnotax'],false,$homepage_product['Pid']); $output .= "</div><input type='submit' id='product_".$homepage_product['Pid']."_submit_button' class='wpsc_buy_button' name='Buy' value='".TXT_WPSC_ADDTOCART."' />"; $output .= "</li></form>"; } } echo $output; }
theme link :https://wpfeed.com/2009/07/wpstore-free-wordpress-e-commerce-theme/
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Need help for function’ is closed to new replies.