Ejemplo n.º 1
1
function nzshpcrt_specials($input = null)
{
    global $wpdb;
    $image_width = get_option('product_image_width');
    $image_height = get_option('product_image_height');
    $siteurl = get_option('siteurl');
    $sql = "SELECT * FROM `" . WPSC_TABLE_PRODUCT_LIST . "` WHERE `special_price` != '0.00'  AND `active` IN ('1') ORDER BY RAND() LIMIT 1";
    $product = $wpdb->get_results($sql, ARRAY_A);
    if ($product != null) {
        $output = "<div>";
        foreach ($product as $special) {
            $special['name'] = htmlentities(stripslashes($special['name']), ENT_QUOTES, "UTF-8");
            $output .= "<strong><a class='wpsc_product_title' href='" . wpsc_product_url($special['id'], $special['category']) . "'>" . $special['name'] . "</a></strong><br /> ";
            if (is_numeric($special['image'])) {
                $image_file_name = $wpdb->get_var("SELECT `image` FROM `" . WPSC_TABLE_PRODUCT_IMAGES . "` WHERE `id`= '" . $special['image'] . "' LIMIT 1");
                if ($image_file_name != '') {
                    $image_path = "index.php?productid=" . $special['id'] . "&amp;width=" . $image_width . "&amp;height=" . $image_height . "";
                    $output .= "<img src='" . $image_path . "' title='" . $special['name'] . "' alt='" . $special['name'] . "' /><br />";
                }
            }
            //exit('Widget specisl'.get_option('wpsc_special_description'));
            if (get_option('wpsc_special_description') != '1') {
                $output .= $special['description'] . "<br />";
            }
            $variations_processor = new nzshpcrt_variations();
            $variations_output = $variations_processor->display_product_variations($special['id'], true, false, true);
            $output .= $variations_output[0];
            if ($variations_output[1] !== null) {
                $special['price'] = $variations_output[1];
                $special['special_price'] = 0;
            }
            if ($variations_output[1] == null) {
                $output .= "<span class='oldprice'>" . nzshpcrt_currency_display($special['price'], $special['notax'], false) . "</span><br />";
            }
            $output .= "<span id='special_product_price_" . $special['id'] . "'><span class='pricedisplay'>";
            $output .= nzshpcrt_currency_display($special['price'] - $special['special_price'], $special['notax'], false, $product['id']);
            $output .= "</span></span><br />";
            $output .= "<form id='specials_" . $special['id'] . "' method='post' action='' onsubmit='submitform(this, null);return false;' >";
            $output .= "<input type='hidden' name='product_id' value='" . $special['id'] . "'/>";
            $output .= "<input type='hidden' name='item' value='" . $special['id'] . "' />";
            $output .= "<input type='hidden' name='wpsc_ajax_action' value='special_widget' />";
            if ($special['quantity_limited'] == 1 && $special['quantity'] < 1) {
                $output .= TXT_WPSC_PRODUCTSOLDOUT . "";
            } else {
                //$output .= $variations_processor->display_product_variations($special['id'],true);
                $output .= "<input type='submit' name='" . TXT_WPSC_ADDTOCART . "' value='" . TXT_WPSC_ADDTOCART . "'  />";
            }
            $output .= "</form>";
        }
        $output .= "</div>";
    } else {
        $output = '';
    }
    echo $input . $output;
}
Ejemplo n.º 2
0
function nzshpcrt_latest_product($input = null)
{
    global $wpdb;
    $siteurl = get_option('siteurl');
    $latest_product = $wpdb->get_results("SELECT * FROM `" . WPSC_TABLE_PRODUCT_LIST . "` WHERE `active` IN ('1') ORDER BY `id` DESC LIMIT 5", ARRAY_A);
    if ($latest_product != null) {
        $output = "<div>";
        foreach ($latest_product as $special) {
            $output .= "<div>";
            $output .= "\t<div class='item_image'>";
            $output .= "\t\t\t<a href='" . wpsc_product_url($special['id'], $special['category']) . "'>";
            if ($special['image'] > 0) {
                if (get_option('wpsc_selected_theme') == 'marketplace') {
                    $src = WPSC_IMAGE_URL . $special['image'];
                    $output .= "\t\t\t\t<img src='" . "index.php?image_id={$special['image']}&amp;width=100&amp;height=75' title='" . $special['name'] . "' alt='" . $special['name'] . "' />";
                } else {
                    $output .= "\t\t\t\t<img src='" . "index.php?image_id={$special['image']}&amp;width=45&amp;height=25' title='" . $special['name'] . "' alt='" . $special['name'] . "' /><br />";
                }
            } else {
                //$output .= "<img src='$siteurl/wp-content/plugins/wp-shopping-cart/no-image-uploaded.gif' title='".$special['name']."' alt='".$special['name']."' /><br />";
            }
            $output .= "\t\t</a>";
            $output .= "\t</div>";
            $output .= "\t<a href='" . wpsc_product_url($special['id'], $special['category']) . "'>";
            $output .= "\t\t<strong>" . stripslashes($special['name']) . "</strong><br />";
            $output .= "\t</a>";
            $output .= "</div>";
        }
        $output .= "</div>";
    } else {
        $output = '';
    }
    echo $input . $output;
}
Ejemplo n.º 3
0
function nzshpcrt_latest_product($input = null)
{
    global $wpdb;
    $siteurl = get_option('siteurl');
    $latest_product = $wpdb->get_results("SELECT * FROM `" . $wpdb->prefix . "product_list` WHERE `active` IN ('1') ORDER BY `id` DESC LIMIT 5", ARRAY_A);
    if ($latest_product != null) {
        $output = "<div>";
        foreach ($latest_product as $special) {
            $output .= "<a href='" . wpsc_product_url($special['id'], $special['category']) . "'><div>";
            $output .= "<div class='item_image'>";
            if ($special['image'] != null && file_exists(WPSC_IMAGE_DIR . $special['image'])) {
                if (get_option('wpsc_selected_theme') == 'marketplace') {
                    $src = WPSC_IMAGE_URL . $special['image'];
                    $output .= "<img src='index.php?productid=" . $special['id'] . "&amp;width=100&amp;height=70' title='" . $special['name'] . "' alt='" . $special['name'] . "' id='product_image_" . $product['id'] . "' class='product_image'/>";
                } else {
                    $output .= "<img src='" . WPSC_THUMBNAIL_URL . $special['image'] . "' title='" . $special['name'] . "' alt='" . $special['name'] . "' /><br />";
                }
            } else {
                //$output .= "<img src='$siteurl/wp-content/plugins/wp-shopping-cart/no-image-uploaded.gif' title='".$special['name']."' alt='".$special['name']."' /><br />";
            }
            $output .= "</div>";
            $output .= "<strong>" . stripslashes($special['name']) . "</strong></a><br><br /> ";
            $output .= "</div>";
        }
        $output .= "</div>";
    } else {
        $output = '';
    }
    echo $input . $output;
}
Ejemplo n.º 4
0
 function wpsc_grid_title_and_price(&$product)
 {
     $output .= "<div class='grid_price'>";
     if ($soldout) {
         $output .= "<span class='soldoutgrid'>Sold out</span>";
     } else {
         if ($product['special'] == 1) {
             $output .= nzshpcrt_currency_display($product['price'] - $product['special_price'], $product['notax'], false, $product['id']) . "\n\r";
         } else {
             $output .= nzshpcrt_currency_display($product['price'], $product['notax']) . "\n\r";
         }
     }
     $output .= "</div>";
     $output .= "<div class='grid_prodcut_title'><a href='" . wpsc_product_url($product['id']) . "'>" . stripslashes($product['name']) . "</a></div>";
     return $output;
 }
Ejemplo n.º 5
0
function nzshpcrt_latest_product($input = null)
{
    global $wpdb;
    $siteurl = get_option('siteurl');
    $latest_product = $wpdb->get_results("SELECT * FROM `" . $wpdb->prefix . "product_list` WHERE `active` IN ('1') ORDER BY `id` DESC LIMIT 5", ARRAY_A);
    if ($latest_product != null) {
        $output = "<div><div>";
        foreach ($latest_product as $special) {
            $output .= "<a href='" . wpsc_product_url($special['id'], $special['category']) . "'><div>";
            //$output .= "<a href='".wpsc_product_url($special['id'])."'>";
            //$output .= "<a href='".wpsc_product_url($special['id'])."'>";
            if ($special['image'] != null) {
                $output .= "<img src='{$siteurl}/wp-content/plugins/wp-shopping-cart/product_images/thumbnails/" . $special['image'] . "' title='" . $special['name'] . "' alt='" . $special['name'] . "' /><br />";
            } else {
                $output .= "<img src='{$siteurl}/wp-content/plugins/wp-shopping-cart/no-image-uploaded.gif' title='" . $special['name'] . "' alt='" . $special['name'] . "' /><br />";
            }
            //$output .= "</a>";
            $output .= "<strong>" . $special['name'] . "</strong></a><br><br /> ";
            //$output .= $special['description']."<br /></div><br>";
            //       $output .= $special['price'];
            /*
                   $output .= "<span id='special_product_price_".$special['id']."'><span class='pricedisplay'>";       
                   $output .= nzshpcrt_currency_display(($special['price'] - $special['special_price']), $special['notax'],false,$product['id']);
                   $output .= "</span></span><br /><br>";*/
            //        $output .= "<form id='specials_".$special['id']."' name='$num' method='post' action='#' onsubmit='submitform(this);return false;' >";
            //        $output .= "<input type='hidden' name='prodid' value='".$special['id']."'/>";
            //        $output .= "<input type='hidden' name='item' value='".$special['id']."' />";
            //
            //        if(($special['quantity_limited'] == 1) && ($special['quantity'] < 1))
            //        {
            // 	       $output .= TXT_WPSC_PRODUCTSOLDOUT."";
            //        }
            //        else
            //        {
            //            //$output .= $variations_processor->display_product_variations($special['id'],true);
            // 	   $output .= "<input type='submit' name='".TXT_WPSC_ADDTOCART."' value='".TXT_WPSC_ADDTOCART."'  />";
            //        }
            //        $output .= "</form>";
        }
        $output .= "</div></div>";
    } else {
        $output = '';
    }
    echo $input . $output;
}
Ejemplo n.º 6
0
function wpsc_akst_send_mail()
{
    global $wpdb, $wp_query;
    //exit("<pre>".print_r($_REQUEST,true)."</pre>");
    $post_id = '';
    $to = '';
    $name = '';
    $email = '';
    if (!empty($_REQUEST['wpsc_akst_to'])) {
        $to = stripslashes($_REQUEST['wpsc_akst_to']);
        $to = strip_tags($to);
        $to = str_replace(array(',', "\n", "\t", "\r"), array(), $to);
    }
    if (!empty($_REQUEST['wpsc_akst_name'])) {
        $name = stripslashes($_REQUEST['wpsc_akst_name']);
        $name = strip_tags($name);
        $name = str_replace(array('"', "\n", "\t", "\r"), array(), $name);
    }
    if (!empty($_REQUEST['wpsc_akst_email'])) {
        $email = stripslashes($_REQUEST['wpsc_akst_email']);
        $email = strip_tags($email);
        $email = str_replace(array(',', "\n", "\t", "\r"), array(), $email);
    }
    if (!empty($_REQUEST['wpsc_akst_post_id'])) {
        $post_id = intval($_REQUEST['wpsc_akst_post_id']);
    }
    if (empty($to) || !ak_check_email_address($to) || empty($email) || !ak_check_email_address($email)) {
        wp_die(__('Click your <strong>back button</strong> and make sure those e-mail addresses are valid then try again.', 'alexking.org'));
    }
    //  $post = &get_post($post_id);
    $headers = "MIME-Version: 1.0\n" . 'From: "' . $name . '" <' . $email . '>' . "\n" . 'Reply-To: "' . $name . '" <' . $email . '>' . "\n" . 'Return-Path: "' . $name . '" <' . $email . '>' . "\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
    $subject = __('Check out this product on ', 'alexking.org') . get_bloginfo('name');
    if (is_numeric($_REQUEST['wpsc_akst_product_id'])) {
        $permalink = get_option('product_list_url');
        $message .= __('Greetings--', 'alexking.org') . "\n\n";
        $message .= $name . __(' thinks this will be of interest to you:', 'alexking.org') . "\n\n";
        //$message .= ak_decode_entities(get_the_title($post_id))."\n\n";
        if ($wp_query->query_vars['product_url_name'] != '') {
            $product_id = $wpdb->get_var("SELECT `product_id` FROM `" . WPSC_TABLE_PRODUCTMETA . "` WHERE `meta_key` IN ( 'url_name' ) AND `meta_value` IN ( '" . $wp_query->query_vars['product_url_name'] . "' ) ORDER BY `product_id` DESC LIMIT 1");
            $message .= wpsc_product_url($product_id);
        } else {
            if (strstr($permalink, "?") !== false) {
                $message .= $permalink . "&product_id=" . $_REQUEST['wpsc_akst_product_id'] . "\n\n";
            } else {
                // $message .= $permalink."?product_id=".$_REQUEST['wpsc_akst_product_id']."\n\n";
                $message .= wpsc_product_url((int) $_REQUEST['wpsc_akst_product_id']) . "\n\n";
            }
        }
        $message .= __('Enjoy.', 'alexking.org') . "\n\n";
        $message .= '--' . "\n";
        $message .= get_bloginfo('home') . "\n";
    } else {
        $message = __('Greetings--', 'alexking.org') . "\n\n" . $name . __(' thinks this will be of interest to you:', 'alexking.org') . "\n\n" . ak_decode_entities(get_the_title($post_id)) . "\n\n" . get_permalink($post_id) . "\n\n" . __('Enjoy.', 'alexking.org') . "\n\n" . '--' . "\n" . get_bloginfo('home') . "\n";
    }
    @wp_mail($to, $subject, $message, $headers);
    if (!empty($_SERVER['HTTP_REFERER'])) {
        $url = $_SERVER['HTTP_REFERER'];
    }
    header("Location: {$url}");
    status_header('302');
    die;
}
Ejemplo n.º 7
0
function wpsc_latest_product($args = null, $instance)
{
    global $wpdb;
    $args = wp_parse_args((array) $args, array('number' => 5));
    $siteurl = get_option('siteurl');
    $options = get_option('wpsc-widget_latest_products');
    $number = isset($instance['number']) ? (int) $instance['number'] : 5;
    $image = isset($instance['image']) ? (bool) $instance['image'] : FALSE;
    if (isset($instance['width'])) {
        $width = $instance['width'];
    }
    if (isset($instance['height'])) {
        $height = $instance['height'];
    }
    $latest_products = get_posts(array('post_type' => 'wpsc-product', 'numberposts' => $number, 'orderby' => 'post_date', 'post_parent' => 0, 'post_status' => 'publish', 'order' => 'DESC'));
    $output = '';
    if (count($latest_products) > 0) {
        foreach ($latest_products as $latest_product) {
            // Link
            $output .= '<a href="' . wpsc_product_url($latest_product->ID, null) . '" class="wpsc-product-title">' . stripslashes($latest_product->post_title) . '</a>';
            // Thumbnails, if required
            if ($image) {
                $output .= '<div class="item_image">';
                $output .= '<a href="' . wpsc_product_url($latest_product->ID, null) . '">';
                $attached_images = (array) get_posts(array('post_type' => 'attachment', 'numberposts' => 1, 'post_status' => null, 'post_parent' => $latest_product->ID, 'orderby' => 'menu_order', 'order' => 'ASC'));
                $attached_image = $attached_images[0];
                if ($attached_image->ID > 0) {
                    $output .= '<img src="' . wpsc_product_image($attached_image->ID, $width, $height) . '" title="' . $latest_product->post_title . '" alt="' . $latest_product->post_title . '" />';
                } else {
                    $output .= '<img class="no-image" id="product_image_' . wpsc_the_product_id() . '" alt="No Image" title="' . wpsc_the_product_title() . '" src="' . WPSC_URL . '/wpsc-theme/images/noimage.png" width="' . $width . '" height="' . $height . '" />';
                }
                $output .= '<span></span>';
                $output .= '</a>';
                $output .= '</div>';
            }
        }
    }
    echo $output;
}
Ejemplo n.º 8
0
 function a_page_url($page = null)
 {
     //exit('<pre>'.print_r($this, true).'</pre>');
     $curpage = $this->query_vars['page'];
     if ($page != '') {
         $this->query_vars['page'] = $page;
     }
     //global $wpsc_query;
     if ($this->is_single === true) {
         $this->query_vars['page'] = $curpage;
         return wpsc_product_url($this->product['id']);
     } else {
         $output = wpsc_category_url($this->category);
         //exit('PAge <pre>'.print_r($this,true).'</pre>');
         if ($this->query_vars['page'] > 1) {
             //
             if (get_option('permalink_structure')) {
                 $output .= "page/{$this->query_vars['page']}/";
             } else {
                 $output = add_query_arg('page_number', '', $output);
             }
         }
         //	$this->query_vars['page'] = $urpage;
         //	exit('Whats returned: '.$output);
         return $output;
     }
 }
