/** * wpsc_convert_categories function. * * @access public * @param int $parent_category. (default: 0) * @return void */ function wpsc_convert_categories($new_parent_category, $group_id, $old_parent_category = 0) { global $wpdb, $user_ID; if ($old_parent_category > 0) { $categorisation = $wpdb->get_results("SELECT * FROM `" . WPSC_TABLE_PRODUCT_CATEGORIES . "` WHERE `active` IN ('1') AND `group_id` IN ('{$group_id}') AND `category_parent` IN ('{$old_parent_category}')"); } else { $categorisation = $wpdb->get_results("SELECT * FROM `" . WPSC_TABLE_PRODUCT_CATEGORIES . "` WHERE `active` IN ('1') AND `group_id` IN ('{$group_id}') AND `category_parent` IN (0)"); } if ($categorisation > 0) { foreach ((array) $categorisation as $category) { $category_id = wpsc_get_meta($category->id, 'category_id', 'wpsc_old_category'); if (!is_numeric($category_id) || $category_id < 1) { $new_category = wp_insert_term($category->name, 'wpsc_product_category', array('description' => $category->description, 'parent' => $new_parent_category)); if (!is_wp_error($new_category)) { $category_id = $new_category['term_id']; } } if (is_numeric($category_id)) { wpsc_update_meta($category->id, 'category_id', $category_id, 'wpsc_old_category'); wpsc_update_categorymeta($category_id, 'category_id', $category->id); wpsc_update_categorymeta($category_id, 'image', $category->image); wpsc_update_categorymeta($category_id, 'display_type', $category->display_type); wpsc_update_categorymeta($category_id, 'image_height', $category->image_height); wpsc_update_categorymeta($category_id, 'image_width', $category->image_width); $use_additonal_form_set = wpsc_get_categorymeta($category->id, 'use_additonal_form_set'); if ($use_additonal_form_set != '') { wpsc_update_categorymeta($category_id, 'use_additonal_form_set', $use_additonal_form_set); } else { wpsc_delete_categorymeta($category_id, 'use_additonal_form_set'); } wpsc_update_categorymeta($category_id, 'uses_billing_address', (bool) (int) wpsc_get_categorymeta($category->id, 'uses_billing_address')); } if ($category_id > 0) { wpsc_convert_categories($category_id, $group_id, $category->id); } } } }
/** * calculates shipping price for an individual cart item. * * @param object $cart_item (reference) * @return float price of shipping for the item. */ function get_item_shipping(&$cart_item) { global $wpdb, $wpsc_cart; $unit_price = $cart_item->unit_price; $quantity = $cart_item->quantity; $weight = $cart_item->weight; $product_id = $cart_item->product_id; $uses_billing_address = false; foreach ($cart_item->category_id_list as $category_id) { $uses_billing_address = (bool) wpsc_get_categorymeta($category_id, 'uses_billing_address'); if ($uses_billing_address === true) { break; /// just one true value is sufficient } } if (is_numeric($product_id) && get_option('do_not_use_shipping') != 1) { if ($uses_billing_address == true) { $country_code = $wpsc_cart->selected_country; } else { $country_code = $wpsc_cart->delivery_country; } if ($cart_item->uses_shipping == true) { //if the item has shipping $additional_shipping = ''; if (isset($cart_item->meta[0]['shipping'])) { $shipping_values = $cart_item->meta[0]['shipping']; } if (isset($shipping_values['local']) && $country_code == get_option('base_country')) { $additional_shipping = $shipping_values['local']; } else { if (isset($shipping_values['international'])) { $additional_shipping = $shipping_values['international']; } } $shipping = $quantity * $additional_shipping; } else { //if the item does not have shipping $shipping = 0; } } else { //if the item is invalid or all items do not have shipping $shipping = 0; } return $shipping; }
<?php $curr_cat = get_term($category_id, 'wpsc_product_category', ARRAY_A); $category_list = get_terms('wpsc_product_category', 'hide_empty=0&parent=' . $category_id); $link = get_term_link((int) $category_id, 'wpsc_product_category'); $category_image = wpsc_get_categorymeta($curr_cat['term_id'], 'image'); $category_image = WPSC_CATEGORY_URL . $category_image; $show_name = $instance['show_name']; if ($grid) { ?> <a href="<?php echo $link; ?> " style="padding: 4px 4px 0 0; width:<?php echo $width; ?> px; height:<?php echo $height; ?> px;" title="<?php echo $curr_cat['name']; ?> " class="wpsc_category_grid_item"> <?php wpsc_parent_category_image($show_thumbnails, $category_image, $width, $height, true, $show_name); ?> </a> <?php wpsc_start_category_query(array('parent_category_id' => $category_id, 'show_thumbnails' => $show_thumbnails, 'show_name' => $show_name));
/** * wpsc_save_category_set, Saves the category set data * @param nothing * @return nothing */ function wpsc_save_category_set($category_id, $tt_id) { global $wpdb; if (!empty($_POST)) { /* Image Processing Code*/ if (!empty($_FILES['image']) && preg_match("/\\.(gif|jp(e)*g|png){1}\$/i", $_FILES['image']['name'])) { if (function_exists("getimagesize")) { if (isset($_POST['width']) && ((int) $_POST['width'] > 10 && (int) $_POST['width'] < 512) && ((int) $_POST['height'] > 10 && (int) $_POST['height'] < 512)) { $width = (int) $_POST['width']; $height = (int) $_POST['height']; image_processing($_FILES['image']['tmp_name'], WPSC_CATEGORY_DIR . $_FILES['image']['name'], $width, $height, 'image'); } else { image_processing($_FILES['image']['tmp_name'], WPSC_CATEGORY_DIR . $_FILES['image']['name'], null, null, 'image'); } $image = esc_sql($_FILES['image']['name']); } else { $new_image_path = WPSC_CATEGORY_DIR . basename($_FILES['image']['name']); move_uploaded_file($_FILES['image']['tmp_name'], $new_image_path); $stat = stat(dirname($new_image_path)); $perms = $stat['mode'] & 0666; @chmod($new_image_path, $perms); $image = esc_sql($_FILES['image']['name']); } } else { $image = ''; } //Good to here if (isset($_POST['tag_ID'])) { //Editing $category_id = (int) $_POST['tag_ID']; $category = get_term_by('id', $category_id, 'wpsc_product_category'); $url_name = $category->slug; } if (isset($_POST['deleteimage']) && $_POST['deleteimage'] == 1) { wpsc_delete_categorymeta($category_id, 'image'); } else { if ($image != '') { wpsc_update_categorymeta($category_id, 'image', $image); } } if (!empty($_POST['height']) && is_numeric($_POST['height']) && !empty($_POST['width']) && is_numeric($_POST['width']) && $image == null) { $imagedata = wpsc_get_categorymeta($category_id, 'image'); if ($imagedata != null) { $height = (int) $_POST['height']; $width = (int) $_POST['width']; $imagepath = WPSC_CATEGORY_DIR . $imagedata; $image_output = WPSC_CATEGORY_DIR . $imagedata; image_processing($imagepath, $image_output, $width, $height); } } wpsc_update_categorymeta($category_id, 'fee', '0'); wpsc_update_categorymeta($category_id, 'active', '1'); wpsc_update_categorymeta($category_id, 'order', '0'); if (isset($_POST['display_type'])) { wpsc_update_categorymeta($category_id, 'display_type', esc_sql(stripslashes($_POST['display_type']))); } if (isset($_POST['image_height'])) { wpsc_update_categorymeta($category_id, 'image_height', (int) $_POST['image_height']); } if (isset($_POST['image_width'])) { wpsc_update_categorymeta($category_id, 'image_width', (int) $_POST['image_width']); } if (!empty($_POST['use_additional_form_set'])) { wpsc_update_categorymeta($category_id, 'use_additional_form_set', absint($_POST['use_additional_form_set'])); } else { wpsc_delete_categorymeta($category_id, 'use_additional_form_set'); } if (!empty($_POST['uses_billing_address'])) { wpsc_update_categorymeta($category_id, 'uses_billing_address', 1); $uses_additional_forms = true; } else { wpsc_update_categorymeta($category_id, 'uses_billing_address', 0); $uses_additional_forms = false; } if (!empty($_POST['countrylist2']) && $category_id > 0) { $AllSelected = false; $countryList = $wpdb->get_col("SELECT `id` FROM `" . WPSC_TABLE_CURRENCY_LIST . "`"); if ($AllSelected != true) { $posted_countries = array_map('intval', $_POST['countrylist2']); $unselectedCountries = array_diff($countryList, $posted_countries); //find the countries that are selected $selectedCountries = array_intersect($countryList, $posted_countries); wpsc_update_categorymeta($category_id, 'target_market', $selectedCountries); } } elseif (!isset($_POST['countrylist2'])) { wpsc_update_categorymeta($category_id, 'target_market', ''); $AllSelected = true; } } }
private function category_image($cat) { $img = wpsc_get_categorymeta($cat->term_id, 'image'); if ($img) { $url = WPSC_CATEGORY_URL . $img; } else { $url = wpsc_locate_asset_uri('images/noimage.png'); } echo "<img src='" . esc_url($url) . "' width='" . esc_attr($this->instance['width']) . "' height='" . esc_attr($this->instance['height']) . "' />"; }
/** * wpsc_checkout method, gets the tax rate as a percentage, based on the selected country and region * @access public */ function wpsc_checkout($checkout_set = 0) { global $wpdb; $this->checkout_items = $wpdb->get_results($wpdb->prepare("SELECT * FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `active` = '1' AND `checkout_set`= %s ORDER BY `checkout_order`;", $checkout_set)); $GLOBALS['wpsc_checkout_error_messages'] = wpsc_get_customer_meta('checkout_error_messages'); $GLOBALS['wpsc_gateway_error_messages'] = wpsc_get_customer_meta('gateway_error_messages'); $GLOBALS['wpsc_registration_error_messages'] = wpsc_get_customer_meta('registration_error_messages'); $GLOBALS['wpsc_customer_checkout_details'] = apply_filters('wpsc_get_customer_checkout_details', wpsc_get_customer_meta('checkout_details')); // legacy filter if (is_user_logged_in()) { $GLOBALS['wpsc_customer_checkout_details'] = apply_filters('wpsc_checkout_user_profile_get', $GLOBALS['wpsc_customer_checkout_details'], get_current_user_id()); } if (!is_array($GLOBALS['wpsc_customer_checkout_details'])) { $GLOBALS['wpsc_customer_checkout_details'] = array(); } $category_list = wpsc_cart_item_categories(true); $additional_form_list = array(); foreach ($category_list as $category_id) { $additional_form_list[] = wpsc_get_categorymeta($category_id, 'use_additional_form_set'); } if (function_exists('wpsc_get_ticket_checkout_set')) { $checkout_form_fields_id = array_search(wpsc_get_ticket_checkout_set(), $additional_form_list); unset($additional_form_list[$checkout_form_fields_id]); } if (count($additional_form_list) > 0) { $this->category_checkout_items = $wpdb->get_results("SELECT * FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `active` = '1' AND `checkout_set` IN ('" . implode("','", $additional_form_list) . "') ORDER BY `checkout_set`, `checkout_order`;"); $this->checkout_items = array_merge((array) $this->checkout_items, (array) $this->category_checkout_items); } if (function_exists('wpsc_get_ticket_checkout_set')) { $sql = "SELECT * FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `active` = '1' AND `checkout_set`='" . wpsc_get_ticket_checkout_set() . "' ORDER BY `checkout_order`;"; $this->additional_fields = $wpdb->get_results($sql); $count = wpsc_ticket_checkoutfields(); $j = 1; $fields = $this->additional_fields; $this->formfield_count = count($fields) + $this->checkout_item_count; while ($j < $count) { $this->additional_fields = array_merge((array) $this->additional_fields, (array) $fields); $j++; } if (wpsc_ticket_checkoutfields() > 0) { $this->checkout_items = array_merge((array) $this->checkout_items, (array) $this->additional_fields); } } $this->checkout_items = apply_filters('wpsc_checkout_fields', $this->checkout_items, $this); $this->checkout_item_count = count($this->checkout_items); }
/** * Return category or product description depending on queried item */ function wpsc_obtain_the_description() { $output = null; // Return Category Description if (is_numeric(get_query_var('category_id'))) { $output = wpsc_get_categorymeta(get_query_var('category_id'), 'description'); } else { if (!empty($_GET['category'])) { $output = wpsc_get_categorymeta(absint($_GET['category']), 'description'); } } // Return product content as description if product page if (!empty($_GET['product_id']) && is_numeric($_GET['product_id'])) { $product = get_post(absint($_GET['product_id'])); $output = $product->post_content; } return $output; }
/** * wpsc_checkout method, gets the tax rate as a percentage, based on the selected country and region * @access public */ function wpsc_checkout($checkout_set = 0) { global $wpdb; $this->checkout_items = $wpdb->get_results("SELECT * FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `active` = '1' AND `checkout_set`='" . $checkout_set . "' ORDER BY `checkout_order`;"); $category_list = wpsc_cart_item_categories(true); $additional_form_list = array(); foreach ($category_list as $category_id) { $additional_form_list[] = wpsc_get_categorymeta($category_id, 'use_additonal_form_set'); } if (function_exists('wpsc_get_ticket_checkout_set')) { $checkout_form_fields_id = array_search(wpsc_get_ticket_checkout_set(), $additional_form_list); unset($additional_form_list[$checkout_form_fields_id]); } if (count($additional_form_list) > 0) { $this->category_checkout_items = $wpdb->get_results("SELECT * FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `active` = '1' AND `checkout_set` IN ('" . implode("','", $additional_form_list) . "') ORDER BY `checkout_set`, `checkout_order`;"); $this->checkout_items = array_merge((array) $this->checkout_items, (array) $this->category_checkout_items); } if (function_exists('wpsc_get_ticket_checkout_set')) { $sql = "SELECT * FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `active` = '1' AND `checkout_set`='" . wpsc_get_ticket_checkout_set() . "' ORDER BY `checkout_order`;"; $this->additional_fields = $wpdb->get_results($sql); $count = wpsc_ticket_checkoutfields(); $j = 1; $fields = $this->additional_fields; $this->formfield_count = count($fields) + $this->checkout_item_count; while ($j < $count) { $this->additional_fields = array_merge((array) $this->additional_fields, (array) $fields); $j++; } if (wpsc_ticket_checkoutfields() > 0) { $this->checkout_items = array_merge((array) $this->checkout_items, (array) $this->additional_fields); } } $this->checkout_item_count = count($this->checkout_items); }
/** * wpsc_category_image function, Gets the category image or returns false * @param integer category ID, can be 0 * @return string url to the category image */ function wpsc_category_image($category_id = null) { if ($category_id < 1) { $category_id = wpsc_category_id(); } $category_image = wpsc_get_categorymeta($category_id, 'image'); $category_path = WPSC_CATEGORY_DIR . basename($category_image); $category_url = WPSC_CATEGORY_URL . basename($category_image); if (file_exists($category_path) && is_file($category_path)) { return $category_url; } return false; }
/** * wpsc category loop function * This function recursively loops through the categories to display the category tree. * This function also generates a tree of categories at the same time * WARNING: as this function is recursive, be careful what you do with it. * @param array the category query * @param string the category html * @param array the category array branch, is an internal value, leave it alone. * @return string - the finished category html */ function wpsc_display_category_loop($query, $category_html, &$category_branch = null) { static $category_count_data = array(); // the array tree is stored in this if (isset($query['parent_category_id'])) { $category_id = absint($query['parent_category_id']); } else { $category_id = 0; } $category_data = get_terms('wpsc_product_category', 'hide_empty=0&parent=' . $category_id, OBJECT, 'display'); $output = ''; // if the category branch is identical to null, make it a reference to $category_count_data if ($category_branch === null) { $category_branch =& $category_count_data; } $allowed_tags = array('a' => array('href' => array(), 'title' => array()), 'abbr' => array('title' => array()), 'acronym' => array('title' => array()), 'code' => array(), 'em' => array(), 'strong' => array(), 'b' => array()); $allowedtags = apply_filters('wpsc_category_description_allowed_tags', $allowed_tags); foreach ((array) $category_data as $category_row) { // modifys the query for the next round $modified_query = $query; $modified_query['parent_category_id'] = $category_row->term_id; // gets the count of products associated with this category $category_count = $category_row->count; // Sticks the category description in $category_description = ''; if ($category_row->description != '' && !empty($query['description_container'])) { $start_element = $query['description_container']['start_element']; $end_element = $query['description_container']['end_element']; $category_description = $start_element . wpautop(wptexturize(wp_kses($category_row->description, $allowedtags))) . $end_element; } // Creates the list of classes on the category item $category_classes = wpsc_print_category_classes((array) $category_row, false); // Set the variables for this category $category_branch[$category_row->term_id]['children'] = array(); $category_branch[$category_row->term_id]['count'] = (int) $category_count; // Recurse into the next level of categories $sub_categories = wpsc_display_category_loop($modified_query, $category_html, $category_branch[$category_row->term_id]['children']); // grab the product count from the subcategories foreach ((array) $category_branch[$category_row->term_id]['children'] as $child_category) { $category_branch[$category_row->term_id]['count'] += (int) $child_category['count']; } // stick the category count array together here // this must run after the subcategories and the count of products belonging to them has been obtained $category_count = $category_branch[$category_row->term_id]['count']; $start_element = ''; $end_element = ''; if (isset($query['products_count']['start_element'])) { $start_element = $query['products_count']['start_element']; } if (isset($query['products_count']['end_element'])) { $end_element = $query['products_count']['end_element']; } $category_count_html = $start_element . $category_count . $end_element; if (isset($query['subcategory_container']) && !empty($sub_categories)) { $start_element = $query['subcategory_container']['start_element']; $end_element = $query['subcategory_container']['end_element']; $sub_categories = $start_element . $sub_categories . $end_element; } // get the category images $category_image = wpsc_place_category_image($category_row->term_id, $modified_query); if (empty($query['image_size']['width'])) { if (!wpsc_category_grid_view()) { $width = wpsc_get_categorymeta($category_row->term_id, 'image_width'); } if (empty($width)) { $width = get_option('category_image_width'); } } else { $width = $query['image_size']['width']; } if (empty($query['image_size']['height'])) { if (!wpsc_category_grid_view()) { $height = wpsc_get_categorymeta($category_row->term_id, 'image_height'); } if (empty($height)) { $height = get_option('category_image_height'); } } else { $height = $query['image_size']['height']; } $category_image = wpsc_get_categorymeta($category_row->term_id, 'image'); $category_image_html = ''; if ($query['show_thumbnails'] == 1) { if (!empty($category_image) && is_file(WPSC_CATEGORY_DIR . $category_image)) { $category_image_html = "<img src='" . WPSC_CATEGORY_URL . "{$category_image}' alt='{$category_row->name}' title='{$category_row->name}' style='width: {$width}px; height: {$height}px;' class='wpsc_category_image' />"; } elseif (isset($query['show_name']) && 1 == $query['show_name']) { $category_image_html .= "<span class='wpsc_category_image item_no_image ' style='width: {$width}px; height: {$height}px;'>\n\r"; $category_image_html .= "\t<span class='link_substitute' >\n\r"; $category_image_html .= "\t\t<span>" . __('N/A', 'wpsc') . "</span>\n\r"; $category_image_html .= "\t</span>\n\r"; $category_image_html .= "</span>\n\r"; } } // get the list of products associated with this category. $tags_to_replace = array('[wpsc_category_name]', '[wpsc_category_description]', '[wpsc_category_url]', '[wpsc_category_id]', '[wpsc_category_classes]', '[wpsc_category_image]', '[wpsc_subcategory]', '[wpsc_category_products_count]'); $content_to_place = array(esc_html($category_row->name), $category_description, esc_url(get_term_link($category_row->slug, 'wpsc_product_category')), $category_row->term_id, $category_classes, $category_image_html, $sub_categories, $category_count_html); // Stick all the category html together and concatenate it to the previously generated HTML $output .= str_replace($tags_to_replace, $content_to_place, $category_html); } return $output; }
function wpsc_obtain_the_description() { global $wpdb, $wp_query, $wpsc_title_data; $output = null; if (is_numeric($wp_query->query_vars['category_id'])) { $category_id = $wp_query->query_vars['category_id']; } else { if ($_GET['category']) { $category_id = absint($_GET['category']); } } if (is_numeric($category_id)) { $output = wpsc_get_categorymeta($category_id, 'description'); } if (is_numeric($_GET['product_id'])) { $product_id = absint($_GET['product_id']); $output = $wpdb->get_var($wpdb->prepare("SELECT `post_content` FROM `" . $wpdb->posts . "` WHERE `id` = %d LIMIT 1", $product_id)); } return $output; }
function nzshpcrt_getcategoryform($catid) { global $wpdb, $nzshpcrt_imagesize_info; $product = $wpdb->get_row("SELECT * FROM `" . WPSC_TABLE_PRODUCT_CATEGORIES . "` WHERE `id`={$catid} LIMIT 1", ARRAY_A); $output = ''; $output .= "<div class='editing_this_group form_table'>"; $output .= "<p>" . str_replace("[categorisation]", htmlentities(stripslashes($product['name'])), __('You are editing the "[categorisation]" Category', 'wpsc')) . "</p>\n\r"; $output .= "<p><a href='' onclick='return showaddform()' class='add_category_link'><span>" . str_replace(""[categorisation]"", "current", __('+ Add new category to the "[categorisation]" Group', 'wpsc')) . "</span></a></p>"; $output .= "<dl>\n\r"; $output .= "\t\t<dt>Display Category Shortcode: </dt>\n\r"; $output .= "\t\t<dd> [wpsc_products category_url_name='{$product['nice-name']}']</dd>\n\r"; $output .= "\t\t<dt>Display Category Template Tag: </dt>\n\r"; $output .= "\t\t<dd> <?php echo wpsc_display_products_page(array('category_url_name'=>'{$product['nice-name']}')); ?></dd>\n\r"; $output .= "</dl>\n\r"; //$output .= " [ <a href='#' onclick='return showedit_categorisation_form()'>".__('Edit This Group', 'wpsc')."</a> ]"; $output .= "</div>"; $output .= " <table class='category_forms'>\n\r"; $output .= " <tr>\n\r"; $output .= " <td>\n\r"; $output .= __('Name', 'wpsc') . ": "; $output .= " </td>\n\r"; $output .= " <td>\n\r"; $output .= "<input type='text' class='text' name='title' value='" . htmlentities(stripslashes($product['name']), ENT_QUOTES, 'UTF-8') . "' />"; $output .= " </td>\n\r"; $output .= " </tr>\n\r"; $output .= " <tr>\n\r"; $output .= " <td>\n\r"; $output .= __('Description', 'wpsc') . ": "; $output .= " </td>\n\r"; $output .= " <td>\n\r"; $output .= "<textarea name='description' cols='40' rows='8' >" . stripslashes($product['description']) . "</textarea>"; $output .= " </td>\n\r"; $output .= " </tr>\n\r"; $output .= " </tr>\n\r"; $output .= " <tr>\n\r"; $output .= " <td>\n\r"; $output .= __('Category Parent', 'wpsc') . ": "; $output .= " </td>\n\r"; $output .= " <td>\n\r"; $output .= wpsc_parent_category_list($product['group_id'], $product['id'], $product['category_parent']); $output .= " </td>\n\r"; $output .= " </tr>\n\r"; $output .= " </tr>\n\r"; if ($product['display_type'] == 'grid') { $display_type1 = "selected='selected'"; } else { if ($product['display_type'] == 'default') { $display_type2 = "selected='selected'"; } } switch ($product['display_type']) { case "default": $product_view1 = "selected ='selected'"; break; case "grid": if (function_exists('product_display_grid')) { $product_view3 = "selected ='selected'"; break; } case "list": if (function_exists('product_display_list')) { $product_view2 = "selected ='selected'"; break; } default: $product_view0 = "selected ='selected'"; break; } $output .= " <tr>\n\r"; $output .= " <td>\n\r"; $output .= __('Category Image', 'wpsc') . ": "; $output .= " </td>\n\r"; $output .= " <td>\n\r"; $output .= "<input type='file' name='image' value='' />"; $output .= " </td>\n\r"; $output .= " </tr>\n\r"; $output .= " </tr>\n\r"; if (function_exists("getimagesize")) { if ($product['image'] != '') { $imagepath = WPSC_CATEGORY_DIR . $product['image']; $imagetype = @getimagesize($imagepath); //previously exif_imagetype() $output .= " <tr>\n\r"; $output .= " <td>\n\r"; $output .= " </td>\n\r"; $output .= " <td>\n\r"; $output .= __('Height', 'wpsc') . ":<input type='text' size='6' name='height' value='" . $imagetype[1] . "' /> " . __('Width', 'wpsc') . ":<input type='text' size='6' name='width' value='" . $imagetype[0] . "' /><br /><span class='wpscsmall description'>{$nzshpcrt_imagesize_info}</span><br />\n\r"; $output .= "<span class='wpscsmall description'>" . __('You can upload thumbnail images for each group. To display Group details in your shop you must configure these settings under <a href="admin.php?page=wpsc-settings&tab=presentation">Presentation Settings</a>.', 'wpsc') . "</span>\n\r"; $output .= " </td>\n\r"; $output .= " </tr>\n\r"; } else { $output .= " <tr>\n\r"; $output .= " <td>\n\r"; $output .= " </td>\n\r"; $output .= " <td>\n\r"; $output .= __('Height', 'wpsc') . ":<input type='text' size='6' name='height' value='" . get_option('product_image_height') . "' /> " . __('Width', 'wpsc') . ":<input type='text' size='6' name='width' value='" . get_option('product_image_width') . "' /><br /><span class='wpscsmall description'>{$nzshpcrt_imagesize_info}</span><br />\n\r"; $output .= "<span class='wpscsmall description'>" . __('You can upload thumbnail images for each group. To display Group details in your shop you must configure these settings under <a href="admin.php?page=wpsc-settings&tab=presentation">Presentation Settings</a>.', 'wpsc') . "</span>\n\r"; $output .= " </td>\n\r"; $output .= " </tr>\n\r"; } } $output .= " <tr>\n\r"; $output .= " <td>\n\r"; $output .= __('Delete Image', 'wpsc') . ": "; $output .= " </td>\n\r"; $output .= " <td>\n\r"; $output .= "<input type='checkbox' name='deleteimage' value='1' />"; $output .= " </td>\n\r"; $output .= " </tr>\n\r"; $output .= " </tr>\n\r"; /* START OF TARGET MARKET SELECTION */ $countrylist = $wpdb->get_results("SELECT id,country,visible FROM `" . WPSC_TABLE_CURRENCY_LIST . "` ORDER BY country ASC ", ARRAY_A); $selectedCountries = $wpdb->get_col("SELECT countryid FROM `" . WPSC_TABLE_CATEGORY_TM . "` WHERE categoryid=" . $product['id'] . " AND visible= 1"); // exit('<pre>'.print_r($countrylist,true).'</pre><br /><pre>'.print_r($selectedCountries,true).'</pre>'); $output .= " <tr>\n\r"; $output .= " \t<td colspan='2'><h4>Target Market Restrictions</h4></td></tr><tr><td> </td></tr><tr>\n\r"; $output .= " \t<td>\n\r"; $output .= __('Target Markets', 'wpsc') . ":\n\r"; $output .= " \t</td>\n\r"; $output .= " \t<td>\n\r"; if (@extension_loaded('suhosin')) { $output .= "<em>" . __("The Target Markets feature has been disabled because you have the Suhosin PHP extension installed on this server. If you need to use the Target Markets feature then disable the suhosin extension, if you can not do this, you will need to contact your hosting provider.\r\n\t\t\t", 'wpsc') . "</em>"; } else { $output .= "<span>Select: <a href='' class='wpsc_select_all'>All</a> <a href='' class='wpsc_select_none'>None</a></span><br />"; $output .= " \t<div id='resizeable' class='ui-widget-content multiple-select'>\n\r"; foreach ($countrylist as $country) { if (in_array($country['id'], $selectedCountries)) { $output .= " <input type='checkbox' name='countrylist2[]' value='" . $country['id'] . "' checked='" . $country['visible'] . "' />" . $country['country'] . "<br />\n\r"; } else { $output .= " <input type='checkbox' name='countrylist2[]' value='" . $country['id'] . "' />" . $country['country'] . "<br />\n\r"; } } $output .= " </div><br /><br />"; $output .= " <span class='wpscsmall description'>Select the markets you are selling this category to.<span>\n\r"; } $output .= " </td>\n\r"; $output .= " </tr>\n\r"; //////// $output .= " <tr>\n\r"; $output .= " \t<td colspan='2' class='category_presentation_settings'>\n\r"; $output .= " \t\t<h4>" . __('Presentation Settings', 'wpsc') . "</h4>\n\r"; $output .= " \t\t<span class='small'>" . __('To over-ride the presentation settings for this group you can enter in your prefered settings here', 'wpsc') . "</span>\n\r"; $output .= " \t</td>\n\r"; $output .= " </tr>\n\r"; $output .= " <tr>\n\r"; $output .= " \t<td>\n\r"; $output .= " \t" . __('Catalog View', 'wpsc') . ":\n\r"; $output .= " \t</td>\n\r"; $output .= " \t<td>\n\r"; $output .= " \t\t<select name='display_type'>\n\r"; $output .= " \t\t\t<option value='' {$product_view0} >" . __('Please select', 'wpsc') . "</option>\n\r"; $output .= " \t\t\t<option value='default' {$product_view1} >" . __('Default View', 'wpsc') . "</option>\n\r"; if (function_exists('product_display_list')) { $output .= " \t\t\t<option value='list' " . $product_view2 . ">" . __('List View', 'wpsc') . "</option>\n\r"; } else { $output .= " \t\t\t<option value='list' disabled='disabled' " . $product_view2 . ">" . __('List View', 'wpsc') . "</option>\n\r"; } if (function_exists('product_display_grid')) { $output .= " \t\t\t<option value='grid' " . $product_view3 . ">" . __('Grid View', 'wpsc') . "</option>\n\r"; } else { $output .= " \t\t\t<option value='grid' disabled='disabled' " . $product_view3 . ">" . __('Grid View', 'wpsc') . "</option>\n\r"; } $output .= " \t\t</select>\n\r"; $output .= " \t</td>\n\r"; $output .= " </tr>\n\r"; if (function_exists("getimagesize")) { $output .= " <tr>\n\r"; $output .= " <td>\n\r"; $output .= __('Thumbnail Size', 'wpsc') . ": "; $output .= " </td>\n\r"; $output .= " <td>\n\r"; $output .= __('Height', 'wpsc') . ": <input type='text' value='" . $product['image_height'] . "' name='product_height' size='6'/> "; $output .= __('Width', 'wpsc') . ": <input type='text' value='" . $product['image_width'] . "' name='product_width' size='6'/> <br/>"; $output .= " </td>\n\r"; $output .= " </tr>\n\r"; } $output .= " <tr>\n\r"; $output .= " \t<td colspan='2' class='category_presentation_settings'>\n\r"; $output .= " \t\t<h4>" . __('Checkout Settings', 'wpsc') . "</h4>\n\r"; //$output .= " <span class='small'>".__('To over-ride the presentation settings for this group you can enter in your prefered settings here', 'wpsc')."</span>\n\r"; $output .= " \t</td>\n\r"; $output .= " </tr>\n\r"; $used_additonal_form_set = wpsc_get_categorymeta($product['id'], 'use_additonal_form_set'); $output .= " <tr>\n\r"; $output .= " <td>\n\r"; $output .= __("This category requires additional checkout form fields", 'wpsc') . ": "; $output .= " </td>\n\r"; $output .= " <td>\n\r"; $output .= " <select name='use_additonal_form_set'>\n\r"; $output .= " \t<option value=''>" . __("None", 'wpsc') . "</option>\n\r"; $checkout_sets = get_option('wpsc_checkout_form_sets'); unset($checkout_sets[0]); foreach ((array) $checkout_sets as $key => $value) { $selected_state = ""; if ($used_additonal_form_set == $key) { $selected_state = "selected='selected'"; } $output .= " <option {$selected_state} value='{$key}'>" . stripslashes($value) . "</option>\n\r"; } $output .= " </select>\n\r"; //$output .= " <label><input type='radio' value='1' name='uses_additonal_forms' ".(($uses_additional_forms == true) ? "checked='checked'" : "")." />".__("Yes",'wpsc')."</label>"; //$output .= " <label><input type='radio' value='0' name='uses_additonal_forms' ".(($uses_additional_forms != true) ? "checked='checked'" : "")." />".__("No",'wpsc')."</label>"; $output .= " </td>\n\r"; $output .= " </tr>\n\r"; $output .= " <tr>"; $output .= " \t<td colspan='2'>\t\t\t\t\t\t</td>"; $output .= " </tr>"; $uses_billing_address = (bool) wpsc_get_categorymeta($product['id'], 'uses_billing_address'); $output .= " <tr>\n\r"; $output .= " <td>\n\r"; $output .= __("Products in this category use the billing address to calculate shipping", 'wpsc') . ": "; $output .= " </td>\n\r"; $output .= " <td>\n\r"; $output .= " <label><input type='radio' value='1' name='uses_billing_address' " . ($uses_billing_address == true ? "checked='checked'" : "") . " />" . __("Yes", 'wpsc') . "</label>"; $output .= " <label><input type='radio' value='0' name='uses_billing_address' " . ($uses_billing_address != true ? "checked='checked'" : "") . " />" . __("No", 'wpsc') . "</label>"; $output .= " </td>\n\r"; $output .= " </tr>\n\r"; $output .= " <tr>\n\r"; $output .= " <td>\n\r"; $output .= " </td>\n\r"; $output .= " <td class='last_row'>\n\r"; $output .= "<input type='hidden' name='prodid' value='" . $product['id'] . "' />"; $output .= "<input type='hidden' name='submit_action' value='edit' />"; $output .= "<input class='button-primary' style='float:left;' type='submit' name='submit' value='" . __('Update Category', 'wpsc') . "' />"; $output .= "<a class='delete_button' href='" . add_query_arg('deleteid', $product['id'], 'admin.php?page=wpsc-edit-groups') . "' onclick=\"return conf();\" >" . __('Delete', 'wpsc') . "</a>"; $output .= " </td>\n\r"; $output .= " </tr>\n\r"; $output .= " </table>\n\r"; return $output; }
/** * Checks the category slug for a display type, if none set returns default * << May need reworking to be more specific to the taxonomy type >> * @access public * * @since 3.8 * @param $slug(string) * @return $slug either from db or 'default' if none set */ function wpsc_get_the_category_display($slug) { global $wpdb; $default_display_type = get_option('product_view'); if (!empty($slug) && is_string($slug)) { $category_id = wpsc_get_the_category_id($slug, 'slug'); $display_type = wpsc_get_categorymeta($category_id, 'display_type'); } if (!empty($display_type)) { return $display_type; } else { return $default_display_type; } }
function get_item_shipping(&$cart_item) { global $wpdb, $wpsc_cart; $unit_price = $cart_item->unit_price; $quantity = $cart_item->quantity; $weight = $cart_item->weight; $product_id = $cart_item->product_id; $uses_billing_address = false; foreach ((array) $cart_item->category_id_list as $category_id) { $uses_billing_address = (bool) wpsc_get_categorymeta($category_id, 'uses_billing_address'); if ($uses_billing_address === true) { break; /// just one true value is sufficient } } if (is_numeric($product_id) && get_option('do_not_use_shipping') != 1) { if ($uses_billing_address == true) { $country_code = $wpsc_cart->selected_country; } else { $country_code = $wpsc_cart->delivery_country; } $product_list = $wpdb->get_row("SELECT * FROM `" . WPSC_TABLE_PRODUCT_LIST . "` WHERE `id`='{$product_id}' LIMIT 1", ARRAY_A); if ($product_list['no_shipping'] == 0) { //if the item has shipping if ($country_code == get_option('base_country')) { $additional_shipping = $product_list['pnp']; } else { $additional_shipping = $product_list['international_pnp']; } $shipping = $quantity * $additional_shipping; } else { //if the item does not have shipping $shipping = 0; } } else { //if the item is invalid or all items do not have shipping $shipping = 0; } return $shipping; }