本文整理汇总了PHP中wpsc_product_has_children函数的典型用法代码示例。如果您正苦于以下问题:PHP wpsc_product_has_children函数的具体用法?PHP wpsc_product_has_children怎么用?PHP wpsc_product_has_children使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wpsc_product_has_children函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: wpsc_additional_column_data
/**
* wpsc_additional_column_data.
*
* @access public
* @param (array) $column
* @return void
* @todo Need to check titles / alt tags ( I don't think thumbnails have any in this code )
* @desc Switch function to generate columns the right way...no more UI hacking!
*
*/
function wpsc_additional_column_data($column, $post_id)
{
$post = get_post($post_id);
$is_parent = wpsc_product_has_children($post_id);
$column = strtolower($column);
do_action("wpsc_manage_products_column_{$column}", $post, $post_id, $is_parent);
}
开发者ID:pankajsinghjarial,项目名称:SYLC,代码行数:17,代码来源:display-items.page.php
示例2: wpsc_product_row
//.........这里部分代码省略.........
?>
<?php
} else {
echo esc_html($title);
}
_post_states($product);
$product_alert = apply_filters('wpsc_product_alert', array(false, ''), $product);
if (!empty($product_alert['messages'])) {
$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_CORE_IMAGES_URL;
?>
/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'];
}
?>
</strong>
<?php
$has_var = '';
if (!$parent_product && wpsc_product_has_children($product->ID)) {
$has_var = 'wpsc_has_variation';
}
$actions = array();
if ($current_user_can_edit_this_product && 'trash' != $product->post_status) {
$actions['edit'] = '<a class="edit-product" href="' . $edit_link . '" title="' . esc_attr__('Edit this product', 'wp-e-commerce') . '">' . __('Edit', 'wp-e-commerce') . '</a>';
//commenting this out for now as we are trying new variation ui quick edit boxes are open by default so we dont need this link.
//$actions['quick_edit'] = "<a class='wpsc_editinline ".$has_var."' title='".esc_attr(__('Quick Edit', 'wp-e-commerce'))."' href='#'>".__('Quick Edit', 'wp-e-commerce')."</a>";
}
$actions = apply_filters('post_row_actions', $actions, $product);
$action_count = count($actions);
$i = 0;
echo '<div class="row-actions">';
foreach ($actions as $action => $link) {
++$i;
$i == $action_count ? $sep = '' : ($sep = ' | ');
echo "<span class='{$action}'>{$link}{$sep}</span>";
}
echo '</div>';
?>
</td>
<?php
break;
case 'image':
/* !image case */
?>
<td class="product-image ">
<?php
$attachment_args = array('post_type' => 'attachment', 'numberposts' => 1, 'post_status' => null, 'post_parent' => $product->ID, 'orderby' => 'menu_order', 'order' => 'ASC');
if (isset($product->ID) && has_post_thumbnail($product->ID)) {
echo get_the_post_thumbnail($product->ID, 'admin-product-thumbnails');
} else {
$image_url = WPSC_CORE_IMAGES_URL . "/no-image-uploaded.gif";
开发者ID:AngryBird3,项目名称:WP-e-Commerce,代码行数:67,代码来源:wpsc-deprecated.php
示例3: get_data_wpsc_38
//.........这里部分代码省略.........
}
$product_type = !is_wp_error($product_type) ? !empty($product_type[0]) ? $product_type[0] : '' : '';
// Code for WP_Error and empty check
$record->category = $record->post_parent > 0 && $product_type == 'simple' || $record->post_parent == 0 ? !empty($record->category) ? $record->category : '' : '';
// To hide category name from Product's variations
$prod_meta_values = explode('###', $record->prod_othermeta_value);
$prod_meta_key = explode('###', $record->prod_othermeta_key);
if (count($prod_meta_key) != count($prod_meta_values)) {
continue;
}
$prod_meta_key_values = array_combine($prod_meta_key, $prod_meta_values);
if (intval($record->post_parent) > 0) {
$title = get_post_field('post_title', $record->post_parent, 'raw');
$variation_terms = wp_get_object_terms($record->id, 'wpsc-variation', array('fields' => 'names', 'orderby' => 'name', 'order' => 'ASC'));
$record->post_title = $title . ' - (' . implode(', ', $variation_terms) . ')';
}
// $thumbnail = isset( $prod_meta_key_values['_thumbnail_id'] ) ? wp_get_attachment_image_src( $prod_meta_key_values['_thumbnail_id'], $image_size ) : '';
// $record->thumbnail = ( $thumbnail[0] != '' ) ? $thumbnail[0] : false;
$thumbnail = wpsc_the_product_thumbnail('', '', $record->id, '');
$record->thumbnail = $thumbnail != '' ? $thumbnail : false;
foreach ($prod_meta_key_values as $key => $value) {
if (is_serialized($value)) {
$unsez_data = unserialize($value);
$unsez_data['weight'] = wpsc_convert_weight($unsez_data['weight'], "pound", $unsez_data['weight_unit']);
// get the weight by converting it to repsective unit
foreach ((array) $unsez_data as $meta_key => $meta_value) {
if (is_array($meta_value)) {
foreach ($meta_value as $sub_metakey => $sub_metavalue) {
in_array($sub_metakey, $view_columns) ? $record->{$sub_metakey} = $sub_metavalue : '';
}
} else {
in_array($meta_key, $view_columns) ? $record->{$meta_key} = $meta_value : '';
}
if ($record->post_parent == 0 && wpsc_product_has_children($record->id)) {
if ($show_variation == true) {
$record->_wpsc_price = $record->_wpsc_special_price = ' ';
} elseif ($show_variation == false) {
$parent_price = version_compare(WPSC_VERSION, '3.8.10', '>=') == 1 ? wpsc_product_variation_price_from($record->id) : wpsc_product_variation_price_available($record->id);
$record->_wpsc_price = substr($parent_price, 1, strlen($parent_price));
$record->_wpsc_special_price = substr($parent_price, 1, strlen($parent_price));
}
}
}
unset($prod_meta_key_values[$value]);
} else {
in_array($key, $view_columns) ? $record->{$key} = $value : '';
}
}
unset($record->prod_othermeta_value);
unset($record->prod_meta);
unset($record->prod_othermeta_key);
}
}
} elseif ($active_module == 'Orders') {
if (SMPRO == true && function_exists('get_packing_slip') && (!empty($_POST['label']) && $_POST['label'] == 'getPurchaseLogs')) {
$log_ids_arr = json_decode(stripslashes($_POST['log_ids']));
if (is_array($log_ids_arr)) {
$log_ids = implode(', ', $log_ids_arr);
}
get_packing_slip($log_ids, $log_ids_arr);
} else {
if (isset($_POST['searchText']) && $_POST['searchText'] != '') {
$search_on = $wpdb->_real_escape(trim($_POST['searchText']));
}
if (isset($_POST['fromDate'])) {
$from_date = strtotime($_POST['fromDate']);
开发者ID:JaneJieYing,项目名称:kiddoonline_dvlpment,代码行数:67,代码来源:json38.php
示例4: wpsc_stock_control_forms
function wpsc_stock_control_forms()
{
global $post, $wpdb, $variations_processor, $wpsc_product_defaults;
$product_data = get_post_custom($post->ID);
$product_data['meta'] = maybe_unserialize($product_data);
foreach ($product_data['meta'] as $meta_key => $meta_value) {
$product_data['meta'][$meta_key] = $meta_value[0];
}
$product_meta = array();
if (!empty($product_data['_wpsc_product_metadata'])) {
$product_meta = maybe_unserialize($product_data["_wpsc_product_metadata"][0]);
}
// this is to make sure after upgrading to 3.8.9, products will have
// "notify_when_none_left" enabled by default if "unpublish_when_none_left"
// is enabled.
if (!isset($product_meta['notify_when_none_left'])) {
$product_meta['notify_when_none_left'] = 0;
if (!empty($product_meta['unpublish_when_none_left'])) {
$product_meta['notify_when_none_left'] = 1;
}
}
if (!isset($product_meta['unpublish_when_none_left'])) {
$product_meta['unpublish_when_none_left'] = '';
}
// Display live title if stock is set
if (isset($product_data['meta']['_wpsc_stock']) && is_numeric($product_data['meta']['_wpsc_stock'])) {
$live_title = '<em id="wpsc_product_stock_metabox_live_title" class="wpsc_metabox_live_title">';
$live_title .= sprintf('<p><span>%s</span> %s</p>', wpsc_format_number($product_data['meta']['_wpsc_stock'], 0), _x('left in stock', 'live preview of stock remaining in admin', 'wp-e-commerce'));
$live_title .= '</em>';
echo $live_title;
}
if (!empty($product_meta['unpublish_when_none_left']) && !isset($product_meta['notify_when_none_left'])) {
}
?>
<label for="wpsc_sku"><abbr title="<?php
esc_attr_e('Stock Keeping Unit', 'wp-e-commerce');
?>
"><?php
esc_html_e('SKU:', 'wp-e-commerce');
?>
</abbr></label>
<?php
if (!isset($product_data['meta']['_wpsc_sku'])) {
$product_data['meta']['_wpsc_sku'] = $wpsc_product_defaults['meta']['sku'];
}
?>
<br />
<input size='32' type='text' class='text' id="wpsc_sku" name='meta[_wpsc_sku]' value='<?php
echo esc_html($product_data['meta']['_wpsc_sku']);
?>
' />
<br style="clear:both" />
<?php
if (!isset($product_data['meta']['_wpsc_stock'])) {
$product_data['meta']['_wpsc_stock'] = '';
}
?>
<br /><input class='limited_stock_checkbox' id='add_form_quantity_limited' type='checkbox' value='yes' <?php
if (is_numeric($product_data['meta']['_wpsc_stock'])) {
echo 'checked="checked"';
} else {
echo '';
}
?>
name='meta[_wpsc_limited_stock]' />
<label for='add_form_quantity_limited' class='small'><?php
esc_html_e('Product has limited stock', 'wp-e-commerce');
?>
</label>
<?php
if ($post->ID > 0) {
if (is_numeric($product_data['meta']['_wpsc_stock'])) {
?>
<div class='edit_stock' style='display: block;'> <?php
} else {
?>
<div class='edit_stock' style='display: none;'><?php
}
?>
<?php
if (wpsc_product_has_children($post->ID)) {
?>
<?php
$stock = wpsc_variations_stock_remaining($post->ID);
?>
<p><?php
echo sprintf(__('This product has variations. To edit the quantity, please use the <a href="%s">Variation Controls</a> below.', 'wp-e-commerce'), '#wpsc_product_variation_forms');
?>
</p>
<p><?php
printf(_n("%s variant item in stock.", "%s variant items in stock.", $stock, 'wp-e-commerce'), $stock);
?>
</p>
<?php
} else {
?>
<div style="margin-bottom:20px;">
<label for="stock_limit_quantity"><?php
esc_html_e('Quantity in stock', 'wp-e-commerce');
?>
//.........这里部分代码省略.........
开发者ID:ashik968,项目名称:digiplot,代码行数:101,代码来源:display-items-functions.php
示例5: get_data_wpsc_38
//.........这里部分代码省略.........
if (intval($record->post_parent) == 0) {
$category_terms = wp_get_object_terms($record->id, 'wpsc_product_category', array('fields' => 'names', 'orderby' => 'name', 'order' => 'ASC'));
$record->category = implode(', ', $category_terms);
// To hide category name from Product's variations
}
$prod_meta_values = explode('###', $record->prod_othermeta_value);
$prod_meta_key = explode('###', $record->prod_othermeta_key);
if (count($prod_meta_key) != count($prod_meta_values)) {
continue;
}
$prod_meta_key_values = array_combine($prod_meta_key, $prod_meta_values);
if (intval($record->post_parent) > 0) {
$title = get_post_field('post_title', $record->post_parent, 'raw');
$variation_terms = wp_get_object_terms($record->id, 'wpsc-variation', array('fields' => 'names', 'orderby' => 'name', 'order' => 'ASC'));
$record->post_title = $title . ' - (' . implode(', ', $variation_terms) . ')';
}
// $thumbnail = isset( $prod_meta_key_values['_thumbnail_id'] ) ? wp_get_attachment_image_src( $prod_meta_key_values['_thumbnail_id'], $image_size ) : '';
// $record->thumbnail = ( $thumbnail[0] != '' ) ? $thumbnail[0] : false;
$thumbnail = wpsc_the_product_thumbnail('', '', $record->id, '');
$record->thumbnail = $thumbnail != '' ? $thumbnail : false;
foreach ($prod_meta_key_values as $key => $value) {
if (is_serialized($value)) {
$unsez_data = unserialize($value);
$unsez_data['weight'] = wpsc_convert_weight($unsez_data['weight'], "pound", $unsez_data['weight_unit']);
// get the weight by converting it to repsective unit
foreach ((array) $unsez_data as $meta_key => $meta_value) {
if (is_array($meta_value)) {
foreach ($meta_value as $sub_metakey => $sub_metavalue) {
in_array($sub_metakey, $view_columns) ? $record->{$sub_metakey} = $sub_metavalue : '';
}
} else {
in_array($meta_key, $view_columns) ? $record->{$meta_key} = $meta_value : '';
}
if ($record->post_parent == 0 && wpsc_product_has_children($record->id)) {
if ($show_variation == true) {
$record->_wpsc_price = $record->_wpsc_special_price = ' ';
} elseif ($show_variation == false) {
$parent_price = wpsc_product_variation_price_available($record->id);
$record->_wpsc_price = substr($parent_price, 1, strlen($parent_price));
$record->_wpsc_special_price = substr($parent_price, 1, strlen($parent_price));
}
}
}
unset($prod_meta_key_values[$value]);
} else {
in_array($key, $view_columns) ? $record->{$key} = $value : '';
}
}
unset($record->prod_othermeta_value);
unset($record->prod_meta);
unset($record->prod_othermeta_key);
}
}
} elseif ($active_module == 'Orders') {
if (SMPRO == true && function_exists('get_packing_slip') && $_POST['label'] == 'getPurchaseLogs') {
$log_ids_arr = json_decode(stripslashes($_POST['log_ids']));
if (is_array($log_ids_arr)) {
$log_ids = implode(', ', $log_ids_arr);
}
get_packing_slip($log_ids, $log_ids_arr);
} else {
if (isset($_POST['searchText']) && $_POST['searchText'] != '') {
$search_on = $wpdb->_real_escape(trim($_POST['searchText']));
}
if (isset($_POST['fromDate'])) {
$from_date = strtotime($_POST['fromDate']);
开发者ID:bulats,项目名称:chef,代码行数:67,代码来源:json38.php
示例6: wpsc_specials
/**
* 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(" ", '"', "'", '"', '''), 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
//.........这里部分代码省略.........
开发者ID:ashik968,项目名称:digiplot,代码行数:101,代码来源:specials_widget.php
示例7: wpsc_stock_control_forms
function wpsc_stock_control_forms()
{
global $post, $wpdb, $variations_processor, $wpsc_product_defaults;
$product_data = get_post_custom($post->ID);
$product_data['meta'] = maybe_unserialize($product_data);
foreach ($product_data['meta'] as $meta_key => $meta_value) {
$product_data['meta'][$meta_key] = $meta_value[0];
}
$product_meta = array();
if (!empty($product_data["_wpsc_product_metadata"])) {
$product_meta = maybe_unserialize($product_data["_wpsc_product_metadata"][0]);
}
// this is to make sure after upgrading to 3.8.9, products will have
// "notify_when_none_left" enabled by default if "unpublish_when_none_left"
// is enabled.
if (!isset($product_meta['notify_when_none_left'])) {
$product_meta['notify_when_none_left'] = 0;
if (!empty($product_meta['unpublish_when_none_left'])) {
$product_meta['notify_when_none_left'] = 1;
}
}
if (!isset($product_meta['unpublish_when_none_left'])) {
$product_meta['unpublish_when_none_left'] = '';
}
if (!empty($product_meta['unpublish_when_none_left']) && !isset($product_meta['notify_when_none_left'])) {
}
?>
<label for="wpsc_sku"><abbr title="<?php
esc_attr_e('Stock Keeping Unit', 'wpsc');
?>
"><?php
esc_html_e('SKU:', 'wpsc');
?>
</abbr></label>
<?php
if (!isset($product_data['meta']['_wpsc_sku'])) {
$product_data['meta']['_wpsc_sku'] = $wpsc_product_defaults['meta']['sku'];
}
?>
<br />
<input size='32' type='text' class='text' id="wpsc_sku" name='meta[_wpsc_sku]' value='<?php
echo esc_html($product_data['meta']['_wpsc_sku']);
?>
' />
<br style="clear:both" />
<?php
if (!isset($product_data['meta']['_wpsc_stock'])) {
$product_data['meta']['_wpsc_stock'] = '';
}
?>
<br /><input class='limited_stock_checkbox' id='add_form_quantity_limited' type='checkbox' value='yes' <?php
if (is_numeric($product_data['meta']['_wpsc_stock'])) {
echo 'checked="checked"';
} else {
echo '';
}
?>
name='meta[_wpsc_limited_stock]' />
<label for='add_form_quantity_limited' class='small'><?php
esc_html_e('I have limited stock for this Product', 'wpsc');
?>
</label>
<?php
if ($post->ID > 0) {
if (is_numeric($product_data['meta']['_wpsc_stock'])) {
?>
<div class='edit_stock' style='display: block;'> <?php
} else {
?>
<div class='edit_stock' style='display: none;'><?php
}
?>
<?php
if (wpsc_product_has_children($post->ID)) {
?>
<?php
$stock = wpsc_variations_stock_remaining($post->ID);
?>
<p><?php
esc_html_e('This Product has variations, to edit the quantity please use the Variation Controls below.', 'wpsc');
?>
</p>
<p><?php
printf(_n("%s variant item in stock.", "%s variant items in stock.", $stock, 'wpsc'), $stock);
?>
</p>
<?php
} else {
?>
<label for="stock_limit_quantity"><?php
esc_html_e('Quantity:', 'wpsc');
?>
</label>
<input type='text' id="stock_limit_quantity" name='meta[_wpsc_stock]' size='3' value='<?php
echo $product_data['meta']['_wpsc_stock'];
?>
' class='stock_limit_quantity' />
<?php
$remaining_quantity = wpsc_get_remaining_quantity($post->ID);
//.........这里部分代码省略.........
开发者ID:pankajsinghjarial,项目名称:SYLC,代码行数:101,代码来源:display-items-functions.php
示例8: wpsc_check_weight
function wpsc_check_weight($state, $product)
{
global $wpdb;
$custom_shipping = (array) get_option('custom_shipping_options');
$has_no_weight = false;
$shipping_modules = array();
$product_meta = get_product_meta($product->ID, 'product_metadata', true);
if (!$product->post_parent && wpsc_product_has_children($product->ID)) {
return $state;
}
// only do anything if UPS is on and shipping is used
if (array_search('ups', $custom_shipping) !== false) {
$shipping_modules[] = 'UPS';
}
if (array_search('weightrate', $custom_shipping) !== false) {
$shipping_modules[] = 'Weight Rate';
}
if (array_search('usps', $custom_shipping) !== false) {
$shipping_modules[] = 'Weight Rate';
}
if (empty($product_meta['no_shipping']) && !empty($shipping_modules)) {
if ($product_meta['weight'] == 0) {
// otherwise, use the weight from the products list table
$has_no_weight = true;
}
if ($has_no_weight === true) {
$state['state'] = true;
$state['messages'][] = implode(',', $shipping_modules) . __(' does not support products without a weight set. Please either disable shipping for this product or give it a weight', 'wpsc');
}
}
return array('state' => $state['state'], 'messages' => $state['messages']);
}
开发者ID:nikitanaumov,项目名称:WP-e-Commerce,代码行数:32,代码来源:processing.functions.php
示例9: wpsc_save_quickedit_box
/**
* wpsc_save_quickedit_box function
* Saves input for the various meta in the quick edit boxes
*
* @todo UI
* @todo Data validation / sanitization / security
* @todo AJAX should probably return weight unit
* @return $post_id (int) Post ID
*/
function wpsc_save_quickedit_box($post_id)
{
global $current_screen;
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE || empty($current_screen) || $current_screen->id != 'edit-wpsc-product' || !defined('DOING_AJAX') || !DOING_AJAX) {
return;
}
$is_parent = (bool) wpsc_product_has_children($post_id);
$product_meta = get_post_meta($post_id, '_wpsc_product_metadata', true);
$weight_unit = $product_meta["weight_unit"];
$weight = wpsc_convert_weight($_POST["weight"], $weight_unit, "pound", true);
if (isset($product_meta["weight"])) {
unset($product_meta["weight"]);
}
$product_meta["weight"] = $weight;
if (!$is_parent) {
update_post_meta($post_id, '_wpsc_product_metadata', $product_meta);
if (is_numeric($_POST['stock'])) {
update_post_meta($post_id, '_wpsc_stock', $_POST['stock']);
} else {
update_post_meta($post_id, '_wpsc_stock', '');
}
update_post_meta($post_id, '_wpsc_price', $_POST['price']);
update_post_meta($post_id, '_wpsc_special_price', $_POST['sale_price']);
}
if ($_POST['sku'] == __('N/A', 'wpsc')) {
update_post_meta($post_id, '_wpsc_sku', '');
} else {
update_post_meta($post_id, '_wpsc_sku', $_POST['sku']);
}
return $post_id;
}
开发者ID:nikitanaumov,项目名称:WP-e-Commerce,代码行数:40,代码来源:display-items-functions.php
示例10: wpsc_additional_column_data
/**
* wpsc_additional_column_data.
*
* @access public
* @param (array) $column
* @return void
* @todo Need to check titles / alt tags ( I don't think thumbnails have any in this code )
* @desc Switch function to generate columns the right way...no more UI hacking!
*
*/
function wpsc_additional_column_data($column)
{
global $post;
$is_parent = (bool) wpsc_product_has_children($post->ID);
switch ($column) {
case 'image':
$attached_images = get_posts(array('post_type' => 'attachment', 'numberposts' => 1, 'post_parent' => $post->ID, 'orderby' => 'menu_order', 'order' => 'ASC'));
if (isset($post->ID) && has_post_thumbnail($post->ID)) {
echo get_the_post_thumbnail($post->ID, 'admin-product-thumbnails');
} else {
if (!empty($attached_images)) {
$attached_image = $attached_images[0];
$src = wp_get_attachment_url($attached_image->ID);
?>
<div style='width:38px; height:38px; overflow:hidden;'>
<img src='<?php
echo $src;
?>
' alt='<?php
_e('Drag to a new position', 'wpsc');
?>
' width='38' height='38' />
</div>
<?php
} else {
$image_url = WPSC_CORE_IMAGES_URL . "/no-image-uploaded.gif";
?>
<img src='<?php
echo $image_url;
?>
' alt='<?php
_e('Drag to a new position', 'wpsc');
?>
' width='38' height='38' />
<?php
}
}
break;
case 'weight':
if ($is_parent) {
_e('N/A', 'wpsc');
} else {
$product_data['meta'] = array();
$product_data['meta'] = get_post_meta($post->ID, '');
foreach ($product_data['meta'] as $meta_name => $meta_value) {
$product_data['meta'][$meta_name] = maybe_unserialize(array_pop($meta_value));
}
$product_data['transformed'] = array();
if (!isset($product_data['meta']['_wpsc_product_metadata']['weight'])) {
$product_data['meta']['_wpsc_product_metadata']['weight'] = "";
}
if (!isset($product_data['meta']['_wpsc_product_metadata']['weight_unit'])) {
$product_data['meta']['_wpsc_product_metadata']['weight_unit'] = "";
}
$product_data['transformed']['weight'] = wpsc_convert_weight($product_data['meta']['_wpsc_product_metadata']['weight'], "pound", $product_data['meta']['_wpsc_product_metadata']['weight_unit']);
$weight = $product_data['transformed']['weight'];
if ($weight == '') {
$weight = '0';
}
$unit = $product_data['meta']['_wpsc_product_metadata']['weight_unit'];
switch ($unit) {
case "pound":
$unit = __(" lbs.", "wpsc");
break;
case "ounce":
$unit = __(" oz.", "wpsc");
break;
case "gram":
$unit = __(" g", "wpsc");
break;
case "kilograms":
case "kilogram":
$unit = __(" kgs.", "wpsc");
break;
}
echo $weight . $unit;
echo '<div id="inline_' . $post->ID . '_weight" class="hidden">' . $weight . '</div>';
}
break;
case 'stock':
$stock = get_post_meta($post->ID, '_wpsc_stock', true);
if ($stock == '') {
$stock = __('N/A', 'wpsc');
}
if (!$is_parent) {
echo $stock;
echo '<div id="inline_' . $post->ID . '_stock" class="hidden">' . $stock . '</div>';
} else {
echo '~' . wpsc_variations_stock_remaining($post->ID);
}
//.........这里部分代码省略.........
开发者ID:nikitanaumov,项目名称:WP-e-Commerce,代码行数:101,代码来源:display-items.page.php
注:本文中的wpsc_product_has_children函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论