/**
 * WPSC canonical URL function
 * Needs a recent version 
 * @since 3.7
 * @param int product id
 * @return bool true or false
 */
function wpsc_change_canonical_url($url)
{
    global $wpdb, $wpsc_query, $post;
    // Only change the URL is we're viewing a WP e-Commerce page
    if (stristr($post->post_content, '[productspage]')) {
        if (isset($wpsc_query->query_vars['product_url_name'])) {
            $product_url_name = $wpsc_query->query_vars['product_url_name'];
        } else {
            $product_url_name = '';
        }
        // Viewing a single product page
        if ($product_url_name != '') {
            if (!is_numeric($_GET['product_id'])) {
                $product_id = $wpdb->get_var($wpdb->prepare("SELECT product_id FROM " . WPSC_TABLE_PRODUCTMETA . " WHERE meta_key = 'url_name'  AND meta_value = %s ORDER BY product_id DESC LIMIT 1", $product_url_name));
            } else {
                $product_id = absint($_GET['product_id']);
            }
            if ($product_id > 0) {
                $url = wpsc_product_url($product_id);
            } else {
                $url = get_option('product_list_url');
            }
            // Viewing a category page
        } elseif (absint($wpsc_query->query_vars['category_id']) > 0) {
            $url = wpsc_category_url(absint($wpsc_query->query_vars['category_id']));
            if ($wpsc_query->query_vars['page'] > 1) {
                if (get_option('permalink_structure')) {
                    $url .= "page/{$wpsc_query->query_vars['page']}/";
                } else {
                    $url .= "&page_number={$wpsc_query->query_vars['page']}";
                    $url = html_entity_decode($url);
                }
            }
        }
    }
    return $url;
}
Ejemplo n.º 10
0
 /**
  * refresh_item method, refreshes the item, calculates the prices, gets the name
  * @access public
  *
  * @return array array of monetary and other values
  */
 function refresh_item()
 {
     global $wpdb, $wpsc_shipping_modules, $wpsc_cart;
     $product_id = $this->product_id;
     $product = get_post($this->product_id);
     $product_meta = get_metadata('post', $this->product_id);
     $this->sku = get_post_meta($product_id, '_wpsc_sku', true);
     $price = get_post_meta($product_id, '_wpsc_price', true);
     $special_price = get_post_meta($product_id, '_wpsc_special_price', true);
     $product_meta = get_post_meta($product_id, '_wpsc_product_metadata');
     $this->stock = get_post_meta($product_id, '_wpsc_stock', true);
     $this->is_donation = get_post_meta($product_id, '_wpsc_is_donation', true);
     if (isset($special_price) && $special_price > 0 && $special_price < $price) {
         $price = $special_price;
     }
     $priceandstock_id = 0;
     $this->weight = isset($product_meta[0]['weight']) ? $product_meta[0]["weight"] : 0;
     // if we are using table rate price
     if (isset($product_meta[0]['table_rate_price'])) {
         $levels = $product_meta[0]['table_rate_price'];
         if (!empty($levels['quantity'])) {
             foreach ((array) $levels['quantity'] as $key => $qty) {
                 if ($this->quantity >= $qty) {
                     $unit_price = $levels['table_price'][$key];
                     if ($unit_price != '') {
                         $price = $unit_price;
                     }
                 }
             }
         }
     }
     $price = apply_filters('wpsc_price', $price, $product_id);
     // create the string containing the product name.
     $this->product_name = $this->get_title('raw');
     $this->priceandstock_id = $priceandstock_id;
     $this->meta = $product_meta;
     // change no_shipping to boolean and invert it
     if (isset($product_meta[0]['no_shipping']) && $product_meta[0]['no_shipping'] == 1) {
         $this->uses_shipping = 0;
     } else {
         $this->uses_shipping = 1;
     }
     $quantity_limited = get_product_meta($product_id, 'stock', true);
     $this->has_limited_stock = (bool) $quantity_limited;
     if ($this->is_donation == 1) {
         $this->unit_price = (double) $this->provided_price;
     } else {
         $this->unit_price = (double) $price;
     }
     $this->total_price = $this->unit_price * $this->quantity;
     if ($product->post_parent) {
         $category_data = get_the_product_category($product->post_parent);
     } else {
         $category_data = get_the_product_category($product_id);
     }
     $this->category_list = array();
     $this->category_id_list = array();
     foreach ((array) $category_data as $category_row) {
         $this->category_list[] = $category_row->slug;
         $this->category_id_list[] = $category_row->term_id;
     }
     //wpec_taxes - calculate product tax and add to total price
     $wpec_taxes_controller = new wpec_taxes_controller();
     if ($wpec_taxes_controller->wpec_taxes_isincluded() && $wpec_taxes_controller->wpec_taxes_isenabled()) {
         $taxes = $wpec_taxes_controller->wpec_taxes_calculate_included_tax($this);
         $this->tax_rate = $taxes['rate'];
         $this->tax = $taxes['tax'];
     }
     $this->product_url = wpsc_product_url($product_id);
     if (!is_array($this->variation_values)) {
         $attach_parent = $product_id;
     } else {
         $attach_parent = $wpdb->get_var($wpdb->prepare("SELECT post_parent FROM {$wpdb->posts} WHERE ID = %d", $product_id));
     }
     $att_img_args = array('post_type' => 'attachment', 'numberposts' => 1, 'post_parent' => $attach_parent, 'orderby' => 'menu_order', 'order' => 'DESC');
     $attached_image = get_posts($att_img_args);
     if ($attached_image != null) {
         $this->thumbnail_image = array_shift($attached_image);
     }
     $product_files = (array) get_posts(array('post_type' => 'wpsc-product-file', 'post_parent' => $this->product_id, 'numberposts' => -1, 'post_status' => 'inherit'));
     if (count($product_files) > 0) {
         $this->file_id = null;
         $this->is_downloadable = true;
     } else {
         $this->file_id = null;
         $this->is_downloadable = false;
     }
     if (isset($this->cart->selected_shipping_method) && isset($wpsc_shipping_modules[$this->cart->selected_shipping_method]) && is_callable(array($wpsc_shipping_modules[$this->cart->selected_shipping_method], "get_item_shipping"))) {
         $this->shipping = $wpsc_shipping_modules[$this->cart->selected_shipping_method]->get_item_shipping($this);
     }
     // update the claimed stock here
     $this->update_claimed_stock();
     do_action_ref_array('wpsc_refresh_item', array(&$this));
 }
Ejemplo n.º 11
0
/**
 * wpsc product comments function
 * @return string - javascript for the intensedebate comments
 */
