get_var("SELECT COUNT(*) AS `count` FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE `donation` IN ('1') AND `active` IN ('1')"); if($donation_count > 0) { echo $before_widget; $full_title = $before_title . $title . $after_title; echo $full_title; nzshpcrt_donations(); echo $after_widget; } } function nzshpcrt_donations($input = null) { global $wpdb; $siteurl = get_option('siteurl'); $sql = "SELECT * FROM `".WPSC_TABLE_PRODUCT_LIST."` WHERE `donation` IN ('1') AND `active` IN ('1')"; $products = $wpdb->get_results($sql,ARRAY_A); // exit('
'.print_r($products,true).'
'); if($products != null) { $output = "
"; foreach($products as $product) { $sql = "SELECT * FROM `".WPSC_TABLE_PRODUCT_IMAGES."` WHERE `id`=".$product['image']; $image = $wpdb->get_row($sql, ARRAY_A); //exit('
'.print_r($image,true).'
'); $output .= "".$product['name']."
"; if($product['image'] != null) { $output .= "".$product[
"; } $output .= $product['description']."
"; $output .= "
"; $variations_processor = new nzshpcrt_variations; $output .= $variations_processor->display_product_variations($product['id']); $output .= ""; $output .= ""; $output .= ""; $currency_sign_location = get_option('currency_sign_location'); $currency_type = get_option('currency_type'); $currency_symbol = $wpdb->get_var("SELECT `symbol_html` FROM `".WPSC_TABLE_CURRENCY_LIST."` WHERE `id`='".$currency_type."' LIMIT 1") ; $output .= " $currency_symbol
"; $output .= ""; $output .= "
"; } $output .= "
"; } else { $output = ''; } echo $input.$output; } function widget_donations_control() { $option_name = 'wpsc-nzshpcrt_donations'; // because I want to only change this to reuse the code. $options = $newoptions = get_option($option_name); if ( isset($_POST[$option_name]) ) { $newoptions['title'] = strip_tags(stripslashes($_POST[$option_name])); } if ( $options != $newoptions ) { $options = $newoptions; update_option($option_name, $options); } $title = htmlspecialchars($options['title'], ENT_QUOTES); echo "

\n\r"; echo " \n\r"; echo "

\n\r"; } function widget_donations_init() { if(function_exists('register_sidebar_widget')) { register_sidebar_widget(__('Product Donations', 'wpsc'), 'widget_donations'); register_widget_control(__('Product Donations', 'wpsc'), 'widget_donations_control'); } return; } add_action('plugins_loaded', 'widget_donations_init'); ?>