예제 #1
0
 function product_display_list($product_list, $group_type, $group_sql = '', $search_sql = '')
 {
     global $wpdb;
     $siteurl = get_option('siteurl');
     if ((double) WPSC_VERSION < 3.8) {
         $images_dir = 'images';
     } else {
         $images_dir = 'wpsc-core/images';
     }
     if (get_option('permalink_structure') != '') {
         $seperator = "?";
     } else {
         $seperator = "&amp;";
     }
     $product_listing_data = wpsc_get_product_listing($product_list, $group_type, $group_sql, $search_sql);
     $product_list = $product_listing_data['product_list'];
     $output .= $product_listing_data['page_listing'];
     if ($product_listing_data['category_id']) {
         $category_nice_name = $wpdb->get_var("SELECT `nice-name` FROM `" . WPSC_TABLE_PRODUCT_CATEGORIES . "` WHERE `id` ='" . (int) $product_listing_data['category_id'] . "' LIMIT 1");
     } else {
         $category_nice_name = '';
     }
     if ($product_list != null) {
         $output .= "<table class='list_productdisplay {$category_nice_name}'>";
         $i = 0;
         foreach ($product_list as $product) {
             $num++;
             if ($i % 2 == 1) {
                 $output .= "    <tr class='product_view_{$product['id']}'>";
             } else {
                 $output .= "    <tr class='product_view_{$product['id']}' style='background-color:#EEEEEE'>";
             }
             $i++;
             $output .= "      <td style='width: 9px;'>";
             if ($product['description'] != null) {
                 $output .= "<a href='#' class='additional_description_link' onclick='return show_additional_description(\"list_description_" . $product['id'] . "\",\"link_icon" . $product['id'] . "\");'>";
                 $output .= "<img style='margin-top:3px;' id='link_icon" . $product['id'] . "' src='{$siteurl}/wp-content/plugins/" . WPSC_DIR_NAME . "/" . $images_dir . "/icon_window_expand.gif' title='" . $product['name'] . "' alt='" . $product['name'] . "' />";
                 $output .= "</a>";
             }
             $output .= "      </td>\n\r";
             $output .= "      <td width='55%'>";
             if ($product['special'] == 1) {
                 $special = "<strong class='special'>" . TXT_WPSC_SPECIAL . " - </strong>";
             } else {
                 $special = "";
             }
             $output .= "<a href='" . wpsc_product_url($product['id']) . "' class='wpsc_product_title' ><strong>" . stripslashes($product['name']) . "</strong></a>";
             $output .= "      </td>";
             $variations_procesor = new nzshpcrt_variations();
             $variations_output = $variations_procesor->display_product_variations($product['id'], false, false, true);
             if ($variations_output[1] !== null) {
                 $product['price'] = $variations_output[1];
             }
             $output .= "      <td width='10px' style='text-align: center;'>";
             if ($product['quantity'] < 1 && $product['quantity_limited'] == 1) {
                 $output .= "<img style='margin-top:5px;' src='{$siteurl}/wp-content/plugins/" . WPSC_DIR_NAME . "/" . $images_dir . "/no_stock.gif' title='No' alt='No' />";
             } else {
                 $output .= "<img style='margin-top:4px;' src='{$siteurl}/wp-content/plugins/" . WPSC_DIR_NAME . "/" . $images_dir . "/yes_stock.gif' title='Yes' alt='Yes' />";
             }
             $output .= "      </td>";
             $output .= "      <td width='10%'>";
             if ($product['special'] == 1 && $variations_output[1] === null) {
                 $output .= nzshpcrt_currency_display($product['price'] - $product['special_price'], $product['notax'], false, $product['id']) . "<br />";
             } else {
                 $output .= "<span id='product_price_" . $product['id'] . "'>" . nzshpcrt_currency_display($product['price'], $product['notax']) . "</span>";
             }
             $output .= "      </td>";
             $output .= "      <td width='20%'>";
             if (get_option('addtocart_or_buynow') == '0') {
                 $output .= "<form name='{$num}'  id='product_" . $product['id'] . "'  method='POST' action='" . get_option('product_list_url') . $seperator . "category=" . $_GET['category'] . "' onsubmit='submitform(this);return false;' >";
             }
             if (get_option('list_view_quantity') == 1) {
                 $output .= "<input type='text' name='quantity' value='1' size='3' maxlength='3'>&nbsp;";
             }
             $output .= $variations_output[0];
             $output .= "<input type='hidden' name='item' value='" . $product['id'] . "' />";
             $output .= "<input type='hidden' name='prodid' value='" . $product['id'] . "'>";
             if (get_option('wpsc_selected_theme') == 'iShop') {
                 if (get_option('addtocart_or_buynow') == '0') {
                     if ($product['quantity_limited'] == 1 && $product['quantity'] < 1) {
                         $output .= "<input disabled='true' type='submit' value='' name='Buy' class='wpsc_buy_button'/>";
                     } else {
                         $output .= "<input type='submit' name='Buy' value='' class='wpsc_buy_button'/>";
                     }
                 } else {
                     if (!($product['quantity_limited'] == 1 && $product['quantity'] < 1)) {
                         $output .= google_buynow($product['id']);
                     }
                 }
             } else {
                 if (get_option('addtocart_or_buynow') == '0') {
                     if ($product['quantity_limited'] == 1 && $product['quantity'] < 1) {
                         $output .= "<input disabled='true' type='submit' name='Buy' class='wpsc_buy_button'  value='" . TXT_WPSC_ADDTOCART . "'  />";
                     } else {
                         $output .= "<input type='submit' name='Buy' class='wpsc_buy_button'  value='" . TXT_WPSC_ADDTOCART . "'  />";
                     }
                 } else {
                     if (!($product['quantity_limited'] == 1 && $product['quantity'] < 1)) {
                         $output .= google_buynow($product['id']);
                     }
                 }
             }
             $output .= "</form>";
             $output .= "      </td>\n\r";
             $output .= "    </tr>\n\r";
             $output .= "    <tr class='list_view_description'>\n\r";
             $output .= "      <td colspan='5'>\n\r";
             $output .= "        <div id='list_description_" . $product['id'] . "'>\n\r";
             $output .= $product['description'];
             $output .= "        </div>\n\r";
             $output .= "      </td>\n\r";
             $output .= "    </tr>\n\r";
         }
         $output .= "</table>";
     } else {
         $output .= "<p>" . TXT_WPSC_NOITEMSINTHIS . " " . $group_type . ".</p>";
     }
     return $output;
 }
예제 #2
0
function product_display_default($product_list, $group_type, $group_sql = '', $search_sql = '')
{
    global $wpdb, $wp_rewrite;
    if (WPSC_DEBUG === true) {
        wpsc_debug_start_subtimer('product_display_default', 'start');
    }
    $siteurl = get_option('siteurl');
    if ($wp_rewrite->permalink_structure != '') {
        $seperator = "?";
    } else {
        $seperator = "&amp;";
    }
    $product_listing_data = wpsc_get_product_listing($product_list, $group_type, $group_sql, $search_sql);
    if ($product_list == '') {
        $product_list = $product_listing_data['product_list'];
    }
    if (get_option('wpsc_page_number_position') == 1 || get_option('wpsc_page_number_position') == 3) {
        $output .= $product_listing_data['page_listing'];
    }
    if ($product_listing_data['category_id']) {
        $category_nice_name = $wpdb->get_var("SELECT `nice-name` FROM `" . $wpdb->prefix . "product_categories` WHERE `id` ='" . (int) $product_listing_data['category_id'] . "' LIMIT 1");
    } else {
        $category_nice_name = '';
    }
    if ($product_list != null) {
        // breadcrumbs start here
        if (get_option("show_breadcrumbs") == '1' && is_numeric($product_listing_data['category_id'])) {
            $output .= "<div class='breadcrumb'>";
            $output .= "<a href='" . get_option('siteurl') . "'>" . get_option('blogname') . "</a> &raquo; ";
            $category = $product_listing_data['category_id'];
            $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 .= "" . $category_name . "";
            // 			$output .= $product_list[0]['name'];
            $output .= "</div>";
        }
        // breadcrumbs end here
        foreach ($product_list as $product) {
            if (WPSC_DEBUG === true) {
                wpsc_debug_start_subtimer('product_start_loop', 'start', true);
            }
            $num++;
            if (function_exists('wpsc_theme_html')) {
                $wpsc_theme = wpsc_theme_html($product);
            }
            $output .= "<div class='productdisplay default_product_display product_view_{$product['id']} {$category_nice_name}'>";
            $output .= "      <div class='textcol'>";
            if ($category_data[0]['fee'] == 0) {
                $output .= "      <div class='imagecol'>";
                if (get_option('show_thumbnails') == 1) {
                    if ($product['image'] != null) {
                        $image_size = @getimagesize(WPSC_IMAGE_DIR . $product['image']);
                        $output .= "<a href='" . WPSC_IMAGE_URL . $product['image'] . "' class='thickbox preview_link'  rel='" . str_replace(" ", "_", $product['name']) . "'>";
                        if ($product['thumbnail_image'] != null) {
                            $image_file_name = $product['thumbnail_image'];
                        } else {
                            $image_file_name = $product['image'];
                        }
                        $output .= "<img src='" . WPSC_THUMBNAIL_URL . $image_file_name . "' title='" . htmlentities($product['name'], ENT_QUOTES) . "' alt='" . htmlentities($product['name'], ENT_QUOTES) . "' id='product_image_" . $product['id'] . "' class='product_image'/>";
                        $output .= "</a>";
                        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') . "' id='product_image_" . $product['id'] . "' class='product_image' />";
                        } else {
                            $output .= "<img src='" . WPSC_URL . "/no-image-uploaded.gif' title='" . $product['name'] . "' alt='" . $product['name'] . "' id='product_image_" . $product['id'] . "' class='product_image' />";
                        }
                    }
                    if (function_exists('drag_and_drop_items')) {
                        $output .= drag_and_drop_items("product_image_" . $product['id']);
                    }
                }
                $output .= "</div>";
            }
            if ($product['special'] == 1) {
                $special = "<span class='special'>" . TXT_WPSC_SPECIAL . " - </span>";
            } else {
                $special = "";
            }
            $output .= "<form id='product_" . $product['id'] . "' name='product_" . $product['id'] . "' method='post' action='" . get_option('product_list_url') . $seperator . "category=" . $_GET['category'] . "' onsubmit='submitform(this);return false;' >";
            $output .= "<input type='hidden' name='prodid' value='" . $product['id'] . "' />";
            $output .= "<div class='producttext'><h2 class='prodtitles'>";
            if (get_option('hide_name_link') != 1) {
                $output .= "<a href='" . wpsc_product_url($product['id']) . "'  class='wpsc_product_title' >{$special}" . stripslashes($product['name']) . "</a>";
            } else {
                $output .= "<a class='wpsc_product_title' >{$special}<strong>" . stripslashes($product['name']) . "</strong></a>";
            }
            $output .= "</h2>";
            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='wpsc_description'>" . nl2br(stripslashes($product['description'])) . "</p>";
            }
            if ($product['additional_description'] != '') {
                $output .= "<a href='#' class='additional_description_link' onclick='return show_additional_description(\"additionaldescription" . $product['id'] . "\",\"link_icon" . $product['id'] . "\");'>";
                $output .= "<img id='link_icon" . $product['id'] . "' class='additional_description_button'  src='" . WPSC_URL . "/images/icon_window_expand.gif' title='" . $product['name'] . "' alt='" . $product['name'] . "' />";
                $output .= TXT_WPSC_MOREDETAILS . "</a>";
                $output .= "<span class='additional_description' id='additionaldescription" . $product['id'] . "'><br />";
                $output .= nl2br(stripslashes($product['additional_description'])) . "";
                $output .= "</span><br />";
            }
            // 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'>";
                foreach ((array) $custom_fields as $custom_field) {
                    $output .= "<strong>{$custom_field['meta_key']}:</strong> {$custom_field['meta_value']} <br />";
                }
                $output .= "</div>";
            }
            ob_start();
            do_action('wpsc_product_addon_after_descr', $product['id']);
            $output .= ob_get_contents();
            ob_end_clean();
            $variations_procesor = new nzshpcrt_variations();
            if (WPSC_DEBUG === true) {
                wpsc_debug_start_subtimer('display_product_variations', 'start', true);
            }
            $variations_output = $variations_procesor->display_product_variations($product['id'], false, false, true);
            if (WPSC_DEBUG === true) {
                wpsc_debug_start_subtimer('display_product_variations', 'stop', 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];
            }
            $extras_processor = new extras();
            $extras_output = $extras_processor->display_product_extras($product['id'], false, false, true);
            $output .= "<p class='wpsc_extras_forms'>" . $extras_output . "</p>";
            $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 ($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>";
            $output .= "<input type='hidden' name='item' value='" . $product['id'] . "' />";
            $updatelink_sql = "SELECT * FROM " . $wpdb->prefix . "wpsc_productmeta WHERE product_id =" . $product['id'] . " AND meta_key='external_link'";
            $updatelink_data = $wpdb->get_results($updatelink_sql, ARRAY_A);
            $updatelink = get_product_meta($product['id'], 'external_link', true);
            if (function_exists('wpsc_theme_html')) {
                $wpsc_theme = wpsc_theme_html($product);
            }
            if ($product['quantity_limited'] == 1 && $product['quantity'] < 1 && $variations_output[1] === null) {
                $output .= "<p class='soldout'>" . TXT_WPSC_PRODUCTSOLDOUT . "</p>";
            } else {
                if (get_option('hide_addtocart_button') != 1 && get_option('payment_gateway') != 'google') {
                    if (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 (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>";
            $output .= "</form>";
            //exit("<pre>".print_r($updatelink_data,1)."</pre>");
            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 .= "      </div>\n\r";
            $output .= " <div class='clear'></div>\n\r";
            $output .= "</div>";
            if (WPSC_DEBUG === true) {
                wpsc_debug_start_subtimer('product_start_loop', 'stop', true);
            }
        }
    } else {
        if ($_GET['product_search'] != null) {
            $output .= "<br /><strong class='cattitles'>" . TXT_WPSC_YOUR_SEARCH_FOR . " \"" . $_GET['product_search'] . "\" " . TXT_WPSC_RETURNED_NO_RESULTS . "</strong>";
        } else {
            $output .= "<p>" . TXT_WPSC_NOITEMSINTHIS . " " . $group_type . ".</p>";
            if (get_option('wpsc_default_category') == $product_listing_data['category_id']) {
                $output .= wpsc_odd_category_setup();
            }
        }
    }
    if (get_option('wpsc_page_number_position') == 2 || get_option('wpsc_page_number_position') == 3) {
        $output .= $product_listing_data['page_listing'];
    }
    $output = str_replace('$', '&#036;', $output);
    if (WPSC_DEBUG === true) {
        wpsc_debug_start_subtimer('product_display_default', 'stop');
    }
    return $output;
}