function wpsc_product_comments()
{
    global $wpsc_query;
    $output = '';
    // add the product comments
    if (get_option('wpsc_enable_comments') == 1) {
        $enable_for_product = get_product_meta($wpsc_query->product['id'], 'enable_comments');
        if (get_option('wpsc_comments_which_products') == 1 && $enable_for_product == '' || $enable_for_product == 'yes') {
            $output = "<script>\n\t\t\t\tvar idcomments_acct = '" . esc_js(get_option('wpsc_intense_debate_account_id')) . "';\n\t\t\t\tvar idcomments_post_id = 'product_" . $wpsc_query->product['id'] . "';\n\t\t\t\tvar idcomments_post_url = encodeURIComponent('" . wpsc_product_url($wpsc_query->product['id'], null, false) . "');\n\t\t\t\t</script>\n\t\t\t\t<span id=\"IDCommentsPostTitle\" style=\"display:none\"></span>\n\t\t\t\t<script type='text/javascript' src='https://www.intensedebate.com/js/genericCommentWrapperV2.js'></script>\n\t\t\t\t";
        }
    }
    return $output;
}
Ejemplo n.º 12
0
     $selected_category = "&amp;category_id=" . $_GET['category'] . "";
 }
 $self = get_option('siteurl') . "/index.php?rss=true&amp;action=product_list{$selected_category}";
 $product_list = $wpdb->get_results($sql, ARRAY_A);
 header("Content-Type: application/xml; charset=UTF-8");
 header('Content-Disposition: inline; filename="E-Commerce_Product_List.rss"');
 $output = "<?xml version='1.0'?>\n\r";
 $output .= "<rss version='2.0' xmlns:atom='http://www.w3.org/2005/Atom' xmlns:product='http://www.buy.com/rss/module/productV2/'>\n\r";
 $output .= "  <channel>\n\r";
 $output .= "    <title>" . get_option('blogname') . " Products</title>\n\r";
 $output .= "    <link>" . get_option('siteurl') . "/wp-admin/admin.php?page=" . WPSC_DIR_NAME . "/display-log.php</link>\n\r";
 $output .= "    <description>This is the WP E-Commerce Product List RSS feed</description>\n\r";
 $output .= "    <generator>WP E-Commerce Plugin</generator>\n\r";
 $output .= "    <atom:link href='{$self}' rel='self' type='application/rss+xml' />";
 foreach ($product_list as $product) {
     $purchase_link = wpsc_product_url($product['id']);
     $output .= "    <item>\n\r";
     $output .= "      <title>" . htmlentities(stripslashes($product['name']), ENT_NOQUOTES, 'UTF-8') . "</title>\n\r";
     $output .= "      <link>{$purchase_link}</link>\n\r";
     //$output .= "      <description>".htmlentities(stripslashes($product['description']), ENT_NOQUOTES, 'UTF-8')."</description>\n\r";
     $output .= "      <description><![CDATA[\n" . htmlentities(stripslashes($product['description']), ENT_NOQUOTES, 'UTF-8') . "\n]]></description>\n\r";
     $output .= "      <pubDate>" . date("r") . "</pubDate>\n\r";
     $output .= "      <guid>{$purchase_link}</guid>\n\r";
     if ($product['thumbnail_image'] != null) {
         $image_file_name = $product['thumbnail_image'];
     } else {
         $image_file_name = $product['image'];
     }
     $image_path = WPSC_THUMBNAIL_DIR . $image_file_name;
     if (is_file($image_path) && filesize($image_path) > 0) {
         $image_data = @getimagesize($image_path);
Ejemplo n.º 13
0
 /**
  * refresh_item method, refreshes the item, calculates the prices, gets the name
  * @access public
  *
  * @return array array of monetary and other values
  */
 function refresh_item()
 {
     global $wpdb, $wpsc_shipping_modules, $wpsc_cart;
     $product = $wpdb->get_row("SELECT * FROM `" . WPSC_TABLE_PRODUCT_LIST . "` WHERE `id` = '{$this->product_id}' LIMIT 1", ARRAY_A);
     $priceandstock_id = 0;
     if (defined('WPSC_ADD_DEBUG_PAGE') && constant('WPSC_ADD_DEBUG_PAGE') == true) {
         $this->product_data = $wpdb->get_row("SELECT * FROM `" . WPSC_TABLE_PRODUCT_LIST . "` WHERE `id` = '{$this->product_id}' LIMIT 1", ARRAY_A);
     }
     if (count($this->variation_values) > 0) {
         // if there are variations, get the price of the combination and the names of the variations.
         $variation_data = $wpdb->get_results("SELECT *FROM `" . WPSC_TABLE_VARIATION_VALUES . "` WHERE `id` IN ('" . implode("','", $this->variation_values) . "')", ARRAY_A);
         $this->variation_data = $variation_data;
         $variation_names = array();
         $variation_ids = array();
         foreach ($variation_data as $variation_row) {
             $variation_names[] = $variation_row['name'];
             $variation_ids[] = $variation_row['variation_id'];
         }
         asort($variation_ids);
         $variation_id_string = implode(",", $variation_ids);
         $priceandstock_id = $wpdb->get_var("SELECT `priceandstock_id` FROM `" . WPSC_TABLE_VARIATION_COMBINATIONS . "` WHERE `product_id` = '{$this->product_id}' AND `value_id` IN ( '" . implode("', '", $this->variation_values) . "' ) AND `all_variation_ids` IN('{$variation_id_string}') GROUP BY `priceandstock_id` HAVING COUNT( `priceandstock_id` ) = '" . count($this->variation_values) . "' LIMIT 1");
         $priceandstock_values = $wpdb->get_row("SELECT * FROM `" . WPSC_TABLE_VARIATION_PROPERTIES . "` WHERE `id` = '{$priceandstock_id}' LIMIT 1", ARRAY_A);
         $price = $priceandstock_values['price'];
         $weight = wpsc_convert_weights($priceandstock_values['weight'], $priceandstock_values['weight_unit']);
         $file_id = $priceandstock_values['file'];
     } else {
         $priceandstock_id = 0;
         $weight = wpsc_convert_weights($product['weight'], $product['weight_unit']);
         // otherwise, just get the price.
         if ($product['special_price'] > 0 and $product['price'] - $product['special_price'] >= 0) {
             $sale_discount = (double) $product['special_price'];
         } else {
             $sale_discount = 0;
         }
         $price = $product['price'] - $sale_discount;
         $file_id = $product['file'];
         // if we are using table rate price
         $levels = get_product_meta($this->product_id, 'table_rate_price');
         if ($levels != '') {
             foreach ((array) $levels['quantity'] as $key => $qty) {
                 if ($this->quantity >= $qty) {
                     $unit_price = $levels['table_price'][$key];
                     if ($unit_price != '') {
                         $price = $unit_price;
                     }
                 }
             }
         }
     }
     $price = apply_filters('wpsc_do_convert_price', $price);
     // create the string containing the product name.
     $product_name = $product['name'];
     if (count($variation_names) > 0) {
         $product_name .= " (" . implode(", ", $variation_names) . ")";
     }
     $this->product_name = $product_name;
     $this->priceandstock_id = $priceandstock_id;
     $this->is_donation = (bool) $product['donation'];
     // change notax to boolean and invert it
     $this->apply_tax = !(bool) $product['notax'];
     // change no_shipping to boolean and invert it
     $this->uses_shipping = !(bool) $product['no_shipping'];
     $this->has_limited_stock = (bool) (int) $product['quantity_limited'];
     if ($this->is_donation == 1) {
         $this->unit_price = $this->provided_price;
     } else {
         $this->unit_price = $price;
     }
     $this->weight = $weight;
     $this->total_price = $this->unit_price * $this->quantity;
     $category_data = $wpdb->get_results("SELECT `" . WPSC_TABLE_PRODUCT_CATEGORIES . "`.`id`,`" . WPSC_TABLE_PRODUCT_CATEGORIES . "`.`nice-name`  FROM `" . WPSC_TABLE_ITEM_CATEGORY_ASSOC . "` , `" . WPSC_TABLE_PRODUCT_CATEGORIES . "` WHERE `" . WPSC_TABLE_ITEM_CATEGORY_ASSOC . "`.`product_id` IN ('" . $product['id'] . "') AND `" . WPSC_TABLE_ITEM_CATEGORY_ASSOC . "`.`category_id` = `" . WPSC_TABLE_PRODUCT_CATEGORIES . "`.`id` AND `" . WPSC_TABLE_PRODUCT_CATEGORIES . "`.`active` IN('1')", ARRAY_A);
     $this->category_list = array();
     $this->category_id_list = array();
     foreach ($category_data as $category_row) {
         $this->category_list[] = $category_row['nice-name'];
         $this->category_id_list[] = $category_row['id'];
     }
     if ($this->apply_tax == true) {
         $this->taxable_price = $this->total_price;
         $custom_tax = get_product_meta($this->product_id, 'custom_tax');
         if (is_numeric($custom_tax)) {
             $this->custom_tax_rate = $custom_tax;
             $this->tax = $this->taxable_price * ($this->custom_tax_rate / 100);
         } else {
             $this->tax = $this->taxable_price * ($wpsc_cart->tax_percentage / 100);
         }
     }
     $this->product_url = wpsc_product_url($this->product_id);
     $this->image_id = $product['image'];
     if ($product['thumbnail_image'] != null) {
         $this->thumbnail_image = $product['thumbnail_image'];
     } else {
         $this->thumbnail_image = $product['image'];
     }
     $product_files = (array) get_product_meta($this->product_id, 'product_files');
     if ($file_id > 0 && (count($product_files) <= 0 || count($this->variation_values) > 0)) {
         $this->file_id = (int) $file_id;
         $this->is_downloadable = true;
     } else {
         if (count($product_files) > 0) {
             $this->file_id = null;
             $this->is_downloadable = true;
         } else {
             $this->file_id = null;
             $this->is_downloadable = false;
         }
     }
     if (is_callable(array($wpsc_shipping_modules[$this->cart->selected_shipping_method], 'get_item_shipping'))) {
         $this->shipping = $wpsc_shipping_modules[$this->cart->selected_shipping_method]->get_item_shipping($this);
     }
     // update the claimed stock here
     $this->update_claimed_stock();
 }
Ejemplo n.º 14
0
function wpsc_generate_product_feed()
{
    global $wpdb;
    // Don't cache feed under WP Super-Cache
    define('DONOTCACHEPAGE', TRUE);
    $siteurl = get_option('siteurl');
    // Allow limiting
    if (is_numeric($_GET['limit'])) {
        $limit = "LIMIT " . $_GET['limit'] . "";
    } else {
        $limit = '';
    }
    $selected_category = '';
    $selected_product = '';
    if (is_numeric($_GET['product_id'])) {
        $selected_product = "&amp;product_id=" . $_GET['product_id'] . "";
        $sql = "    SELECT p.*,\n\t\t                   pi.image\n\t\t              FROM `" . WPSC_TABLE_PRODUCT_LIST . "` p\n\t\t         LEFT JOIN `" . WPSC_TABLE_PRODUCT_IMAGES . "` pi\n\t\t                ON `p`.`image` = `pi`.`id`\n\t\t               AND `pi`.`product_id` = `p`.`id`\n\t\t             WHERE `active` = '1'\n\t\t               AND `publish` = '1'\n\t\t               AND p.id = '" . $_GET['product_id'] . "'\n\t\t             LIMIT 1";
    } elseif (is_numeric($_GET['category_id'])) {
        $selected_category = "&amp;category_id=" . $_GET['category_id'] . "";
        $sql = "SELECT `p`.*,\n\t\t               `pi`.`image`\n\t\t          FROM `" . WPSC_TABLE_PRODUCT_LIST . "` p\n\t\t     LEFT JOIN `" . WPSC_TABLE_PRODUCT_IMAGES . "` pi\n\t\t            ON `p`.`image` = `pi`.`id`\n\t\t           AND `p`.`id` = `pi`.`product_id`\n\t\t     LEFT JOIN `" . WPSC_TABLE_ITEM_CATEGORY_ASSOC . "` ca\n\t\t            ON `p`.`id` = `ca`.`product_id`\n\t\t         WHERE `p`.`active` = '1'\n\t\t           AND `p`.`publish` = '1'\n\t\t           AND `ca`.`category_id` IN ('" . $_GET['category_id'] . "')\n\t\t        {$limit}";
    } else {
        $sql = "SELECT p.*,\n\t\t               pi.image\n\t\t          FROM `" . WPSC_TABLE_PRODUCT_LIST . "` p\n\t\t     LEFT JOIN `" . WPSC_TABLE_PRODUCT_IMAGES . "` pi\n\t\t            ON `p`.`image` = `pi`.`id`\n\t\t           AND `pi`.`product_id` = `p`.`id`\n\t\t         WHERE `active` ='1'\n\t\t           AND `publish` = '1'\n\t\t      ORDER BY `id`\n\t\t          DESC {$limit}";
    }
    $self = get_option('siteurl') . "/index.php?rss=true&amp;action=product_list{$selected_category}{$selected_product}";
    $product_list = $wpdb->get_results($sql, ARRAY_A);
    header("Content-Type: application/xml; charset=UTF-8");
    header('Content-Disposition: inline; filename="e-Commerce_Product_List.rss"');
    $output = "<?xml version='1.0' encoding='UTF-8' ?>\n\r";
    $output .= "<rss version='2.0' xmlns:atom='http://www.w3.org/2005/Atom'";
    $google_checkout_note = FALSE;
    if ($_GET['xmlformat'] == 'google') {
        $output .= ' xmlns:g="http://base.google.com/ns/1.0"';
        // Is Google Checkout available as a payment gateway
        $selected_gateways = get_option('custom_gateway_options');
        if (in_array('google', $selected_gateways)) {
            $google_checkout_note = TRUE;
        }
    } else {
        $output .= ' xmlns:product="http://www.buy.com/rss/module/productV2/"';
    }
    $output .= ">\n\r";
    $output .= "  <channel>\n\r";
    $output .= "    <title><![CDATA[" . get_option('blogname') . " Products]]></title>\n\r";
    $output .= "    <link>" . get_option('siteurl') . "/wp-admin/admin.php?page=" . WPSC_DIR_NAME . "/display-log.php</link>\n\r";
    $output .= "    <description>This is the WP e-Commerce Product List RSS feed</description>\n\r";
    $output .= "    <generator>WP e-Commerce Plugin</generator>\n\r";
    $output .= "    <atom:link href='{$self}' rel='self' type='application/rss+xml' />\n\r";
    foreach ($product_list as $product) {
        $purchase_link = wpsc_product_url($product['id']);
        $output .= "    <item>\n\r";
        if ($google_checkout_note) {
            $output .= "      <g:payment_notes>Google Checkout</g:payment_notes>\n\r";
        }
        $output .= "      <title><![CDATA[" . stripslashes($product['name']) . "]]></title>\n\r";
        $output .= "      <link>{$purchase_link}</link>\n\r";
        $output .= "      <description><![CDATA[" . stripslashes($product['description']) . "]]></description>\n\r";
        $output .= "      <pubDate>" . date("r") . "</pubDate>\n\r";
        $output .= "      <guid>{$purchase_link}</guid>\n\r";
        if ($product['thumbnail_image'] != null) {
            $image_file_name = $product['thumbnail_image'];
            $image_path = WP_CONTENT_DIR . "/uploads" . "/wpsc/product_images/thumbnails/{$image_file_name}";
            $image_link = WP_CONTENT_URL . "/uploads" . "/wpsc/product_images/thumbnails/" . rawurlencode($image_file_name);
        } else {
            $image_file_name = $product['image'];
            $image_path = WP_CONTENT_DIR . "/uploads" . "/wpsc/product_images/{$image_file_name}";
            $image_link = WP_CONTENT_URL . "/uploads" . "/wpsc/product_images/" . rawurlencode($image_file_name);
        }
        //$image_path = WP_CONTENT_DIR."/uploads"."/wpsc/product_images/thumbnails/{$image_file_name}";
        if (is_file($image_path) && filesize($image_path) > 0) {
            $image_data = @getimagesize($image_path);
            //	$image_link = WP_CONTENT_URL."/uploads"."/wpsc/product_images/thumbnails/".urlencode($image_file_name);
            if ($_GET['xmlformat'] == 'google') {
                $output .= "      <g:image_link>{$image_link}</g:image_link>\n\r";
            } else {
                $output .= "      <enclosure url='{$image_link}' length='" . filesize($image_path) . "' type='" . $image_data['mime'] . "' width='" . $image_data[0] . "' height='" . $image_data[1] . "' />\n\r";
            }
        }
        if ($_GET['xmlformat'] == 'google') {
            $output .= "      <g:price>" . $product['price'] . "</g:price>\n\r";
            //$output .= "      <g:condition>new</g:condition>\n\r";
            $meta_sql = "SELECT meta_key, meta_value \n\t\t                 FROM `" . WPSC_TABLE_PRODUCTMETA . "` pm\n                         WHERE `pm`.`product_id` = '" . $product['id'] . "'\n                         AND `pm`.`meta_key` LIKE 'g:%'";
            $google_elements = $wpdb->get_results($meta_sql, ARRAY_A);
            $google_elements = apply_filters('wpsc_google_elements', array('product_id' => $product['id'], 'elements' => $google_elements));
            $google_elements = $google_elements['elements'];
            $done_condition = FALSE;
            if (count($google_elements)) {
                foreach ($google_elements as $gelement) {
                    $output .= "      <" . $gelement['meta_key'] . ">";
                    $output .= "<![CDATA[" . $gelement['meta_value'] . "]]>";
                    $output .= "</" . $gelement['meta_key'] . ">\n\r";
                    if ($gelement['meta_key'] == 'g:condition') {
                        $done_condition = TRUE;
                    }
                }
            }
            if (!$done_condition) {
                $output .= "      <g:condition>new</g:condition>\n\r";
            }
        } else {
            $output .= "      <product:price>" . $product['price'] . "</product:price>\n\r";
        }
        $output .= "    </item>\n\r";
    }
    $output .= "  </channel>\n\r";
    $output .= "</rss>";
    echo $output;
    exit;
}
Ejemplo n.º 15
0
function show_cats_brands($category_group = null, $display_method = null, $order_by = 'name', $image = null)
{
    global $wpdb;
    if ($category_group == null) {
        $category_group = $wpdb->get_var("SELECT `id` FROM `" . $wpdb->prefix . "wpsc_categorisation_groups` WHERE `active` IN ('1') AND `default` IN ('1') LIMIT 1 ");
    } else {
        $category_group = (int) $category_group;
    }
    // Show cats & brands list if displaying on every page or if on a shop page (bit hacky but out of time).
    if (get_option('cat_brand_loc') != 3 && !function_exists("nzshpcrt_display_categories_groups") && $display_method != 'sidebar') {
        return;
    }
    if (get_option('permalink_structure') != '') {
        $seperator = "?";
    } else {
        $seperator = "&amp;";
    }
    $output = "<div class='PeSwitcher'>";
    switch (get_option('show_categorybrands')) {
        case 1:
            $output .= "<ul id='PeCatsBrandsBoth' class='category_brand_header'><li id='PeSwitcherFirst'><a href='' onclick='return prodgroupswitch(\"categories\");'>" . TXT_WPSC_CATEGORIES . "</a> | <a href='' onclick='return prodgroupswitch(\"brands\");'>" . TXT_WPSC_BRANDS . "</a></li></ul>";
            break;
    }
    $output .= "</div>";
    $output .= "<div class='PeCatsBrands'>";
    if (get_option('show_categorybrands') == 1 || get_option('show_categorybrands') == 2) {
        $output .= "<div class='PeCategories categorydisplay'>";
        $categories = $wpdb->get_results("SELECT * FROM `" . $wpdb->prefix . "product_categories` WHERE `group_id` IN ('{$category_group}') AND `active`='1' AND `category_parent` = '0' ORDER BY `" . $wpdb->escape($order_by) . "` ASC", ARRAY_A);
        if ($categories != null) {
            $output .= "<ul class='PeCategories'>";
            foreach ($categories as $option) {
                // Adrian - check option for category count
                if (get_option('show_category_count') == 1) {
                    //show product count for each category
                    $count_sql = "SELECT count(*) FROM `" . $wpdb->prefix . "item_category_associations` WHERE `category_id` = '" . $option['id'] . "'";
                    $count = $wpdb->get_var($count_sql);
                    $addCount = " [" . $count . "]";
                }
                //end get_option
                // Adrian - if sliding category type selected, NO link for category text, mootools.js creates the linkable sliders onDomReady.
                if (get_option('catsprods_display_type') == 1) {
                    $output .= "<li class='MainCategory'><strong class='category'>" . stripslashes($option['name']) . $addCount . "</strong>";
                } else {
                    // Adrian - otherwise create normal category text with or without product count
                    if (!$image) {
                        $output .= "<li class='MainCategory'><strong class='category'><a class='productlink' href='" . wpsc_category_url($option['id']) . "'>" . stripslashes($option['name']) . $addCount . "</a></strong>";
                    } else {
                        $output .= "<li class='MainCategory'><img src='" . get_option('siteurl') . "/wp-content/uploads/wpsc/category_images/" . $option['image'] . "'><br><strong class='category'><a class='productlink' href='" . wpsc_category_url($option['id']) . "'>" . stripslashes($option['name']) . $addCount . "</a></strong>";
                    }
                }
                //end get_option
                $subcategory_sql = "SELECT * FROM `" . $wpdb->prefix . "product_categories` WHERE `group_id` IN ('{$category_group}') AND `active`='1' AND `category_parent` = '" . $option['id'] . "' ORDER BY `id`";
                $subcategories = $wpdb->get_results($subcategory_sql, ARRAY_A);
                if ($subcategories != null) {
                    $output .= display_subcategories($option['id']);
                } else {
                    // Adrian - check if the user wants categories only or sliding categories
                    if (get_option('catsprods_display_type') == 1) {
                        // Adrian - display all products for that category
                        $product_sql = "SELECT product_id FROM `" . $wpdb->prefix . "item_category_associations` WHERE `category_id` = '" . $option['id'] . "'";
                        $productIDs = $wpdb->get_results($product_sql, ARRAY_A);
                        if ($productIDs != null) {
                            $output .= "<ul>";
                            foreach ($productIDs as $productID) {
                                $ID = $productID['product_id'];
                                $productName_sql = "SELECT name FROM `" . $wpdb->prefix . "product_list` WHERE `id` = '" . $ID . "'";
                                $productName = $wpdb->get_var($productName_sql);
                                $output .= "<li><a class='productlink' href='" . wpsc_product_url($ID, $option['id']) . "'>" . $productName . "</a></li>";
                            }
                            //end foreach
                            $output .= "</ul>";
                        }
                        //end if productsIDs
                    }
                    //end if get_option
                }
                //end else
                $output .= "</li>";
            }
            $output .= "</ul>";
        }
        $output .= "</div>";
    }
    if (get_option('show_categorybrands') == 1 || get_option('show_categorybrands') == 3) {
        if (get_option('show_categorybrands') == 1) {
            $output .= "<ul class='PeBrands branddisplay' style='display: none;'>";
        } else {
            $output .= "<ul class='PeBrands branddisplay'>";
        }
        //$output ='';
        $brands = $wpdb->get_results("SELECT * FROM `" . $wpdb->prefix . "product_brands` WHERE `active`='1' ORDER BY `order` ASC", ARRAY_A);
        if ($brands != null) {
            foreach ($brands as $option) {
                $output .= "<li><a class='categorylink' href='" . get_option('product_list_url') . $seperator . "brand=" . $option['id'] . "'>" . stripslashes($option['name']) . "</a></li>";
            }
        }
        //$output .= $output;
        $output .= "</ul>";
    }
    $output .= "</div>";
    echo $output;
}
function wpsc_latest_product($args = null, $instance)
{
    global $wpdb;
    $args = wp_parse_args((array) $args, array('number' => 5));
    $siteurl = get_option('siteurl');
    $options = get_option('wpsc-widget_latest_products');
    $number = isset($instance['number']) ? (int) $instance['number'] : 5;
    $image = isset($instance['image']) ? (bool) $instance['image'] : FALSE;
    if (isset($instance['width'])) {
        $width = $instance['width'];
    }
    if (isset($instance['height'])) {
        $height = $instance['height'];
    }
    $latest_products = get_posts(array('post_type' => 'wpsc-product', 'numberposts' => $number, 'orderby' => 'post_date', 'post_parent' => 0, 'post_status' => 'publish', 'order' => 'DESC'));
    $output = '';
    if (count($latest_products) > 0) {
        $output .= '<ul class="wpsc-latest-products">';
        foreach ($latest_products as $latest_product) {
            $output .= '<li class="wpsc-latest-product">';
            // Thumbnails, if required
            if ($image) {
                $output .= '<div class="item_image">';
                $output .= '<a href="' . wpsc_product_url($latest_product->ID, null) . '">';
                $thumbnail = wpsc_the_product_thumbnail($width, $height, $latest_product->ID, '');
                if ($thumbnail) {
                    $output .= '<img src="' . esc_url($thumbnail) . '" title="' . apply_filters('the_title', $latest_product->post_title) . '" alt="' . apply_filters('the_title', $latest_product->post_title) . '" />';
                } else {
                    $output .= '<img class="no-image" id="product_image_' . wpsc_the_product_id() . '" alt="' . esc_attr__('No Image', 'wpsc') . '" title="' . wpsc_the_product_title() . '" src="' . WPSC_URL . '/wpsc-theme/wpsc-images/noimage.png" width="' . $width . '" height="' . $height . '" />';
                }
                $output .= '</a>';
                $output .= '</div>';
            }
            // Link
            $output .= '<a href="' . esc_url(wpsc_product_url($latest_product->ID, null)) . '" class="wpsc-product-title">' . apply_filters('the_title', $latest_product->post_title) . '</a>';
            $output .= '</li>';
        }
        $output .= "</ul>";
    }
    echo $output;
}
Ejemplo n.º 17
0
/**
 * Product Specials Widget content function
 *
 * Displays the latest products.
 *
 * @todo Remove marketplace theme specific code and maybe replce with a filter for the image output? (not required if themeable as above)
 *
 * Changes made in 3.8 that may affect users:
 *
 * 1. The product title link text does now not have a bold tag, it should be styled via css.
 * 2. <br /> tags have been ommitted. Padding and margins should be applied via css.
 * 3. Each product is enclosed in a <div> with a 'wpec-special-product' class.
 * 4. The product list is enclosed in a <div> with a 'wpec-special-products' class.
 * 5. Function now expect a single paramter with an array of options (used to be a string which prepended the output).
 */
function wpsc_specials($args = null, $instance)
{
    global $wpdb;
    $args = wp_parse_args((array) $args, array('number' => 5));
    $siteurl = get_option('siteurl');
    if (!($number = (int) $instance['number'])) {
        $number = 5;
    }
    $show_thumbnails = isset($instance['show_thumbnails']) ? (bool) $instance['show_thumbnails'] : FALSE;
    $show_description = isset($instance['show_description']) ? (bool) $instance['show_description'] : FALSE;
    $excludes = wpsc_specials_excludes();
    $args = array('post_type' => 'wpsc-product', 'caller_get_posts' => 1, 'post_status' => 'publish', 'post_parent' => 0, 'post__not_in' => $excludes, 'posts_per_page' => $number);
    $special_products = query_posts($args);
    $output = '';
    $product_ids[] = array();
    if (count($special_products) > 0) {
        list($wp_query, $special_products) = array($special_products, $wp_query);
        // swap the wpsc_query object
        while (wpsc_have_products()) {
            wpsc_the_product();
            if (!in_array(wpsc_the_product_id(), $product_ids)) {
                $product_ids[] = wpsc_the_product_id();
                if ($show_thumbnails) {
                    if (wpsc_the_product_thumbnail()) {
                        ?>
						<a rel="<?php 
                        echo str_replace(array(" ", '"', "'", '&quot;', '&#039;'), array("_", "", "", "", ''), wpsc_the_product_title());
                        ?>
" href="<?php 
                        echo wpsc_the_product_permalink();
                        ?>
">
							<img class="product_image" id="product_image_<?php 
                        echo wpsc_the_product_id();
                        ?>
" alt="<?php 
                        echo wpsc_the_product_title();
                        ?>
" title="<?php 
                        echo wpsc_the_product_title();
                        ?>
" src="<?php 
                        echo wpsc_the_product_thumbnail();
                        ?>
"/>
						</a>
				<?php 
                    } else {
                        ?>
							<a href="<?php 
                        echo wpsc_the_product_permalink();
                        ?>
">
							<img class="no-image" id="product_image_<?php 
                        echo wpsc_the_product_id();
                        ?>
" alt="No Image" title="<?php 
                        echo wpsc_the_product_title();
                        ?>
" src="<?php 
                        echo WPSC_URL;
                        ?>
/wpsc-theme/wpsc-images/noimage.png" width="<?php 
                        esc_attr_e(get_option('product_image_width'));
                        ?>
" height="<?php 
                        esc_attr_e(get_option('product_image_height'));
                        ?>
" />
							</a>
				<?php 
                    }
                    ?>
				<?php 
                }
                // close show thumbnails
                ?>
 
				<br />
				<span id="special_product_price_<?php 
                echo wpsc_the_product_id();
                ?>
">
				<!-- price display -->
				<?php 
                echo wpsc_the_product_price();
                ?>
				</span><br />			
				<strong><a class="wpsc_product_title" href="<?php 
                echo wpsc_product_url(wpsc_the_product_id(), false);
                ?>
"><?php 
                echo wpsc_the_product_title();
                ?>
</a></strong><br /> 
				
				<?php 
                if ($show_description) {
                    ?>
					<div class="wpsc-special-description">
						<?php 
                    echo wpsc_the_product_description();
                    ?>
					</div>									
				<?php 
                }
                // close show description
                ?>
 
			
				<?php 
            }
        }
        list($wp_query, $special_products) = array($special_products, $wp_query);
        // swap the wpsc_query object
        wp_reset_query();
    }
}
Ejemplo n.º 18
0
function wpsc_also_bought($product_id)
{
    /*
     * Displays products that were bought aling with the product defined by $product_id
     * most of it scarcely needs describing
     */
    global $wpdb;
    $siteurl = get_option('siteurl');
    if (get_option('wpsc_also_bought') == 0) {
        //returns nothing if this is off
        return '';
    }
    // to be made customiseable in a future release
    $also_bought_limit = 3;
    $element_widths = 96;
    $image_display_height = 96;
    $image_display_width = 96;
    $also_bought = $wpdb->get_results("SELECT `" . $wpdb->prefix . "product_list`.* FROM `" . $wpdb->prefix . "also_bought_product`, `" . $wpdb->prefix . "product_list` WHERE `selected_product`='" . $product_id . "' AND `" . $wpdb->prefix . "also_bought_product`.`associated_product` = `" . $wpdb->prefix . "product_list`.`id` AND `" . $wpdb->prefix . "product_list`.`active` IN('1') ORDER BY `wp_also_bought_product`.`quantity` DESC LIMIT {$also_bought_limit}", ARRAY_A);
    if (count($also_bought) > 0) {
        $output = "<p class='wpsc_also_bought_header'>" . TXT_WPSC_ALSO_BOUGHT . "</p>";
        $output .= "<div class='wpsc_also_bought'>";
        foreach ((array) $also_bought as $also_bought_data) {
            $output .= "<p class='wpsc_also_bought' style='width: " . $element_widths . "px;'>";
            if (get_option('show_thumbnails') == 1) {
                if ($also_bought_data['image'] != null) {
                    $image_size = @getimagesize(WPSC_THUMBNAIL_DIR . $also_bought_data['image']);
                    $largest_dimension = $image_size[1] >= $image_size[0] ? $image_size[1] : $image_size[0];
                    $size_multiplier = $image_display_height / $largest_dimension;
                    // to only make images smaller, scaling up is ugly, also, if one is scaled, so must the other be scaled
                    if ($image_size[0] >= $image_display_width || $image_size[1] >= $image_display_height) {
                        $resized_width = $image_size[0] * $size_multiplier;
                        $resized_height = $image_size[1] * $size_multiplier;
                    } else {
                        $resized_width = $image_size[0];
                        $resized_height = $image_size[1];
                    }
                    $margin_top = floor((96 - $resized_height) / 2);
                    $margin_top = 0;
                    $image_link = WPSC_IMAGE_URL . $also_bought_data['image'];
                    if ($also_bought_data['thumbnail_image'] != null) {
                        $image_file_name = $also_bought_data['thumbnail_image'];
                    } else {
                        $image_file_name = $also_bought_data['image'];
                    }
                    $output .= "<a href='" . wpsc_product_url($also_bought_data['id']) . "' class='preview_link'  rel='" . str_replace(" ", "_", $also_bought_data['name']) . "'>";
                    $image_url = "index.php?productid=" . $also_bought_data['id'] . "&amp;thumbnail=true&amp;width=" . $resized_width . "&amp;height=" . $resized_height . "";
                    $output .= "<img src='{$siteurl}/{$image_url}' id='product_image_" . $also_bought_data['id'] . "' class='product_image' style='margin-top: " . $margin_top . "px'/>";
                    $output .= "</a>";
                } else {
                    if (get_option('product_image_width') != '') {
                        $output .= "<img src='" . WPSC_URL . "/no-image-uploaded.gif' title='" . $also_bought_data['name'] . "' alt='" . $also_bought_data['name'] . "' width='{$image_display_height}' height='{$image_display_height}' id='product_image_" . $also_bought_data['id'] . "' class='product_image' />";
                    } else {
                        $output .= "<img src='" . WPSC_URL . "/no-image-uploaded.gif' title='" . $also_bought_data['name'] . "' alt='" . $product['name'] . "' id='product_image_" . $also_bought_data['id'] . "' class='product_image' />";
                    }
                }
            }
            $output .= "<a class='wpsc_product_name' href='" . wpsc_product_url($also_bought_data['id']) . "'>" . $also_bought_data['name'] . "</a>";
            //$output .= "<a href='".wpsc_product_url($also_bought_data['id'])."'>".$also_bought_data['name']."</a>";
            $output .= "</p>";
        }
        $output .= "</div>";
        $output .= "<br clear='all' />";
    }
    return $output;
}
Ejemplo n.º 19
0
/**
 * Product Specials Widget content function
 *
 * Displays the latest products.
 *
 * Changes made in 3.8 that may affect users:
 *
 * 1. The product title link text does now not have a bold tag, it should be styled via css.
 * 2. <br /> tags have been ommitted. Padding and margins should be applied via css.
 * 3. Each product is enclosed in a <div> with a 'wpec-special-product' class.
 * 4. The product list is enclosed in a <div> with a 'wpec-special-products' class.
 * 5. Function now expect a single paramter with an array of options (used to be a string which prepended the output).
 */
function wpsc_specials($args = null, $instance)
{
    global $wpdb;
    $args = wp_parse_args((array) $args, array('number' => 5));
    if (!($number = (int) $instance['number'])) {
        $number = 5;
    }
    $show_thumbnails = isset($instance['show_thumbnails']) ? (bool) $instance['show_thumbnails'] : false;
    $show_description = isset($instance['show_description']) ? (bool) $instance['show_description'] : false;
    $show_discount = isset($instance['show_discount']) ? (bool) $instance['show_discount'] : false;
    $show_old_price = isset($instance['show_old_price']) ? (bool) $instance['show_old_price'] : false;
    $args = array('post_type' => 'wpsc-product', 'ignore_sticky_posts' => 1, 'post_status' => 'publish', 'post_parent' => 0, 'posts_per_page' => $number, 'no_found_rows' => true);
    add_filter('posts_join', '_wpsc_filter_special_widget_join');
    add_filter('posts_where', '_wpsc_filter_special_widget_where');
    $special_products = new WP_Query($args);
    remove_filter('posts_join', '_wpsc_filter_special_widget_join');
    remove_filter('posts_where', '_wpsc_filter_special_widget_where');
    if (!$special_products->post_count) {
        echo apply_filters('wpsc_specials_widget_no_items_message', __('We currently have no items on special.', 'wp-e-commerce'));
        return;
    }
    $product_ids = array();
    while ($special_products->have_posts()) {
        $special_products->the_post();
        ?>
		<h4><strong><a class="wpsc_product_title" href="<?php 
        echo esc_url(wpsc_product_url(wpsc_the_product_id(), false));
        ?>
"><?php 
        echo esc_html(wpsc_the_product_title());
        ?>
</a></h4></strong>

		<?php 
        if ($show_description) {
            ?>
			<div class="wpsc-special-description">
				<?php 
            echo wpsc_the_product_description();
            ?>
			</div>
		<?php 
        }
        // close show description
        if (!in_array(wpsc_the_product_id(), $product_ids)) {
            $product_ids[] = wpsc_the_product_id();
            $has_children = wpsc_product_has_children(get_the_ID());
            $width = get_option('product_image_width');
            $height = get_option('product_image_height');
            if ($show_thumbnails) {
                if (wpsc_the_product_thumbnail()) {
                    ?>
					<a rel="<?php 
                    echo str_replace(array(" ", '"', "'", '&quot;', '&#039;'), array("_", "", "", "", ''), wpsc_the_product_title());
                    ?>
" href="<?php 
                    echo esc_url(wpsc_the_product_permalink());
                    ?>
"><img class="product_image" id="product_image_<?php 
                    echo esc_attr(wpsc_the_product_id());
                    ?>
" alt="<?php 
                    echo esc_attr(wpsc_the_product_title());
                    ?>
" title="<?php 
                    echo esc_attr(wpsc_the_product_title());
                    ?>
" src="<?php 
                    echo esc_url(wpsc_the_product_thumbnail($width, $height));
                    ?>
"/></a>
				<?php 
                } else {
                    ?>
					<a href="<?php 
                    esc_url(wpsc_the_product_permalink());
                    ?>
"><img class="no-image" id="product_image_<?php 
                    echo esc_attr(wpsc_the_product_id());
                    ?>
" alt="<?php 
                    echo esc_attr(wpsc_the_product_title());
                    ?>
" title="<?php 
                    echo esc_attr(wpsc_the_product_title());
                    ?>
" src="<?php 
                    echo esc_url(WPSC_CORE_THEME_PATH . '/wpsc-images/noimage.png');
                    ?>
" width="<?php 
                    echo esc_attr($width);
                    ?>
" height="<?php 
                    echo esc_attr($height);
                    ?>
" /></a>
				<?php 
                }
                ?>
				<br />
			<?php 
            }
            // close show thumbnails
            ?>
			<div id="special_product_price_<?php 
            echo esc_attr(wpsc_the_product_id());
            ?>
">
				<?php 
            wpsc_the_product_price_display(array('output_old_price' => $show_old_price, 'output_you_save' => $show_discount));
            ?>
			</div><br />
			<?php 
        }
    }
    wp_reset_postdata();
}
Ejemplo n.º 20
0
/**
 * Product Specials Widget content function
 *
 * Displays the latest products.
 *
 * @todo Remove marketplace theme specific code and maybe replce with a filter for the image output? (not required if themeable as above)
 *
 * Changes made in 3.8 that may affect users:
 *
 * 1. The product title link text does now not have a bold tag, it should be styled via css.
 * 2. <br /> tags have been ommitted. Padding and margins should be applied via css.
 * 3. Each product is enclosed in a <div> with a 'wpec-special-product' class.
 * 4. The product list is enclosed in a <div> with a 'wpec-special-products' class.
 * 5. Function now expect a single paramter with an array of options (used to be a string which prepended the output).
 */
function wpsc_specials($args = null, $instance)
{
    global $wpdb;
    $args = wp_parse_args((array) $args, array('number' => 5));
    $siteurl = get_option('siteurl');
    if (!($number = (int) $instance['number'])) {
        $number = 5;
    }
    $show_thumbnails = isset($instance['show_thumbnails']) ? (bool) $instance['show_thumbnails'] : FALSE;
    $show_description = isset($instance['show_description']) ? (bool) $instance['show_description'] : FALSE;
    $excludes = wpsc_specials_excludes();
    $args = array('post_type' => 'wpsc-product', 'caller_get_posts' => 1, 'post_status' => 'publish', 'post_parent' => 0, 'post__not_in' => $excludes, 'posts_per_page' => $number);
    $special_products = query_posts($args);
    $output = '';
    $product_ids[] = array();
    if (count($special_products) > 0) {
        list($wp_query, $special_products) = array($special_products, $wp_query);
        // swap the wpsc_query object
        while (wpsc_have_products()) {
            wpsc_the_product();
            if (!in_array(wpsc_the_product_id(), $product_ids)) {
                $product_ids[] = wpsc_the_product_id();
                if ($show_thumbnails) {
                    if (wpsc_the_product_thumbnail()) {
                        ?>
						<a rel="<?php 
                        echo str_replace(array(" ", '"', "'", '&quot;', '&#039;'), array("_", "", "", "", ''), wpsc_the_product_title());
                        ?>
" href="<?php 
                        echo wpsc_the_product_permalink();
                        ?>
">
							<img class="product_image" id="product_image_<?php 
                        echo wpsc_the_product_id();
                        ?>
" alt="<?php 
                        echo wpsc_the_product_title();
                        ?>
" title="<?php 
                        echo wpsc_the_product_title();
                        ?>
" src="<?php 
                        echo wpsc_the_product_thumbnail();
                        ?>
"/>
						</a>
				<?php 
                    } else {
                        ?>
							<a href="<?php 
                        echo wpsc_the_product_permalink();
                        ?>
">
							<img class="no-image" id="product_image_<?php 
                        echo wpsc_the_product_id();
                        ?>
" alt="No Image" title="<?php 
                        echo wpsc_the_product_title();
                        ?>
" src="<?php 
                        echo WPSC_URL;
                        ?>
/wpsc-theme/wpsc-images/noimage.png" width="<?php 
                        esc_attr_e(get_option('product_image_width'));
                        ?>
" height="<?php 
                        esc_attr_e(get_option('product_image_height'));
                        ?>
" />
							</a>
				<?php 
                    }
                    ?>
				<?php 
                }
                // close show thumbnails
                ?>
 
				<br />
				<span id="special_product_price_<?php 
                echo wpsc_the_product_id();
                ?>
">
				<!-- price display -->
				<?php 
                if (wpsc_have_variation_groups()) {
                    while (wpsc_have_variation_groups()) {
                        wpsc_the_variation_group();
                        ?>
								<?php 
                        /** the variation HTML and loop */
                        ?>
								<?php 
                        $variation_outputs = array();
                        ?>
								<?php 
                        while (wpsc_have_variations()) {
                            wpsc_the_variation();
                            ?>
										<?php 
                            $variation_outputs[] = '';
                            $variation_prices[] = wpsc_the_variation_price(true);
                        }
                        // Sort the variations into price order before outputting
                        $data[] = $variation_outputs;
                        $data[] = $variation_prices;
                        array_multisort($data[1], SORT_ASC, SORT_NUMERIC, $data[0], SORT_ASC, SORT_STRING);
                        ?>
						<?php 
                    }
                    echo __('From', 'wpsc') . ' : ' . wpsc_currency_display($data[1][0]);
                    ?>
				<?php 
                } else {
                    ?>
				<?php 
                    echo wpsc_currency_display(wpsc_calculate_price(wpsc_the_product_id(), null, true));
                    ?>
				
				<?php 
                }
                ?>
				</span><br />			
				<strong><a class="wpsc_product_title" href="<?php 
                echo wpsc_product_url(wpsc_the_product_id(), false);
                ?>
"><?php 
                echo wpsc_the_product_title();
                ?>
</a></strong><br /> 
				
				<?php 
                if ($show_description) {
                    ?>
					<div class="wpsc-special-description">
						<?php 
                    echo wpsc_the_product_description();
                    ?>
					</div>									
				<?php 
                }
                // close show description
                ?>
 
			
				<?php 
            }
        }
        list($wp_query, $special_products) = array($special_products, $wp_query);
        // swap the wpsc_query object
        wp_reset_query();
    }
}
Ejemplo n.º 21
0
function show_cats_brands($category_group = null, $display_method = null, $order_by = 'name', $image = null)
{
    global $wpdb;
    if ($category_group == null) {
        $category_group = $wpdb->get_var("SELECT `id` FROM `" . WPSC_TABLE_CATEGORISATION_GROUPS . "` WHERE `active` IN ('1') AND `default` IN ('1') LIMIT 1 ");
    } else {
        $category_group = (int) $category_group;
    }
    // Show cats & brands list if displaying on every page or if on a shop page (bit hacky but out of time).
    if (get_option('cat_brand_loc') != 3 && !function_exists("nzshpcrt_display_categories_groups") && $display_method != 'sidebar') {
        return;
    }
    if (get_option('permalink_structure') != '') {
        $seperator = "?";
    } else {
        $seperator = "&amp;";
    }
    $output = "<div class='PeSwitcher'>";
    switch (get_option('show_categorybrands')) {
        case 1:
            $output .= "<ul id='PeCatsBrandsBoth' class='category_brand_header'><li id='PeSwitcherFirst'><a href='' onclick='return prodgroupswitch(\"categories\");'>" . TXT_WPSC_CATEGORIES . "</a> | <a href='' onclick='return prodgroupswitch(\"brands\");'>" . TXT_WPSC_BRANDS . "</a></li></ul>";
            break;
    }
    $output .= "</div>";
    $output .= "<div class='PeCatsBrands'>";
    if (get_option('show_categorybrands') == 1 || get_option('show_categorybrands') == 2) {
        $output .= "<div class='PeCategories categorydisplay'>";
        $categories = $wpdb->get_results("SELECT * FROM `" . WPSC_TABLE_PRODUCT_CATEGORIES . "` WHERE `group_id` IN ('{$category_group}') AND `active`='1' AND `category_parent` = '0' ORDER BY `" . $wpdb->escape($order_by) . "` ASC", ARRAY_A);
        if ($categories != null) {
            $output .= "<ul class='PeCategories'>";
            foreach ($categories as $option) {
                // Adrian - check option for category count
                if (get_option('show_category_count') == 1) {
                    //show product count for each category
                    $count = $wpdb->get_var("SELECT COUNT(`p`.`id`) FROM `" . WPSC_TABLE_ITEM_CATEGORY_ASSOC . "` AS `a` JOIN `" . WPSC_TABLE_PRODUCT_LIST . "` AS `p` ON `a`.`product_id` = `p`.`id` WHERE `a`.`category_id` IN ('{$option['id']}') AND `p`.`active` IN ('1')");
                    $addCount = " (" . $count . ")";
                }
                //end get_option
                // No more mootools
                if (get_option('catsprods_display_type') == 1) {
                    $output .= "<li class='cat-item'><span class='category'><a class='productlink' href='" . wpsc_category_url($option['id']) . "'>" . stripslashes($option['name']) . "</a>" . $addCount . "</span>";
                } else {
                    // Adrian - otherwise create normal category text with or without product count
                    if (!$image) {
                        $output .= "<li class='cat-item'><span class='category'><a class='productlink' href='" . wpsc_category_url($option['id']) . "'>" . stripslashes($option['name']) . "</a>" . $addCount . "</span>";
                    } else {
                        $output .= "<li class='cat-item'><img src='" . WPSC_CATEGORY_URL . $option['image'] . "'><br><span class='category'><a class='productlink' href='" . wpsc_category_url($option['id']) . "'>" . stripslashes($option['name']) . "</a>" . $addCount . "</span>";
                    }
                }
                //end get_option
                $subcategory_sql = "SELECT * FROM `" . WPSC_TABLE_PRODUCT_CATEGORIES . "` WHERE `group_id` IN ('{$category_group}') AND `active`='1' AND `category_parent` = '" . $option['id'] . "' ORDER BY `id`";
                $subcategories = $wpdb->get_results($subcategory_sql, ARRAY_A);
                if ($subcategories != null) {
                    $output .= display_subcategories($option['id']);
                } else {
                    // Adrian - check if the user wants categories only or sliding categories
                    if (get_option('permalink_structure') != '') {
                        $uri = $_SERVER['REQUEST_URI'];
                        $category = explode('/', $uri);
                        $count = count($category);
                        $category_nice_name = $category[$count - 2];
                        $category_nice_name2 = $wpdb->get_var("SELECT `nice-name` FROM " . WPSC_TABLE_PRODUCT_CATEGORIES . " WHERE id='{$option['id']}'");
                        if ($category_nice_name == $category_nice_name2) {
                            $list_product = true;
                        } else {
                            $list_product = false;
                        }
                    }
                    if (get_option('catsprods_display_type') == 1 && ($option['id'] == $_GET['category'] || $list_product)) {
                        // Adrian - display all products for that category
                        $product_sql = "SELECT product_id FROM `" . WPSC_TABLE_ITEM_CATEGORY_ASSOC . "` WHERE `category_id` = '" . $option['id'] . "'";
                        $productIDs = $wpdb->get_results($product_sql, ARRAY_A);
                        if ($productIDs != null) {
                            $output .= "<ul class='category-product-list'>";
                            foreach ($productIDs as $productID) {
                                $ID = $productID['product_id'];
                                $productName_sql = "SELECT * FROM `" . WPSC_TABLE_PRODUCT_LIST . "` WHERE `id` = '" . $ID . "'";
                                $productName = $wpdb->get_results($productName_sql, ARRAY_A);
                                if ($productName[0]['active']) {
                                    $output .= "<li class='cat-item'><a class='productlink' href='" . wpsc_product_url($ID, $option['id']) . "'>" . $productName[0]['name'] . "</a></li>";
                                }
                            }
                            //end foreach
                            $output .= "</ul>";
                        }
                        //end if productsIDs
                    }
                    //end if get_option
                }
                //end else
                $output .= "</li>";
            }
            $output .= "</ul>";
        }
        $output .= "</div>";
    }
    if (get_option('show_categorybrands') == 1 || get_option('show_categorybrands') == 3) {
        if (get_option('show_categorybrands') == 1) {
            $output .= "<ul class='PeBrands branddisplay' style='display: none;'>";
        } else {
            $output .= "<ul class='PeBrands branddisplay'>";
        }
        //$output ='';
        $brands = $wpdb->get_results("SELECT * FROM `" . $wpdb->prefix . "product_brands` WHERE `active`='1' ORDER BY `order` ASC", ARRAY_A);
        if ($brands != null) {
            foreach ($brands as $option) {
                $output .= "<li><a class='categorylink' href='" . get_option('product_list_url') . $seperator . "brand=" . $option['id'] . "'>" . stripslashes($option['name']) . "</a></li>";
            }
        }
        //$output .= $output;
        $output .= "</ul>";
    }
    $output .= "</div>";
    echo $output;
}
function wpsc_product_basic_details_form(&$product_data)
{
    global $wpdb, $nzshpcrt_imagesize_info;
    /*<h3 class='hndle'><?php echo  __('Product Details', 'wpsc'); ?> <?php echo __('(enter in your product details here)', 'wpsc'); ?></h3>*/
    ?>
  <h3 class='form_heading'>
 <?php 
    if ($product_data['id'] > 0) {
        echo __('Edit Product', 'wpsc') . " <span>(<a href='" . add_query_arg('page', 'wpsc-edit-products', remove_query_arg('product_id', 'admin.php')) . "'>" . __('Add Product', 'wpsc') . "</a>)</span>";
    } else {
        echo __('Add Product', 'wpsc');
    }
    ?>
	</h3>
	<div>
		<table class='product_editform' >
			<tr>
				<td colspan='2' class='itemfirstcol'>  
				<div style='width:470px'>
					<label for="wpsc_product_name"><?php 
    echo __('Product Name', 'wpsc');
    ?>
</label>
					<div class='admin_product_name'>
						<input id='wpsc_product_name' class='wpsc_product_name text' size='15' type='text' name='title' value='<?php 
    echo htmlentities(stripslashes($product_data['name']), ENT_QUOTES, 'UTF-8');
    ?>
' />
						<a href='#' class='shorttag_toggle'></a>
					</div>
					<div class='admin_product_shorttags'>
						<h4>Shortcodes</h4>
	
						<dl>
							<dt><?php 
    echo __('Display Product Shortcode', 'wpsc');
    ?>
: </dt><dd>[wpsc_products product_id='<?php 
    echo $product_data['id'];
    ?>
']</dd>
							<dt><?php 
    echo __('Buy Now Shortcode', 'wpsc');
    ?>
: </dt><dd>[buy_now_button=<?php 
    echo $product_data['id'];
    ?>
]</dd>
							<dt><?php 
    echo __('Add to Cart Shortcode', 'wpsc');
    ?>
: </dt><dd>[add_to_cart=<?php 
    echo $product_data['id'];
    ?>
]</dd>
						</dl>

						<h4>Template Tags</h4>

						<dl>
							<dt><?php 
    echo __('Display Product Template Tag', 'wpsc');
    ?>
: </dt><dd> &lt;?php echo wpsc_display_products('product_id=<?php 
    echo $product_data['id'];
    ?>
'); ?&gt;</dd>
							<dt><?php 
    echo __('Buy Now PHP', 'wpsc');
    ?>
: </dt><dd>&lt;?php echo wpsc_buy_now_button(<?php 
    echo $product_data['id'];
    ?>
); ?&gt;</dd>
							<dt><?php 
    echo __('Add to Cart PHP', 'wpsc');
    ?>
: </dt><dd>&lt;?php echo wpsc_add_to_cart_button(<?php 
    echo $product_data['id'];
    ?>
); ?&gt;</dd>
							<dt><?php 
    echo __('Display Product SKU', 'wpsc');
    ?>
: </dt><dd>&lt;?php echo wpsc_product_sku(<?php 
    echo $product_data['id'];
    ?>
); ?&gt;</dd>
						</dl>
						
						<?php 
    if ($product_data['id'] > 0) {
        ?>
							<p><a href="<?php 
        echo wpsc_product_url($product_data['id']);
        ?>
" target="_blank" class="button">View product</a></p>
						<?php 
    }
    ?>
						
					</div>
					</div>
					<div style='clear:both; height: 0px; margin-bottom: 15px;'></div>	
				</td>
			</tr>
		
		
			<tr>
				<td colspan='3' class='skuandprice'>
					<div class='wpsc_floatleft'>
					<?php 
    echo __('Stock Keeping Unit', 'wpsc');
    ?>
 :<br />
					<input size='17' type='text' class='text'  name='productmeta_values[sku]' value='<?php 
    echo htmlentities(stripslashes($product_data['meta']['sku']), ENT_QUOTES, 'UTF-8');
    ?>
' />
					</div>
					<div class='wpsc_floatleft'>
					<?php 
    echo __('Price', 'wpsc');
    ?>
 :<br />
					<input type='text' class='text' size='17' name='price' value='<?php 
    echo $product_data['price'];
    ?>
' />
					</div>
					<div class='wpsc_floatleft'>
    			   <label for='add_form_special'><?php 
    echo __('Sale Price :', 'wpsc');
    ?>
</label>
			       <div style='display:<?php 
    if ($product_data['special'] == 1 ? 'block' : 'none') {
    }
    ?>
' id='add_special'>
								<?php 
    if (is_numeric($product_data['special_price'])) {
        $special_price = number_format($product_data['price'] - $product_data['special_price'], 2);
    }
    /*
    if(0 == $product_data['special_price']){
    									$special_price = number_format(( $product_data['special_price']), 2);
    
    								}
    */
    ?>
        			  <input type='text' size='17' value='<?php 
    echo $special_price;
    ?>
' name='special_price'/>
			       </div>
			       </div>

      			</td>
    
	
			</tr>
		
			<tr>
				<td ><a href='' class='wpsc_add_new_currency'>+ <?php 
    echo __('New Currency', 'wpsc');
    ?>
</a></td>
			</tr>
			<tr class='new_layer'>
					<td>
						<label for='newCurrency[]'><?php 
    echo __('Currency type', 'wpsc');
    ?>
:</label><br />
						<select name='newCurrency[]' class='newCurrency'>
						<?php 
    $currency_data = $wpdb->get_results("SELECT * FROM `" . WPSC_TABLE_CURRENCY_LIST . "` ORDER BY `country` ASC", ARRAY_A);
    foreach ((array) $currency_data as $currency) {
        if ($isocode == $currency['isocode']) {
            $selected = "selected='selected'";
        } else {
            $selected = "";
        }
        ?>
							<option value='<?php 
        echo $currency['id'];
        ?>
' <?php 
        echo $selected;
        ?>
 ><?php 
        echo htmlspecialchars($currency['country']);
        ?>
 (<?php 
        echo $currency['currency'];
        ?>
)</option>
				<?php 
    }
    $currency_data = $wpdb->get_row("SELECT `symbol`,`symbol_html`,`code` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `id`='" . get_option('currency_type') . "' LIMIT 1", ARRAY_A);
    if ($currency_data['symbol'] != '') {
        $currency_sign = $currency_data['symbol_html'];
    } else {
        $currency_sign = $currency_data['code'];
    }
    ?>
						</select>
						</td>
						<td>
						<?php 
    echo __('Price', 'wpsc');
    ?>
 :<br />
						<input type='text' class='text' size='15' name='newCurrPrice[]' value='0.00' />
						<a href='' class='deletelayer' rel='<?php 
    echo $isocode;
    ?>
'><?php 
    echo __('Delete Currency', 'wpsc');
    ?>
</a>
						</td>

			</tr>
			<?php 
    if (count($product_data['newCurr']) > 0) {
        $i = 0;
        foreach ($product_data['newCurr'] as $newCurr) {
            $i++;
            $isocode = str_replace("currency[", "", $newCurr['meta_key']);
            $isocode = str_replace("]", "", $isocode);
            //	exit('ere<pre>'.print_r($isocode, true).'</pre>');
            ?>
					<tr>
						<td>
						<label for='newCurrency[]'><?php 
            echo __('Currency type', 'wpsc');
            ?>
:</label><br />
						<select name='newCurrency[]' class='newCurrency'>
						<?php 
            $currency_data = $wpdb->get_results("SELECT * FROM `" . WPSC_TABLE_CURRENCY_LIST . "` ORDER BY `country` ASC", ARRAY_A);
            foreach ($currency_data as $currency) {
                if ($isocode == $currency['isocode']) {
                    $selected = "selected='selected'";
                } else {
                    $selected = "";
                }
                ?>
							<option value='<?php 
                echo $currency['id'];
                ?>
' <?php 
                echo $selected;
                ?>
 ><?php 
                echo htmlspecialchars($currency['country']);
                ?>
 (<?php 
                echo $currency['currency'];
                ?>
)</option>
				<?php 
            }
            $currency_data = $wpdb->get_row("SELECT `symbol`,`symbol_html`,`code` FROM `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `id`='" . get_option('currency_type') . "' LIMIT 1", ARRAY_A);
            if ($currency_data['symbol'] != '') {
                $currency_sign = $currency_data['symbol_html'];
            } else {
                $currency_sign = $currency_data['code'];
            }
            ?>
						</select>
						</td>
						<td>
						Price<?php 
            //echo __('Price', 'wpsc');
            ?>
 :<br />
						<input type='text' class='text' size='15' name='newCurrPrice[]' value='<?php 
            echo $newCurr['meta_value'];
            ?>
' />
						<a href='' class='wpsc_delete_currency_layer' rel='<?php 
            echo $isocode;
            ?>
'><?php 
            echo __('Delete Currency', 'wpsc');
            ?>
</a>
						</td>
					</tr>
			<?php 
        }
        ?>
			<?php 
    }
    ?>
			<tr>
				<td colspan='2'>
					<div id="<?php 
    echo user_can_richedit() ? 'postdivrich' : 'postdiv';
    ?>
" class="postarea" >
				 <?php 
    wpsc_the_editor($product_data['description'], 'content', false, false);
    ?>
				 </div>
				</td>
			</tr>
		
			<tr>
				<td class='itemfirstcol' colspan='2'>
					
					<strong ><?php 
    echo __('Additional Description', 'wpsc');
    ?>
 :</strong><br />			
					
					<textarea name='additional_description' id='additional_description' cols='40' rows='5' ><?php 
    echo stripslashes($product_data['additional_description']);
    ?>
</textarea>
				</td>
			</tr>
		</table>
	</div>
	<div class='meta-box-sortables'>
		<?php 
    $default_order = array("wpsc_product_category_and_tag_forms", "wpsc_product_price_and_stock_forms", "wpsc_product_shipping_forms", "wpsc_product_variation_forms", "wpsc_product_advanced_forms", "wpsc_product_image_forms", "wpsc_product_download_forms");
    $order = apply_filters('wpsc_products_page_forms', get_option('wpsc_product_page_order'));
    //echo "<pre>".print_r($order,true)."</pre>";
    if ($order == '' || count($order) < 6) {
        $order = $default_order;
    }
    $check_missing_items = array_diff($default_order, $order);
    if (count($check_missing_items) > 0) {
        $order = array_merge($check_missing_items, $order);
    }
    update_option('wpsc_product_page_order', $order);
    foreach ((array) $order as $key => $box_function_name) {
        if (function_exists($box_function_name)) {
            echo call_user_func(apply_filters('wpsc_product_page_order_form_name', $box_function_name), $product_data);
        }
    }
    ?>
	</div>

	<input type='hidden' name='product_id' id='product_id' value='<?php 
    echo $product_data['id'];
    ?>
' />
	<input type='hidden' name='wpsc_admin_action' value='edit_product' />
	<?php 
    wp_nonce_field('edit-product', 'wpsc-edit-product');
    ?>
	<input type='hidden' name='submit_action' value='edit' />
	<?php 
    wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
    ?>
	 
	
	<input class='button-primary' style='float:left;'  type='submit' name='submit' value='<?php 
    if ($product_data['id'] > 0) {
        _e('Update Product', 'wpsc');
    } else {
        _e('Add New Product', 'wpsc');
    }
    ?>
' />&nbsp;
	<a class='submitdelete delete_button' title='<?php 
    echo attribute_escape(__('Delete this product'));
    ?>
' href='<?php 
    echo wp_nonce_url("page.php?wpsc_admin_action=delete_product&amp;product={$product_data['id']}", 'delete_product_' . $product_data['id']);
    ?>
' onclick="if ( confirm(' <?php 
    echo js_escape(sprintf(__("You are about to delete this product '%s'\n 'Cancel' to stop, 'OK' to delete."), $product_data['name']));
    ?>
') ) { return true;}return false;"><?php 
    _e('Delete');
    ?>
</a>
	<?php 
}
Ejemplo n.º 23
0
function wpsc_generate_product_feed()
{
    global $wpdb, $wp_query, $post;
    // Don't cache feed under WP Super-Cache
    define('DONOTCACHEPAGE', TRUE);
    $siteurl = get_option('siteurl');
    // Allow limiting
    if (isset($_GET['limit']) && is_numeric($_GET['limit'])) {
        $limit = "LIMIT " . $_GET['limit'] . "";
    } else {
        $limit = '';
    }
    $selected_category = '';
    $selected_product = '';
    if (isset($_GET['product_id']) && is_numeric($_GET['product_id'])) {
        $args[] = array('post__in' => $_GET['product_id']);
    } elseif (isset($_GET['category_id']) && is_numeric($_GET['category_id'])) {
        $args[] = array('cat' => $_GET['category_id']);
    }
    $args['post_type'] = 'wpsc-product';
    $args['posts_per_page'] = 999;
    $products = query_posts($args);
    $self = get_option('siteurl') . "/index.php?rss=true&amp;action=product_list{$selected_category}{$selected_product}";
    header("Content-Type: application/xml; charset=UTF-8");
    header('Content-Disposition: inline; filename="E-Commerce_Product_List.rss"');
    $output = "<?xml version='1.0' encoding='UTF-8' ?>\n\r";
    $output .= "<rss version='2.0' xmlns:atom='http://www.w3.org/2005/Atom'";
    $google_checkout_note = FALSE;
    if ($_GET['xmlformat'] == 'google') {
        $output .= ' xmlns:g="http://base.google.com/ns/1.0"';
        // Is Google Checkout available as a payment gateway
        $selected_gateways = get_option('custom_gateway_options');
        if (in_array('google', $selected_gateways)) {
            $google_checkout_note = TRUE;
        }
    } else {
        $output .= ' xmlns:product="http://www.buy.com/rss/module/productV2/"';
    }
    $output .= ">\n\r";
    $output .= "  <channel>\n\r";
    $output .= "    <title><![CDATA[" . get_option('blogname') . " Products]]></title>\n\r";
    $output .= "    <link>" . get_option('siteurl') . "/wp-admin/admin.php?page=" . WPSC_DIR_NAME . "/display-log.php</link>\n\r";
    $output .= "    <description>This is the WP e-Commerce Product List RSS feed</description>\n\r";
    $output .= "    <generator>WP e-Commerce Plugin</generator>\n\r";
    $output .= "    <atom:link href='{$self}' rel='self' type='application/rss+xml' />\n\r";
    foreach ($products as $post) {
        setup_postdata($post);
        $purchase_link = wpsc_product_url($post->ID);
        $output .= "    <item>\n\r";
        if ($google_checkout_note) {
            $output .= "      <g:payment_notes>Google Checkout</g:payment_notes>\n\r";
        }
        $output .= "      <title><![CDATA[" . get_the_title() . "]]></title>\n\r";
        $output .= "      <link>{$purchase_link}</link>\n\r";
        $output .= "      <description><![CDATA[" . get_the_content() . "]]></description>\n\r";
        $output .= "      <pubDate>" . $post->post_modified_gmt . "</pubDate>\n\r";
        $output .= "      <guid>{$purchase_link}</guid>\n\r";
        $image_link = FALSE;
        if (has_post_thumbnail($post->ID)) {
            $post_thumbnail_id = get_post_thumbnail_id($post->ID);
            $src = wp_get_attachment_image_src($post_thumbnail_id, 'large');
            $image_link = $src[0];
        }
        if ($image_link !== FALSE) {
            if ($_GET['xmlformat'] == 'google') {
                $output .= "      <g:image_link>{$image_link}</g:image_link>\n\r";
            } else {
                $output .= "      <enclosure url='{$image_link}' />\n\r";
            }
        }
        $price = wpsc_calculate_price($post->ID);
        $children = get_children(array('post_parent' => $post->ID, 'post_type' => 'wpsc-product'));
        foreach ($children as $child) {
            $child_price = wpsc_calculate_price($child->ID);
            if ($price == 0 && $child_price > 0) {
                $price = $child_price;
            } else {
                if ($child_price > 0 && $child_price < $price) {
                    $price = $child_price;
                }
            }
        }
        if ($_GET['xmlformat'] == 'google') {
            $output .= "      <g:price>" . $price . "</g:price>\n\r";
            $product_meta = get_post_meta($post->ID, '_wpsc_product_metadata', true);
            foreach (array_keys($product_meta) as $meta_key) {
                if (stripos($meta_key, 'g:') === 0) {
                    $google_elements[$meta_key] = $product_meta[$meta_key];
                }
            }
            $google_elements = apply_filters('wpsc_google_elements', array('product_id' => $product['id'], 'elements' => $google_elements));
            $google_elements = $google_elements['elements'];
            $done_condition = FALSE;
            if (count($google_elements)) {
                foreach ($google_elements as $gelement) {
                    $output .= "      <" . $gelement['meta_key'] . ">";
                    $output .= "<![CDATA[" . $gelement['meta_value'] . "]]>";
                    $output .= "</" . $gelement['meta_key'] . ">\n\r";
                    if ($gelement['meta_key'] == 'g:condition') {
                        $done_condition = TRUE;
                    }
                }
            }
            if (!$done_condition) {
                $output .= "      <g:condition>new</g:condition>\n\r";
            }
        } else {
            $output .= "      <product:price>" . $price . "</product:price>\n\r";
        }
        $output .= "    </item>\n\r";
    }
    $output .= "  </channel>\n\r";
    $output .= "</rss>";
    echo $output;
    exit;
}
Ejemplo n.º 24
0
function wpsc_admin_products_list($category_id = 0)
{
    global $wpdb, $_wp_column_headers;
    // set is_sortable to false to start with
    $is_sortable = false;
    $page = null;
    $search_input = '';
    if ($_GET['search']) {
        $search_input = stripslashes($_GET['search']);
        $search_string = "%" . $wpdb->escape($search_input) . "%";
        $search_sql = "AND (`products`.`name` LIKE '" . $search_string . "' OR `products`.`description` LIKE '" . $search_string . "')";
    } else {
        $search_sql = '';
    }
    $search_sql = apply_filters('wpsc_admin_products_list_search_sql', $search_sql);
    if ($category_id > 0) {
        // if we are getting items from only one category, this is a monster SQL query to do this with the product order
        $sql = "SELECT `products`.`id` , `products`.`name` , `products`.`price` , `products`.`image`,`products`.`weight` , `products`.`publish`, `categories`.`category_id`,`order`.`order`, IF(ISNULL(`order`.`order`), 0, 1) AS `order_state`\r\n\t\t\tFROM `" . WPSC_TABLE_PRODUCT_LIST . "` AS `products`\r\n\t\t\tLEFT JOIN `" . WPSC_TABLE_ITEM_CATEGORY_ASSOC . "` AS `categories` ON `products`.`id` = `categories`.`product_id` \r\n\t\t\tLEFT JOIN `" . WPSC_TABLE_PRODUCT_ORDER . "` AS `order` ON ( \r\n\t\t\t\t(\t`products`.`id` = `order`.`product_id` )\r\n\t\t\tAND \r\n\t\t\t\t( `categories`.`category_id` = `order`.`category_id` )\r\n\t\t\t)\r\n\t\t\tWHERE `products`.`active` = '1' {$search_sql}\r\n\t\t\tAND `categories`.`category_id` \r\n\t\t\tIN (\r\n\t\t\t'" . $category_id . "'\r\n\t\t\t)\r\n\t\t\tORDER BY `order_state` DESC,`order`.`order` ASC,  `products`.`date_added` DESC,  `products`.`id` DESC";
        // if we are selecting a category, set is_sortable to true
        $is_sortable = true;
    } else {
        $itempp = 10;
        if ($_GET['pageno'] != 'all') {
            if ($_GET['pageno'] > 0) {
                $page = absint($_GET['pageno']);
            } else {
                $page = 1;
            }
            $start = (int) ($page * $itempp) - $itempp;
            $sql = "SELECT DISTINCT * FROM `" . WPSC_TABLE_PRODUCT_LIST . "` AS `products` WHERE `products`.`active`='1' {$search_sql} ORDER BY `products`.`date_added` DESC LIMIT {$start},{$itempp}";
            if (get_option('wpsc_sort_by') == 'dragndrop') {
                $sql = "SELECT DISTINCT * FROM `" . WPSC_TABLE_PRODUCT_LIST . "` AS `products` LEFT JOIN `" . WPSC_TABLE_PRODUCT_ORDER . "` AS `order` ON `products`.`id`= `order`.`product_id` WHERE `products`.`active`='1' AND `order`.`category_id`='0' {$search_sql} ORDER BY `order`.`order`";
            }
        } else {
            $sql = "SELECT DISTINCT * FROM `" . WPSC_TABLE_PRODUCT_LIST . "` AS `products` WHERE `products`.`active`='1' {$search_sql} ORDER BY `products`.`date_added`";
        }
    }
    //	exit($sql);
    $product_list = $wpdb->get_results($sql, ARRAY_A);
    //exit('<pre>'.print_r($product_list, true).'</pre>');
    $num_products = $wpdb->get_var("SELECT COUNT(DISTINCT `products`.`id`) FROM `" . WPSC_TABLE_PRODUCT_LIST . "` AS `products` WHERE `products`.`active`='1' {$search_sql}");
    if (isset($itempp)) {
        $num_pages = ceil($num_products / $itempp);
    }
    if ($page !== null) {
        $page_links = paginate_links(array('base' => add_query_arg('pageno', '%#%'), 'format' => '', 'prev_text' => __('&laquo;'), 'next_text' => __('&raquo;'), 'total' => $num_pages, 'current' => $page));
    }
    $this_page_url = stripslashes($_SERVER['REQUEST_URI']);
    ?>
	<div class="wpsc-separator"><br/></div>
	
	<div class="tablenav">
		
		
		
		
		<?php 
    if (get_option('wpsc_sort_by') != 'dragndrop') {
        ?>
		<div class="tablenav-pages">
			<?php 
        echo $page_links;
        ?>
	
		</div>
		<?php 
    }
    ?>
		
		<div class="alignleft actions">
			<form action="admin.php" method="get">
				<?php 
    echo wpsc_admin_category_dropdown();
    ?>
			</form>
		</div>	
	</div>
	
	
	<form id="posts-filter" action="" method="get">
		<div class="tablenav">	
			<div class="alignright search-box">
				<input type='hidden' name='page' value='wpsc-edit-products'  />
				<input type="text" class="search-input" id="page-search-input" name="search" value="<?php 
    echo $search_input;
    ?>
" />
				<input type="submit" name='wpsc_search' value="<?php 
    _e('Search');
    ?>
" class="button" />
			</div>
		
			<div class="alignleft actions">
					<select name="bulkAction">
						<option value="-1" selected="selected"><?php 
    _e('Bulk Actions');
    ?>
</option>
						<option value="delete"><?php 
    _e('Delete');
    ?>
</option>
						<option value="show"><?php 
    _e('Publish');
    ?>
</option>
						<option value="hide"><?php 
    _e('Draft');
    ?>
</option>

					</select>
					<input type='hidden' name='wpsc_admin_action' value='bulk_modify' />
					<input type="submit" value="<?php 
    _e('Apply');
    ?>
" name="doaction" id="doaction" class="button-secondary action" />
					<?php 
    wp_nonce_field('bulk-products', 'wpsc-bulk-products');
    ?>
			</div>
		</div>
	
		<input type='hidden' id='products_page_category_id'  name='category_id' value='<?php 
    echo $category_id;
    ?>
' />
		<table class="widefat page fixed" id='wpsc_product_list' cellspacing="0">
			<thead>
				<tr>
					<?php 
    print_column_headers('display-product-list');
    ?>
				</tr>
			</thead>
		
			<tfoot>
				<tr>
					<?php 
    print_column_headers('display-product-list', false);
    ?>
				</tr>
			</tfoot>
		
			<tbody>
				<?php 
    if (count($product_list) > 0) {
        foreach ((array) $product_list as $product) {
            //first set the patch to the default
            $image_path = WPSC_URL . "/images/no-image-uploaded.gif";
            if (is_numeric($product['image'])) {
                // check for automatic thumbnail images
                // file_exists(WPSC_THUMBNAIL_DIR.$product['image'])
                $product_image = $wpdb->get_var("SELECT `image` FROM  `" . WPSC_TABLE_PRODUCT_IMAGES . "` WHERE `id` = '{$product['image']}' LIMIT 1");
                // if the image exists, set the image path to it.
                if ($product_image != null && file_exists(WPSC_THUMBNAIL_DIR . $product_image)) {
                    $image_path = WPSC_THUMBNAIL_URL . $product_image;
                }
            }
            // get the  product name, unless there is no name, in which case, display text indicating so
            if ($product['name'] == '') {
                $product_name = "(" . __('No Name', 'wpsc') . ")";
            } else {
                $product_name = htmlentities(stripslashes($product['name']), ENT_QUOTES, 'UTF-8');
            }
            $category_html = '';
            if (get_option('wpsc_sort_by') != 'dragndrop') {
                $category_list = $wpdb->get_results("SELECT `" . WPSC_TABLE_PRODUCT_CATEGORIES . "`.`id`,`" . WPSC_TABLE_PRODUCT_CATEGORIES . "`.`name` FROM `" . WPSC_TABLE_ITEM_CATEGORY_ASSOC . "` , `" . WPSC_TABLE_PRODUCT_CATEGORIES . "` WHERE `" . WPSC_TABLE_ITEM_CATEGORY_ASSOC . "`.`product_id` IN ('" . $product['id'] . "') AND `" . WPSC_TABLE_ITEM_CATEGORY_ASSOC . "`.`category_id` = `" . WPSC_TABLE_PRODUCT_CATEGORIES . "`.`id` AND `" . WPSC_TABLE_PRODUCT_CATEGORIES . "`.`active` IN('1')", ARRAY_A);
            } else {
                $category_list = $wpdb->get_results("SELECT `" . WPSC_TABLE_PRODUCT_CATEGORIES . "`.`id`,`" . WPSC_TABLE_PRODUCT_CATEGORIES . "`.`name` FROM `" . WPSC_TABLE_PRODUCT_CATEGORIES . "` LEFT JOIN `" . WPSC_TABLE_ITEM_CATEGORY_ASSOC . "` ON `" . WPSC_TABLE_ITEM_CATEGORY_ASSOC . "`.`category_id`= `" . WPSC_TABLE_PRODUCT_CATEGORIES . "`.`id` WHERE `" . WPSC_TABLE_ITEM_CATEGORY_ASSOC . "`.`product_id` IN ('" . $product['product_id'] . "')  AND `" . WPSC_TABLE_PRODUCT_CATEGORIES . "`.`active` IN('1')", ARRAY_A);
            }
            $i = 0;
            foreach ((array) $category_list as $category_row) {
                if ($i > 0) {
                    $category_html .= "<br />";
                }
                $category_html .= "<a class='category_link' href='" . htmlentities(remove_query_arg('product_id', add_query_arg('category_id', $category_row['id']))) . "'>" . stripslashes($category_row['name']) . "</a>";
                $i++;
            }
            if (get_option('wpsc_sort_by') == 'dragndrop') {
                $product['id'] = $product['product_id'];
            }
            ?>
							<tr class="product-edit <?php 
            echo wpsc_publish_status($product['id']) ? ' wpsc_published' : ' wpsc_not_published';
            ?>
" id="product-<?php 
            echo $product['id'];
            ?>
" >
									<th class="check-column" scope="row">
										<input type='checkbox' name='product[]' class='deletecheckbox' value='<?php 
            echo $product['id'];
            ?>
' title="ID #<?php 
            echo $product['id'];
            ?>
" />
										<?php 
            echo do_action('wpsc_admin_product_checkbox', $product['id']);
            ?>
									</th>
									
									
									<td class="product-image ">
										<img title='Drag to a new position' src='<?php 
            echo $image_path;
            ?>
' alt='<?php 
            echo $product['name'];
            ?>
' width='38' height='38' />
									</td>
									<td class="product-title column-title">
									  <?php 
            $edit_product_url = wp_nonce_url(htmlentities(add_query_arg('product_id', $product['id'])), 'edit_product_' . $product['id']);
            ?>
										<a class='edit-product' href='<?php 
            echo $edit_product_url;
            ?>
' title="ID #<?php 
            echo $product['id'];
            ?>
: <?php 
            echo $product_name;
            ?>
"><?php 
            echo $product_name;
            ?>
</a>
											<?php 
            if ($product['publish'] != 1) {
                ?>
 - <strong> <?php 
                _e('Draft', 'wpsc');
                ?>
	</strong>	<?php 
            }
            ?>
											<?php 
            $product_alert = apply_filters('wpsc_product_alert', array(false, ''), $product);
            if (count($product_alert['messages']) > 0) {
                $product_alert['messages'] = implode("\n", (array) $product_alert['messages']);
            }
            if ($product_alert['state'] === true) {
                ?>
												<img alt='<?php 
                echo $product_alert['messages'];
                ?>
' title='<?php 
                echo $product_alert['messages'];
                ?>
' class='product-alert-image' src='<?php 
                echo WPSC_URL;
                ?>
/images/product-alert.jpg' alt='' />
												<?php 
            }
            // If a product alert has stuff to display, show it.
            // Can be used to add extra icons etc
            if (!empty($product_alert['display'])) {
                echo $product_alert['display'];
            }
            ?>
											<img class='loadingImg' style='display:none;' src='<?php 
            echo get_option('siteurl');
            ?>
/wp-admin/images/wpspin_light.gif' alt='loading' />
									
									
										<div class="wpsc-row-actions">
											<span class="edit">
												<a class='edit-product' title="Edit this post" href='<?php 
            echo $edit_product_url;
            ?>
' style="cursor:pointer;">Edit</a>
											</span>
											 |
											<span class="delete">
												<a class='submitdelete delete_button'
													title='<?php 
            echo attribute_escape(__('Delete this product', 'wpsc'));
            ?>
'
													href='<?php 
            echo wp_nonce_url("admin.php?wpsc_admin_action=delete_product&amp;product={$product['id']}", 'delete_product_' . $product['id']);
            ?>
'
													onclick="if ( confirm(' <?php 
            echo js_escape(sprintf(__("You are about to delete this product '%s'\n 'Cancel' to stop, 'OK' to delete."), $product['name']));
            ?>
') ) { return true;}return false;"
													>
													<?php 
            _e('Delete');
            ?>
												</a>
											</span>
											 |
											<span class="view">
												<a target="_blank" rel="permalink" title='View <?php 
            echo $product_name;
            ?>
' href="<?php 
            echo wpsc_product_url($product['id']);
            ?>
">View</a>
											</span>
											|
											<span class="view">
												<a rel="permalink"
													title='Duplicate <?php 
            echo $product_name;
            ?>
'
													href="<?php 
            echo wp_nonce_url("admin.php?wpsc_admin_action=duplicate_product&amp;product={$product['id']}", 'duplicate_product_' . $product['id']);
            ?>
													">
													Duplicate
												</a>
											</span>
											|
											<span class="publish_toggle">
												<a title="Change publish status"
													href="<?php 
            echo wp_nonce_url("admin.php?wpsc_admin_action=toggle_publish&product=" . $product['id'], 'toggle_publish_' . $product['id']);
            ?>
"
													>
													<?php 
            if ($product['publish'] == 1) {
                _e('Unpublish', 'wpsc');
            } else {
                _e('Publish', 'wpsc');
            }
            ?>
												</a>
											</span>
										</div>
									</td>
									
									<td class="product-price column-price">

									<?php 
            echo nzshpcrt_currency_display($product['price'], 1);
            ?>
									<div class='price-editing-fields' id='price-editing-fields-<?php 
            echo $product['id'];
            ?>
'>
										<input type='text' class='the-product-price' name='product_price[<?php 
            echo $product['id'];
            ?>
][price]' value='<?php 
            echo number_format($product['price'], 2, '.', '');
            ?>
' />
										<input type='hidden' name='product_price[<?php 
            echo $product['id'];
            ?>
][id]' value='<?php 
            echo $product['id'];
            ?>
' />
										<input type='hidden' name='product_price[<?php 
            echo $product['id'];
            ?>
][nonce]' value='<?php 
            echo wp_create_nonce('edit-product_price-' . $product['id']);
            ?>
' />
										
									
									</div>
									</td>
									<td class="column-categories"><?php 
            echo $category_html;
            ?>
</td>
							</tr>
						<?php 
        }
    } else {
        ?>
				<tr>
					<td colspan='5'>
					  <?php 
        _e("You have no products added.");
        ?>
					</td>
				</tr>
				<?php 
    }
    ?>
			
			</tbody>
		</table>
	</form>
	<?php 
}
Ejemplo n.º 25
0
function nszhpcrt_category_tag($content = '')
{
    require_once 'themes/iShop/iShop.php';
    global $wpdb;
    if (preg_match_all("/\\[wpsc_category_exclude=([\\d]+),*(full)?\\]/", $content, $matches)) {
        foreach ($matches[1] as $key => $category_id) {
            $categories[$key]['id'] = $category_id;
            $categories[$key]['display'] = $matches[2][$key];
            $categories[$key]['original_string'] = $matches[0][$key];
        }
        foreach ($categories as $category) {
            $sql1 = "SELECT DISTINCT `" . $wpdb->prefix . "product_list`.*, `" . $wpdb->prefix . "item_category_associations`.`category_id`,`" . $wpdb->prefix . "product_order`.`order`, IF(ISNULL(`" . $wpdb->prefix . "product_order`.`order`), 0, 1) AS `order_state` FROM `" . $wpdb->prefix . "product_list` LEFT JOIN `" . $wpdb->prefix . "item_category_associations` ON `" . $wpdb->prefix . "product_list`.`id` = `" . $wpdb->prefix . "item_category_associations`.`product_id` LEFT JOIN `" . $wpdb->prefix . "product_order` ON ( ( `" . $wpdb->prefix . "product_list`.`id` = `" . $wpdb->prefix . "product_order`.`product_id` ) AND ( `" . $wpdb->prefix . "item_category_associations`.`category_id` = `" . $wpdb->prefix . "product_order`.`category_id` ) ) WHERE `" . $wpdb->prefix . "product_list`.`active` = '1' AND `" . $wpdb->prefix . "item_category_associations`.`category_id` NOT IN ('" . $category['id'] . "') {$no_donations_sql} ORDER BY `order_state` DESC,`" . $wpdb->prefix . "product_order`.`order` ASC";
            $product_list1 = $wpdb->get_results($sql1, ARRAY_A);
            if (function_exists('product_display_list') && get_option('product_view') == 'list') {
                $output1 = product_display_list($product_list1, $group_type, $group_sql, $search_sql);
            } else {
                if (function_exists('product_display_grid') && get_option('product_view') == 'grid') {
                    $output1 = product_display_grid($product_list1, $group_type, $group_sql, $search_sql);
                } else {
                    $output1 = product_display_default($product_list1, '');
                }
            }
        }
        $content = str_replace($category['original_string'], $output1, $content);
    }
    if (preg_match_all("/\\[wpsc_category=([\\d]+),*(full)?\\]/", $content, $matches)) {
        foreach ($matches[1] as $key => $category_id) {
            $categories[$key]['id'] = $category_id;
            $categories[$key]['display'] = $matches[2][$key];
            $categories[$key]['original_string'] = $matches[0][$key];
        }
        //echo("<pre>".print_r($categories,true)."</pre>");
        $siteurl = get_option('siteurl');
        if (get_option('permalink_structure') != '') {
            $seperator = "?";
        } else {
            $seperator = "&amp;";
        }
        foreach ((array) $activated_widgets as $widget_container) {
            if (is_array($widget_container) && array_search(TXT_WPSC_DONATIONS, $widget_container)) {
                $no_donations_sql = "AND `" . $wpdb->prefix . "product_list`.`donation` != '1'";
                break;
            }
        }
        foreach ((array) $categories as $category) {
            $full_view = null;
            if ($category['display'] == 'full') {
                $sql = "SELECT DISTINCT `" . $wpdb->prefix . "product_list`.*, `" . $wpdb->prefix . "item_category_associations`.`category_id`,`" . $wpdb->prefix . "product_order`.`order`, IF(ISNULL(`" . $wpdb->prefix . "product_order`.`order`), 0, 1) AS `order_state` FROM `" . $wpdb->prefix . "product_list` LEFT JOIN `" . $wpdb->prefix . "item_category_associations` ON `" . $wpdb->prefix . "product_list`.`id` = `" . $wpdb->prefix . "item_category_associations`.`product_id` LEFT JOIN `" . $wpdb->prefix . "product_order` ON ( ( `" . $wpdb->prefix . "product_list`.`id` = `" . $wpdb->prefix . "product_order`.`product_id` ) AND ( `" . $wpdb->prefix . "item_category_associations`.`category_id` = `" . $wpdb->prefix . "product_order`.`category_id` ) ) WHERE `" . $wpdb->prefix . "product_list`.`active` = '1' AND `" . $wpdb->prefix . "item_category_associations`.`category_id` IN ('" . $category['id'] . "') {$no_donations_sql} ORDER BY `order_state` DESC,`" . $wpdb->prefix . "product_order`.`order` ASC";
                $product_list = $wpdb->get_results($sql, ARRAY_A);
                // sorry about the global variable, but it was the best way I could think of to avoid people having to upgrade the gold cart
                $GLOBALS['wpsc_category_id'] = $category['id'];
                if (function_exists('product_display_list') && get_option('product_view') == 'list') {
                    $output .= product_display_list($product_list, $group_type, $group_sql, $search_sql);
                } else {
                    if (function_exists('product_display_grid') && get_option('product_view') == 'grid') {
                        $output .= product_display_grid($product_list, $group_type, $group_sql, $search_sql);
                    } else {
                        $output .= product_display_default($product_list, $group_type, $group_sql, $search_sql);
                    }
                }
            } else {
                $sql = "SELECT DISTINCT `" . $wpdb->prefix . "product_list`.*, `" . $wpdb->prefix . "item_category_associations`.`category_id`,`" . $wpdb->prefix . "product_order`.`order`, IF(ISNULL(`" . $wpdb->prefix . "product_order`.`order`), 0, 1) AS `order_state` FROM `" . $wpdb->prefix . "product_list` LEFT JOIN `" . $wpdb->prefix . "item_category_associations` ON `" . $wpdb->prefix . "product_list`.`id` = `" . $wpdb->prefix . "item_category_associations`.`product_id` LEFT JOIN `" . $wpdb->prefix . "product_order` ON ( ( `" . $wpdb->prefix . "product_list`.`id` = `" . $wpdb->prefix . "product_order`.`product_id` ) AND ( `" . $wpdb->prefix . "item_category_associations`.`category_id` = `" . $wpdb->prefix . "product_order`.`category_id` ) ) WHERE `" . $wpdb->prefix . "product_list`.`active` = '1' AND `" . $wpdb->prefix . "item_category_associations`.`category_id` IN ('" . $category['id'] . "') {$no_donations_sql} ORDER BY `order_state` DESC,`" . $wpdb->prefix . "product_order`.`order` ASC";
                $product_list = $wpdb->get_results($sql, ARRAY_A);
                $output = "<div id='products_page_container' class='wrap wpsc_container'>\n\r";
                $output .= "<div id='homepage_products'>\n\r";
                if ($full_view != null) {
                    $output .= "<table class='productdisplay'>";
                }
                foreach ((array) $product_list as $product) {
                    $wpsc_theme = wpsc_theme_html($product);
                    if ($full_view == null) {
                        $output .= "<div class='category_view_product'>\n\r";
                    } else {
                        /* product image is here */
                        $output .= "<tr>";
                        $output .= "<td class='imagecol'>";
                    }
                    $output .= "<a href='" . WPSC_IMAGE_URL . $product['image'] . "' class='thickbox preview_link'  rel='" . str_replace(" ", "_", $product['name']) . "'>";
                    if ($product['image'] != '') {
                        $output .= "<img class='product_image' src='" . WPSC_THUMBNAIL_URL . $product['image'] . "' title='" . $product['name'] . "' alt='" . $product['name'] . "' />\n\r";
                    }
                    $output .= "</a>";
                    if ($full_view != null) {
                        $output .= "</td><td class='textcol'>";
                    } else {
                        $output .= "<div class='product_details'>";
                    }
                    if (get_option('hide_name_link') != 1) {
                        if ($product['special'] == 1 && $variations_output[1] === null) {
                            $output .= "<a href='" . wpsc_product_url($product['id']) . "' class='wpsc_product_title' >{$special}<strong class='special'>Special / Sale Price - </strong><strong>" . stripslashes($product['name']) . "</strong></a>";
                        } else {
                            $output .= "<a href='" . wpsc_product_url($product['id']) . "' class='wpsc_product_title' >{$special}<strong>" . stripslashes($product['name']) . "</strong></a>";
                        }
                    } else {
                        if ($product['special'] == 1 && $variations_output[1] === null) {
                            $output .= "<a class='wpsc_product_title' >{$special}<strong class='special'>Special / Sale Price - </strong><strong>" . stripslashes($product['name']) . "</strong></a>";
                        } else {
                            $output .= "<a class='wpsc_product_title' >{$special}<strong>" . stripslashes($product['name']) . "</strong></a>";
                        }
                    }
                    if ($full_view != null) {
                        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 />";
                        }
                    }
                    /*
                    adding to cart stuff
                    */
                    $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 .= "<input type='hidden' name='item' value='" . $product['id'] . "' />";
                    $variations_procesor = new nzshpcrt_variations();
                    $variations_output = $variations_procesor->display_product_variations($product['id'], false, false, true);
                    $output .= $variations_output[0];
                    if ($variations_output[1] !== null) {
                        $product['price'] = $variations_output[1];
                    }
                    if ($product['special'] == 1 && $variations_output[1] === null) {
                        $output .= "<span class='oldprice'>" . nzshpcrt_currency_display($product['price'], $product['notax']) . "</span><br />";
                        $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><br />";
                    }
                    if (get_option('hide_addtocart_button') != '1' || get_option('payment_gateway') != 'google') {
                        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 . "'  />";
                        }
                    }
                    $output .= "</form>";
                    if (get_option('addtocart_or_buynow') == '1') {
                        if (get_option('payment_gateway') == 'google') {
                            $output .= google_buynow($product['id']);
                        }
                    }
                    if ($full_view != null) {
                        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 .= "</td>";
                        $output .= "</tr>";
                    } else {
                        $output .= "</div>\n\r";
                        $output .= "</div>";
                    }
                }
                if ($full_view != null) {
                    $output .= "</table>";
                }
                $output .= "</div>\n\r";
                $output .= "<br style='clear: left;'>\n\r";
                $output .= "</div>\n\r";
            }
            $content = str_replace($category['original_string'], $output, $content);
        }
    }
    return $content;
}
Ejemplo n.º 26
0
function wpsc_generate_product_feed()
{
    global $wpdb, $wp_query, $post;
    set_time_limit(0);
    // Don't build up a huge posts cache for the whole store - http://code.google.com/p/wp-e-commerce/issues/detail?id=885
    // WP 3.3+ only
    if (function_exists('wp_suspend_cache_addition')) {
        wp_suspend_cache_addition(true);
    }
    $chunk_size = apply_filters('wpsc_productfeed_chunk_size', 50);
    // Don't cache feed under WP Super-Cache
    define('DONOTCACHEPAGE', TRUE);
    $selected_category = '';
    $selected_product = '';
    $args = array('post_type' => 'wpsc-product', 'numberposts' => $chunk_size, 'offset' => 0, 'cache_results' => false);
    $args = apply_filters('wpsc_productfeed_query_args', $args);
    $self = site_url("/index.php?rss=true&amp;action=product_list{$selected_category}{$selected_product}");
    header("Content-Type: application/xml; charset=UTF-8");
    header('Content-Disposition: inline; filename="E-Commerce_Product_List.rss"');
    echo "<?xml version='1.0' encoding='UTF-8' ?>\n\r";
    echo "<rss version='2.0' xmlns:atom='http://www.w3.org/2005/Atom'";
    $google_checkout_note = false;
    if ($_GET['xmlformat'] == 'google') {
        echo ' xmlns:g="http://base.google.com/ns/1.0"';
        // Is Google Checkout available as a payment gateway
        $selected_gateways = get_option('custom_gateway_options');
        if (in_array('google', $selected_gateways)) {
            $google_checkout_note = true;
        }
    } else {
        echo ' xmlns:product="http://www.buy.com/rss/module/productV2/"';
    }
    echo ">\n\r";
    echo "  <channel>\n\r";
    echo "    <title><![CDATA[" . get_option('blogname') . " Products]]></title>\n\r";
    echo "    <link>" . get_option('siteurl') . "/wp-admin/admin.php?page=" . WPSC_DIR_NAME . "/display-log.php</link>\n\r";
    echo "    <description>This is the WP e-Commerce Product List RSS feed</description>\n\r";
    echo "    <generator>WP e-Commerce Plugin</generator>\n\r";
    echo "    <atom:link href='{$self}' rel='self' type='application/rss+xml' />\n\r";
    $products = get_posts($args);
    while (count($products)) {
        foreach ($products as $post) {
            setup_postdata($post);
            $purchase_link = wpsc_product_url($post->ID);
            echo "    <item>\n\r";
            if ($google_checkout_note) {
                echo "      <g:payment_notes>Google Checkout</g:payment_notes>\n\r";
            }
            echo "      <title><![CDATA[" . get_the_title() . "]]></title>\n\r";
            echo "      <link>{$purchase_link}</link>\n\r";
            echo "      <description><![CDATA[" . apply_filters('the_content', get_the_content()) . "]]></description>\n\r";
            echo "      <pubDate>" . $post->post_modified_gmt . "</pubDate>\n\r";
            echo "      <guid>{$purchase_link}</guid>\n\r";
            $image_link = wpsc_the_product_thumbnail();
            if ($image_link !== FALSE) {
                if ($_GET['xmlformat'] == 'google') {
                    echo "      <g:image_link>{$image_link}</g:image_link>\n\r";
                } else {
                    echo "      <enclosure url='{$image_link}' />\n\r";
                }
            }
            $price = wpsc_calculate_price($post->ID);
            $currargs = array('display_currency_symbol' => false, 'display_decimal_point' => true, 'display_currency_code' => false, 'display_as_html' => false);
            $price = wpsc_currency_display($price, $currargs);
            $children = get_children(array('post_parent' => $post->ID, 'post_type' => 'wpsc-product'));
            foreach ($children as $child) {
                $child_price = wpsc_calculate_price($child->ID);
                if ($price == 0 && $child_price > 0) {
                    $price = $child_price;
                } else {
                    if ($child_price > 0 && $child_price < $price) {
                        $price = $child_price;
                    }
                }
            }
            if ($_GET['xmlformat'] == 'google') {
                echo "      <g:price>" . $price . "</g:price>\n\r";
                $google_elements = array();
                $product_meta = get_post_custom($post->ID);
                if (is_array($product_meta)) {
                    foreach ($product_meta as $meta_key => $meta_value) {
                        if (stripos($meta_key, 'g:') === 0) {
                            $google_elements[$meta_key] = $meta_value;
                        }
                    }
                }
                $google_elements = apply_filters('wpsc_google_elements', array('product_id' => $post->ID, 'elements' => $google_elements));
                $google_elements = $google_elements['elements'];
                $done_condition = FALSE;
                $done_availability = FALSE;
                $done_weight = FALSE;
                if (count($google_elements)) {
                    foreach ($google_elements as $element_name => $element_values) {
                        foreach ($element_values as $element_value) {
                            echo "      <" . $element_name . ">";
                            echo "<![CDATA[" . $element_value . "]]>";
                            echo "</" . $element_name . ">\n\r";
                        }
                        if ($element_name == 'g:shipping_weight') {
                            $done_weight = TRUE;
                        }
                        if ($element_name == 'g:condition') {
                            $done_condition = TRUE;
                        }
                        if ($element_name == 'g:availability') {
                            $done_availability = true;
                        }
                    }
                }
                if (!$done_condition) {
                    echo "      <g:condition>new</g:condition>\n\r";
                }
                if (!$done_availability) {
                    if (wpsc_product_has_stock()) {
                        $product_availability = "in stock";
                    } else {
                        $product_availability = "out of stock";
                    }
                    echo " <g:availability>{$product_availability}</g:availability>";
                }
                if (!$done_weight) {
                    $wpsc_product_meta = get_product_meta($post->ID, 'product_metadata', true);
                    $weight = apply_filters('wpsc_google_shipping_weight', $wpsc_product_meta['weight'], $post->ID);
                    if ($weight && is_numeric($weight) && $weight > 0) {
                        echo "<g:shipping_weight>{$weight} pounds</g:shipping_weight>";
                    }
                }
            } else {
                echo "      <product:price>" . $price . "</product:price>\n\r";
            }
            echo "    </item>\n\r";
        }
        $args['offset'] += $chunk_size;
        $products = get_posts($args);
    }
    echo "  </channel>\n\r";
    echo "</rss>";
    exit;
}
Ejemplo n.º 27
0
/**
 * WPSC canonical URL function
 * Needs a recent version 
 * @since 3.7
 * @param int product id
 * @return bool true or false
 */
