WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Need help for function (3 posts)

  1. xinfo
    Member
    Posted 4 years ago #

    i am using wpstore theme

    in homepage it shows
    image
    title
    price
    add to cart

    i 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>&quot;.WPSC_TABLE_PRODUCT_CATEGORIES.&quot;</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>&quot;.WPSC_TABLE_PRODUCT_LIST.&quot;</code>.id AS Pid, <code>&quot;.WPSC_TABLE_PRODUCT_LIST.&quot;</code>.name AS Pname, <code>&quot;.WPSC_TABLE_PRODUCT_LIST.&quot;</code>.price AS Pprice,<code>&quot;.WPSC_TABLE_PRODUCT_LIST.&quot;</code>.special_price AS Pspecial_price,<code>&quot;.WPSC_TABLE_PRODUCT_LIST.&quot;</code>.notax AS Pnotax  FROM <code>&quot;.WPSC_TABLE_PRODUCT_LIST.&quot;</code> INNER JOIN <code>&quot;.WPSC_TABLE_ITEM_CATEGORY_ASSOC.&quot;</code> ON <code>&quot;.WPSC_TABLE_PRODUCT_LIST.&quot;</code>.id = <code>&quot;.WPSC_TABLE_ITEM_CATEGORY_ASSOC.&quot;</code>.product_id AND <code>&quot;.WPSC_TABLE_ITEM_CATEGORY_ASSOC.&quot;</code>.category_id = ".$id." And <code>&quot;.WPSC_TABLE_PRODUCT_LIST.&quot;</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>&quot;.WPSC_TABLE_PRODUCT_IMAGES.&quot;</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 :http://wpfeed.com/2009/07/wpstore-free-wordpress-e-commerce-theme/

  2. xinfo
    Member
    Posted 4 years ago #

    any one here to help me i want to show description also

  3. xinfo
    Member
    Posted 4 years ago #

    sorry for the bump

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags