function wpsc_donations($args = null) { global $wpdb; // Args not used yet but this is ready for when it is $args = wp_parse_args((array) $args, array()); $products = $wpdb->get_results("SELECT DISTINCT `p` . * , `m`.`meta_value` AS `special_price`\n\t\tFROM `" . $wpdb->postmeta . "` AS `m`\n\t\tJOIN `" . $wpdb->posts . "` AS `p` ON `m`.`post_id` = `p`.`ID`\n\t\tWHERE `p`.`post_parent` IN ('0')\n\t\t\tAND `m`.`meta_key` IN ('_wpsc_is_donation')\n\t\t\tAND `m`.`meta_value` IN( '1' )\n\t\tORDER BY RAND( )\n\t\tLIMIT 1", ARRAY_A); $output = ''; if ($products != null) { foreach ($products as $product) { $attached_images = (array) get_posts(array('post_type' => 'attachment', 'numberposts' => 1, 'post_status' => null, 'post_parent' => $product['ID'], 'orderby' => 'menu_order', 'order' => 'ASC')); $attached_image = $attached_images[0]; $output .= "<div class='wpsc_product_donation'>"; if ($attached_image->ID > 0) { $output .= "<img src='" . wpsc_product_image($attached_image->ID, get_option('product_image_width'), get_option('product_image_height')) . "' title='" . $product['post_title'] . "' alt='" . esc_attr($product['post_title']) . "' /><br />"; } // Get currency options $currency_sign_location = get_option('currency_sign_location'); $currency_type = get_option('currency_type'); WPSC_Countries::get_currency_symbol($currency_type); $price = get_post_meta($product['ID'], '_wpsc_price', true); // Output $output .= "<strong>" . $product['post_title'] . "</strong><br />"; $output .= $product['post_content'] . "<br />"; $output .= "<form class='product_form' name='donation_widget_" . $product['ID'] . "' method='post' action='' id='donation_widget_" . $product['ID'] . "'>"; $output .= "<input type='hidden' name='product_id' value='" . $product['ID'] . "'/>"; $output .= "<input type='hidden' name='item' value='" . $product['ID'] . "' />"; $output .= "<input type='hidden' name='wpsc_ajax_action' value='add_to_cart' />"; $output .= "<label for='donation_widget_price_" . $product['ID'] . "'>" . __('Donation', 'wp-e-commerce') . ":</label> {$currency_symbol}<input type='text' id='donation_widget_price_" . $product['ID'] . "' name='donation_price' value='" . esc_attr(number_format($price, 2)) . "' size='6' /><br />"; $output .= "<input type='submit' id='donation_widget_" . $product['ID'] . "_submit_button' name='Buy' class='wpsc_buy_button' value='" . __('Add To Cart', 'wp-e-commerce') . "' />"; $output .= "</form>"; $output .= "</div>"; } } else { $output = ''; } echo $output; }
/** * wpsc_get_currency_symbol * @param does not receive anything * @return returns the currency symbol used for the shop */ function wpsc_get_currency_symbol() { $currency_type = get_option('currency_type'); $wpsc_currency_data = WPSC_Countries::get_currency_symbol($currency_type); return $wpsc_currency_data; }