function wpsc_change_canonical_url($url)
{
    global $wpdb, $wpsc_query;
    if ($wpsc_query->is_single == true) {
        if (!is_numeric($_GET['product_id'])) {
            $product_id = $wpdb->get_var("SELECT `product_id` FROM `" . WPSC_TABLE_PRODUCTMETA . "` WHERE `meta_key` IN ( 'url_name' ) AND `meta_value` IN ( '" . $wpsc_query->query_vars['product_url_name'] . "' ) ORDER BY `product_id` DESC LIMIT 1");
        } else {
            $product_id = absint($_GET['product_id']);
        }
        $url = wpsc_product_url($product_id);
    } else {
        if ($wpsc_query->query_vars['category_id'] > 0) {
            $url = wpsc_category_url($wpsc_query->query_vars['category_id']);
            if (get_option('permalink_structure') && $wpsc_query->query_vars['page'] > 1) {
                $url .= $url . "page/{$wpsc_query->query_vars['page']}/";
            }
        }
    }
    return $url;
}
Ejemplo n.º 28
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;
 }
Ejemplo n.º 29
0
function wpsc_also_bought($product_id)
{
    /*
     * Displays products that were bought aling with the product defined by $product_id
     * most of it scarcely needs describing
     */
    global $wpdb;
    $siteurl = get_option('siteurl');
    if (get_option('wpsc_also_bought') == 0) {
        //returns nothing if this is off
        return '';
    }
    // to be made customiseable in a future release
    $also_bought_limit = 3;
    $element_widths = 96;
    $image_display_height = 96;
    $image_display_width = 96;
    $also_bought = $wpdb->get_results("SELECT `" . WPSC_TABLE_PRODUCT_LIST . "`.* FROM `" . WPSC_TABLE_ALSO_BOUGHT . "`, `" . WPSC_TABLE_PRODUCT_LIST . "` WHERE `selected_product`='" . $product_id . "' AND `" . WPSC_TABLE_ALSO_BOUGHT . "`.`associated_product` = `" . WPSC_TABLE_PRODUCT_LIST . "`.`id` AND `" . WPSC_TABLE_PRODUCT_LIST . "`.`active` IN('1') AND `" . WPSC_TABLE_PRODUCT_LIST . "`.`publish` IN ('1')ORDER BY `" . WPSC_TABLE_ALSO_BOUGHT . "`.`quantity` DESC LIMIT {$also_bought_limit}", ARRAY_A);
    if (count($also_bought) > 0) {
        $output = "<h2 class='prodtitles wpsc_also_bought' >" . TXT_WPSC_ALSO_BOUGHT . "</h2>";
        $output .= "<div class='wpsc_also_bought'>";
        foreach ((array) $also_bought as $also_bought_data) {
            $output .= "<div class='wpsc_also_bought_item' style='width: " . $element_widths . "px;'>";
            if (get_option('show_thumbnails') == 1) {
                if ($also_bought_data['image'] != null) {
                    $output .= "<a href='" . wpsc_product_url($also_bought_data['id']) . "' class='preview_link'  rel='" . str_replace(" ", "_", $also_bought_data['name']) . "'>";
                    $image_path = "index.php?productid=" . $also_bought_data['id'] . "&amp;width=" . $image_display_width . "&amp;height=" . $image_display_height . "";
                    $output .= "<img src='{$image_path}' id='product_image_" . $also_bought_data['id'] . "' class='product_image' style='margin-top: " . $margin_top . "px'/>";
                    $output .= "</a>";
                } else {
                    if (get_option('product_image_width') != '') {
                        $output .= "<img src='" . WPSC_URL . "/images/no-image-uploaded.gif' title='" . $also_bought_data['name'] . "' alt='" . $also_bought_data['name'] . "' width='{$image_display_height}' height='{$image_display_height}' id='product_image_" . $also_bought_data['id'] . "' class='product_image' />";
                    } else {
                        $output .= "<img src='" . WPSC_URL . "/images/no-image-uploaded.gif' title='" . $also_bought_data['name'] . "' alt='" . htmlentities(stripslashes($product['name']), ENT_QUOTES, 'UTF-8') . "' id='product_image_" . $also_bought_data['id'] . "' class='product_image' />";
                    }
                }
            }
            $variations_processor = new nzshpcrt_variations();
            $variations_output = $variations_processor->display_product_variations($also_bought_data['id'], true, false, true);
            //$output .= $variations_output[0];
            if ($variations_output[1] !== null) {
                $also_bought_data['price'] = $variations_output[1];
                $also_bought_data['special_price'] = 0;
            }
            $output .= "<a class='wpsc_product_name' href='" . wpsc_product_url($also_bought_data['id']) . "'>" . $also_bought_data['name'] . "</a>";
            $output .= nzshpcrt_currency_display($also_bought_data['price'] - $also_bought_data['special_price'], $also_bought_data['notax'], false, $also_bought_data['id']);
            //$output .= "<a href='".wpsc_product_url($also_bought_data['id'])."'>".$also_bought_data['name']."</a>";
            $output .= "</div>";
        }
        $output .= "</div>";
        $output .= "<br clear='all' />";
    }
    return $output;
}
        $image = " yes-image";
    }
    if ($i == 4) {
        $rightCol = " col-right";
    }
    echo "<li class='latest-product" . $image . $rightCol . "'>";
    if ($latest_product['price'] - $latest_product['special_price'] > 0 && $latest_product['special_price'] > 0) {
        ?>
<span class="sale-icon"><?php 
        _e('Sale!', 'flexishop');
        ?>
</span><?php 
    }
    ?>
			<?php 
    echo "<div class='padding'>";
    if ($latest_product['image']) {
        $theSrc = get_timthumb_src(WPSC_THUMBNAIL_URL . $latest_product['image']);
        if ($options['themelayout'] == 'boxed') {
            $output = "<img src='" . get_bloginfo('template_url') . "/timthumb.php?src=" . $theSrc . "&w=174&q=100' title='" . $latest_product['name'] . "' alt='" . $latest_product['name'] . "' />";
        } else {
            $output = "<img src='" . get_bloginfo('template_url') . "/timthumb.php?src=" . $theSrc . "&w=186&q=100' title='" . $latest_product['name'] . "' alt='" . $latest_product['name'] . "' />";
        }
    } else {
        $output = __("No Image Available", 'flexishop');
    }
    echo '<div class="imagecol"><a href="' . wpsc_product_url($latest_product['id']) . '">' . $output . '</a></div>';
    echo "<div class='producttext'><h3><a href='" . wpsc_product_url($latest_product['id']) . "'>" . stripslashes(${$latest_product}['name']) . "</a></h3></div>";
    echo "</div></li>";
}
echo "</ul>";