}
        ?>
							<?php 
    }
    ?>
							<?php 
    do_action('wpsc_product_form_fields_end');
    ?>
						</form><!--close product_form-->

						<?php 
    if (get_option('hide_addtocart_button') == 0 && get_option('addtocart_or_buynow') == '1') {
        echo wpsc_buy_now_button(wpsc_the_product_id());
    }
    echo wpsc_product_rater();
    echo wpsc_also_bought(wpsc_the_product_id());
    if (wpsc_show_fb_like()) {
        ?>
	                        <div class="FB_like">
	                        <iframe src="https://www.facebook.com/plugins/like.php?href=<?php 
        echo wpsc_the_product_permalink();
        ?>
&amp;layout=standard&amp;show_faces=true&amp;width=435&amp;action=like&amp;font=arial&amp;colorscheme=light" frameborder="0"></iframe>
	                        </div><!--close FB_like-->
                        <?php 
    }
    ?>

                        <div class="mobile">
			              <div class="share_product">
			              	<h4>Share this product</h4>
Exemplo n.º 2
0
function single_product_display($product_id)
{
    global $wpdb;
    $siteurl = get_option('siteurl');
    if (get_option('permalink_structure') != '') {
        $seperator = "?";
    } else {
        $seperator = "&amp;";
    }
    // what is our product?
    if (is_numeric($product_id)) {
        $product_list = $wpdb->get_results("SELECT * FROM `" . $wpdb->prefix . "product_list` WHERE `id`='" . (int) $product_id . "' LIMIT 1", ARRAY_A);
    }
    // if we have a product
    if ($product_list != null) {
        // show the breadcrumbs
        if (get_option("show_breadcrumbs") == '1') {
            $output .= "<div class='breadcrumb'>\n\r";
            $output .= "  <a href='" . get_option('siteurl') . "'>" . get_option('blogname') . "</a> &raquo; ";
            $category = $wpdb->get_var("SELECT category_id FROM {$wpdb->prefix}item_category_associations WHERE product_id='" . $product_id . "' ORDER BY id ASC LIMIT 1");
            $category_info = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}product_categories WHERE id='" . $category . "'", ARRAY_A);
            $category_name = $wpdb->get_var("SELECT name FROM {$wpdb->prefix}product_categories WHERE id='" . $category . "'");
            while ($category_info[0]['category_parent'] != 0) {
                $category_info = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}product_categories WHERE id='" . $category_info[0]['category_parent'] . "'", ARRAY_A);
                $output .= "<a href='" . wpsc_category_url($category_info[0]['id']) . "'>" . $category_info[0]['name'] . "</a> &raquo; ";
            }
            $output .= "<a href='" . wpsc_category_url($category) . "'>" . $category_name . "</a> &raquo; ";
            $output .= $product_list[0]['name'] . "\n\r";
            $output .= "</div>\n\r";
        }
        $output .= "  <div class='productdisplay'>\n\r";
        foreach ((array) $product_list as $product) {
            $num++;
            $output .= "    <div class='single_product_display product_view_{$product['id']} '>\n\r";
            $output .= "      <div class='textcol'>\n\r";
            // display the image
            $output .= "        <div class='imagecol'>\n\r";
            if (get_option('show_thumbnails') == 1) {
                if ($product['image'] != null) {
                    if ($product['thumbnail_image'] != null) {
                        $image_file_name = $product['thumbnail_image'];
                    } else {
                        $image_file_name = $product['image'];
                    }
                    $output .= "<a href='" . WPSC_IMAGE_URL . $product['image'] . "' class='thickbox preview_link'  rel='" . str_replace(" ", "_", $product['name']) . "'>\n\r";
                    $src = WPSC_IMAGE_URL . $product['image'];
                    if (get_option('single_view_image_width') >= 1 && get_option('single_view_image_height') >= 1) {
                        $output .= "<img src='index.php?productid=" . $product['id'] . "&amp;width=" . get_option('single_view_image_width') . "&amp;height=" . get_option('single_view_image_height') . "' title='" . $product['name'] . "' alt='" . $product['name'] . "' id='product_image_" . $product['id'] . "' class='product_image'/>\n\r";
                    } else {
                        $output .= "<img src='" . WPSC_THUMBNAIL_URL . $image_file_name . "' title='" . $product['name'] . "' alt='" . $product['name'] . "' id='product_image_" . $product['id'] . "' class='product_image'/>\n\r";
                    }
                    $output .= "</a>\n\r";
                    if (function_exists("gold_shpcrt_display_extra_images")) {
                        $output .= gold_shpcrt_display_extra_images($product['id'], $product['name']);
                    }
                } else {
                    if (get_option('product_image_width') != '') {
                        $output .= "<img src='" . WPSC_URL . "/no-image-uploaded.gif' title='" . $product['name'] . "' alt='" . $product['name'] . "' width='" . get_option('product_image_width') . "' height='" . get_option('product_image_height') . "' />\n\r";
                    } else {
                        $output .= "<img src='" . WPSC_URL . "/no-image-uploaded.gif' title='" . $product['name'] . "' alt='" . $product['name'] . "' />\n\r";
                    }
                }
            }
            $output .= "        </div>\n\r";
            // if the product is special, say so
            if ($product['special'] == 1) {
                $special = "        <span class='special'>" . TXT_WPSC_SPECIAL . " - </span>\n\r";
            }
            $output .= "        <form id='product_" . $product['id'] . "' name='{$num}' method='post' action='" . get_option('product_list_url') . $seperator . "category=" . $_GET['category'] . "' onsubmit='submitform(this);return false;' >\n\r";
            $output .= "<input type='hidden' name='prodid' value='" . $product['id'] . "' />\n\r";
            $output .= "        <div class='producttext'>\n\r";
            $output .= "           <h2 class='prodtitles'>{$special}" . stripslashes($product['name']) . "</h2>\n\r";
            if (get_option('wpsc_selected_theme') == 'market3') {
                $soldout = 0;
                if ($product['quantity_limited'] && $product['quantity'] < 1) {
                    $soldout = 1;
                }
                if ($soldout) {
                    $output .= "           <span class='soldout'>Sold out</span>\n\r";
                } else {
                    $output .= "           <span class='price'>" . nzshpcrt_currency_display($product['price'], $product['notax']) . "</span>\n\r";
                }
            }
            ob_start();
            do_action('wpsc_product_addons', $product['id']);
            $output .= ob_get_contents();
            ob_end_clean();
            if (is_numeric($product['file']) && $product['file'] > 0) {
                $file_data = $wpdb->get_row("SELECT * FROM `" . $wpdb->prefix . "product_files` WHERE `id`='" . $product['file'] . "' LIMIT 1", ARRAY_A);
                if ($file_data != null && function_exists('listen_button')) {
                    $output .= listen_button($file_data['idhash'], $file_data['id']);
                }
            }
            if ($product['description'] != '') {
                $output .= "           <p  class='description'>" . nl2br(stripslashes($product['description'])) . "</p>\n\r";
            }
            if (get_option('wpsc_selected_theme') == 'market3') {
                $output .= "           <br />";
            }
            if ($product['additional_description'] != '') {
                $output .= "           <p class='single_additional_description' >\n\r";
                if (get_option('wpsc_selected_theme') == 'market3') {
                    $output .= "           <span class='additional'>Additional Details: </span>\n\r";
                }
                $output .= nl2br(stripslashes($product['additional_description'])) . "";
                $output .= "           </p>\n\r";
            }
            // print the custom fields here, if there are any
            $custom_fields = $wpdb->get_results("SELECT * FROM `{$wpdb->prefix}wpsc_productmeta` WHERE `product_id` IN('{$product['id']}') AND `custom` IN('1') ", ARRAY_A);
            if (count($custom_fields) > 0) {
                $output .= "           <div class='custom_meta'>\n\r";
                foreach ((array) $custom_fields as $custom_field) {
                    $output .= "             <strong>{$custom_field['meta_key']}:</strong> {$custom_field['meta_value']} <br />\n\r";
                }
                $output .= "           </div>\n\r";
            }
            ob_start();
            do_action('wpsc_product_addon_after_descr', $product['id']);
            $output .= ob_get_contents();
            ob_end_clean();
            if (function_exists('wpsc_akst_share_link') && get_option('wpsc_share_this') == 1) {
                $output .= wpsc_akst_share_link('return');
            }
            $variations_procesor = new nzshpcrt_variations();
            $variations_output = $variations_procesor->display_product_variations($product['id'], false, false, true);
            if ($variations_output[0] != '') {
                //will always be set, may sometimes be an empty string
                $output .= "           <p class='wpsc_variation_forms'>" . $variations_output[0] . "</p>";
            }
            if ($variations_output[1] !== null) {
                $product['price'] = $variations_output[1];
            }
            if (get_option('wpsc_selected_theme') != 'market3') {
                $output .= "           <p class='wpsc_product_price'>";
                if ($product['donation'] == 1) {
                    $currency_sign_location = get_option('currency_sign_location');
                    $currency_type = get_option('currency_type');
                    $currency_symbol = $wpdb->get_var("SELECT `symbol_html` FROM `" . $wpdb->prefix . "currency_list` WHERE `id`='" . $currency_type . "' LIMIT 1");
                    $output .= "           <label for='donation_price_" . $product['id'] . "'>" . TXT_WPSC_DONATION . ":</label> {$currency_symbol}<input type='text' id='donation_price_" . $product['id'] . "' name='donation_price' value='" . number_format($product['price'], 2) . "' size='6' /><br />";
                } else {
                    if (get_option('wpsc_selected_theme') != 'market3') {
                        if ($product['special'] == 1 && $variations_output[1] === null) {
                            $output .= "<span class='oldprice'>" . TXT_WPSC_PRICE . ": " . nzshpcrt_currency_display($product['price'], $product['notax']) . "</span><br />";
                            $output .= TXT_WPSC_PRICE . ": " . nzshpcrt_currency_display($product['price'] - $product['special_price'], $product['notax'], false, $product['id']) . "<br />";
                        } else {
                            $output .= TXT_WPSC_PRICE . ": <span id='product_price_" . $product['id'] . "'>" . nzshpcrt_currency_display($product['price'], $product['notax']) . "</span><br />";
                        }
                        // if(get_option('display_pnp') == 1) {
                        // 	$output .= TXT_WPSC_PNP.": " . nzshpcrt_currency_display($product['pnp'], 1) . "<br />";
                        // }
                    }
                }
                $output .= "</p>\n\r";
            }
            if (function_exists('wpsc_theme_html')) {
                $wpsc_theme = wpsc_theme_html($product);
            }
            $output .= "<input type='hidden' name='item' value='" . $product['id'] . "' />";
            //AND (`quantity_limited` = '1' AND `quantity` > '0' OR `quantity_limited` = '0' )
            if ($product['quantity_limited'] == 1 && $product['quantity'] < 1 && $variations_output[1] === null) {
                if (get_option("wpsc_selected_theme") != 'market3') {
                    $output .= "<p class='soldout'>" . TXT_WPSC_PRODUCTSOLDOUT . "</p>";
                }
            } else {
                if (get_option('hide_addtocart_button') != 1 && get_option('addtocart_or_buynow') == 0) {
                    if (isset($wpsc_theme) && is_array($wpsc_theme) && $wpsc_theme['html'] != '') {
                        $output .= $wpsc_theme['html'];
                    } else {
                        $output .= "<input type='submit' id='product_" . $product['id'] . "_submit_button' class='wpsc_buy_button' name='Buy' value='" . TXT_WPSC_ADDTOCART . "'  />";
                    }
                }
            }
            if (function_exists('gold_shpcrt_display_gallery')) {
                $output .= gold_shpcrt_display_gallery($product['id']);
            }
            if (get_option('product_ratings') == 1) {
                $output .= "<div class='product_footer'>";
                $output .= "<div class='product_average_vote'>";
                $output .= "<strong>" . TXT_WPSC_AVGCUSTREVIEW . ":</strong>";
                $output .= nzshpcrt_product_rating($product['id']);
                $output .= "</div>";
                $output .= "<div class='product_user_vote'>";
                $vote_output = nzshpcrt_product_vote($product['id'], "onmouseover='hide_save_indicator(\"saved_" . $product['id'] . "_text\");'");
                if ($vote_output[1] == 'voted') {
                    $output .= "<strong><span id='rating_" . $product['id'] . "_text'>" . TXT_WPSC_YOURRATING . ":</span>";
                    $output .= "<span class='rating_saved' id='saved_" . $product['id'] . "_text'> " . TXT_WPSC_RATING_SAVED . "</span>";
                    $output .= "</strong>";
                } else {
                    if ($vote_output[1] == 'voting') {
                        $output .= "<strong><span id='rating_" . $product['id'] . "_text'>" . TXT_WPSC_RATETHISITEM . ":</span>";
                        $output .= "<span class='rating_saved' id='saved_" . $product['id'] . "_text'> " . TXT_WPSC_RATING_SAVED . "</span>";
                        $output .= "</strong>";
                    }
                }
                $output .= $vote_output[0];
                $output .= "</div>";
                $output .= "</div>";
            }
            $output .= "          </div>\n\r";
            $output .= "        </form>\n\r";
            if (count($updatelink_data) > 0 && $updatelink_data[0]['meta_value'] != '') {
                $output .= external_link($product['id']);
            } else {
                if (get_option('addtocart_or_buynow') == '1') {
                    if (get_option('payment_gateway') == 'google') {
                        $output .= google_buynow($product['id']);
                    } else {
                        if (get_option('payment_gateway') == 'paypal_multiple') {
                            $output .= "<form onsubmit='log_paypal_buynow(this)' target='paypal' action='" . get_option('paypal_multiple_url') . "' method='post'>\n\t\t\t\t\t\t\t<input type='hidden' name='business' value='" . get_option('paypal_multiple_business') . "'>\n\t\t\t\t\t\t\t<input type='hidden' name='cmd' value='_xclick'>\n\t\t\t\t\t\t\t<input type='hidden' name='item_name' value='" . $product['name'] . "'>\n\t\t\t\t\t\t\t<input type='hidden' id='item_number' name='item_number' value='" . $product['id'] . "'>\n\t\t\t\t\t\t\t<input type='hidden' id='amount' name='amount' value='" . $product['price'] . "'>\n\t\t\t\t\t\t\t<input type='hidden' id='unit' name='unit' value='" . $product['price'] . "'>\n\t\t\t\t\t\t\t<input type='hidden' id='shipping' name='ship11' value='" . $shipping . "'>\n\t\t\t\t\t\t\t<input type='hidden' name='handling' value='" . get_option('base_local_shipping') . "'>\n\t\t\t\t\t\t\t<input type='hidden' name='currency_code' value='" . get_option('paypal_curcode') . "'>\n\t\t\t\t\t\t\t<input type='hidden' name='undefined_quantity' value='0'>\n\t\t\t\t\t\t\t<input type='image' name='submit' border='0' src='https://www.paypal.com/en_US/i/btn/btn_buynow_LG.gif' alt='PayPal - The safer, easier way to pay online'>\n\t\t\t\t\t\t\t<img alt='' border='0' width='1' height='1' src='https://www.paypal.com/en_US/i/scr/pixel.gif' >\n\t\t\t\t\t\t</form>\n\t\t\t\t\t";
                        }
                    }
                }
            }
            $output .= "        <form id='product_extra_" . $product['id'] . "' name='product_" . $product['id'] . "' method='post' action='" . get_option('product_list_url') . $seperator . "category=" . $_GET['category'] . "' onsubmit='submitform(this);return false;' >\n\r";
            $output .= "          <input type='hidden' name='prodid' value='" . $product['id'] . "' />\n\r";
            $output .= "          <input type='hidden' name='item' value='" . $product['id'] . "' />\n\r";
            $output .= "        </form>\n\r";
            $output .= "      </div>\n\r";
            $output .= "    </div>\n\r";
            $output .= " <div class='clear'></div>\n\r";
        }
        $output .= wpsc_also_bought($product_id);
        $output .= "  </div>";
    } else {
        // otherwise, we have no product
        $output .= "<p>" . TXT_WPSC_NOITEMSINTHIS . " " . $group_type . ".</p>";
    }
    // replace dollar signs with the HTML code so that PHP doesn't try to interpret them as variables.
    $output = str_replace('$', '&#036;', $output);
    return $output;
}