• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wc_get_product_types函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中wc_get_product_types函数的典型用法代码示例。如果您正苦于以下问题:PHP wc_get_product_types函数的具体用法?PHP wc_get_product_types怎么用?PHP wc_get_product_types使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了wc_get_product_types函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: wc_get_products

/**
 * Products wrapper for get_posts.
 *
 * This function should be used for product retrieval so that we have a data agnostic
 * way to get a list of products.
 *
 * Args:
 *      status array|string List of statuses to find. Default: any. Options: any, draft, pending, private and publish.
 *      type array|string Product type, e.g. Default: all. Options: all, simple, external, variable, variation, grouped.
 *      parent int post/product parent
 *      sku string Limit result set to products with specific SKU.
 *      category array Limit result set to products assigned to specific categories by slug
 *                     e.g. array('hoodie', 'cap', 't-shirt').
 *      tag array Limit result set to products assigned to specific tags (by slug)
 *                e.g. array('funky', 'retro', 'designer')
 *      shipping_class array Limit results set to products in specific shipping classes (by slug)
 *                           e.g. array('standard', 'next-day')
 *      limit int Maximum of products to retrieve.
 *      offset int Offset of products to retrieve.
 *      page int Page of products to retrieve. Ignored when using the 'offset' arg.
 *      exclude array Product IDs to exclude from the query.
 *      orderby string Order by date, title, id, modified, rand etc
 *      order string ASC or DESC
 *      return string Type of data to return. Allowed values:
 *          ids array of Product ids
 *          objects array of product objects (default)
 *      paginate bool If true, the return value will be an array with values:
 *          'products'      => array of data (return value above),
 *          'total'         => total number of products matching the query
 *          'max_num_pages' => max number of pages found
 *
 * @since  2.7.0
 * @param  array $args Array of args (above)
 * @return array|stdClass Number of pages and an array of product objects if
 *                             paginate is true, or just an array of values.
 */
function wc_get_products($args)
{
    $args = wp_parse_args($args, array('status' => array('draft', 'pending', 'private', 'publish'), 'type' => array_merge(array_keys(wc_get_product_types())), 'parent' => null, 'sku' => '', 'category' => array(), 'tag' => array(), 'limit' => get_option('posts_per_page'), 'offset' => null, 'page' => 1, 'exclude' => array(), 'orderby' => 'date', 'order' => 'DESC', 'return' => 'objects', 'paginate' => false, 'shipping_class' => array()));
    // Handle some BW compatibility arg names where wp_query args differ in naming.
    $map_legacy = array('numberposts' => 'limit', 'post_status' => 'status', 'post_parent' => 'parent', 'posts_per_page' => 'limit', 'paged' => 'page');
    foreach ($map_legacy as $from => $to) {
        if (isset($args[$from])) {
            $args[$to] = $args[$from];
        }
    }
    return WC_Data_Store::load('product')->get_products($args);
}
开发者ID:shivapoudel,项目名称:woocommerce,代码行数:48,代码来源:wc-product-functions.php


示例2: edit_product

 /**
  * Edit a product
  *
  * @since 2.2
  * @param int $id the product ID
  * @param array $data
  * @return array
  */
 public function edit_product($id, $data)
 {
     try {
         if (!isset($data['product'])) {
             throw new WC_API_Exception('woocommerce_api_missing_product_data', sprintf(__('No %1$s data specified to edit %1$s', 'woocommerce'), 'product'), 400);
         }
         $data = $data['product'];
         $id = $this->validate_request($id, 'product', 'edit');
         if (is_wp_error($id)) {
             return $id;
         }
         $data = apply_filters('woocommerce_api_edit_product_data', $data, $this);
         // Product title.
         if (isset($data['title'])) {
             wp_update_post(array('ID' => $id, 'post_title' => wc_clean($data['title'])));
         }
         // Product name (slug).
         if (isset($data['name'])) {
             wp_update_post(array('ID' => $id, 'post_name' => sanitize_title($data['name'])));
         }
         // Product status.
         if (isset($data['status'])) {
             wp_update_post(array('ID' => $id, 'post_status' => wc_clean($data['status'])));
         }
         // Product short description.
         if (isset($data['short_description'])) {
             // Enable short description html tags.
             $post_excerpt = isset($data['enable_html_short_description']) && true === $data['enable_html_short_description'] ? $data['short_description'] : wc_clean($data['short_description']);
             wp_update_post(array('ID' => $id, 'post_excerpt' => $post_excerpt));
         }
         // Product description.
         if (isset($data['description'])) {
             // Enable description html tags.
             $post_content = isset($data['enable_html_description']) && true === $data['enable_html_description'] ? $data['description'] : wc_clean($data['description']);
             wp_update_post(array('ID' => $id, 'post_content' => $post_content));
         }
         // Validate the product type
         if (isset($data['type']) && !in_array(wc_clean($data['type']), array_keys(wc_get_product_types()))) {
             throw new WC_API_Exception('woocommerce_api_invalid_product_type', sprintf(__('Invalid product type - the product type must be any of these: %s', 'woocommerce'), implode(', ', array_keys(wc_get_product_types()))), 400);
         }
         // Check for featured/gallery images, upload it and set it
         if (isset($data['images'])) {
             $this->save_product_images($id, $data['images']);
         }
         // Save product meta fields
         $this->save_product_meta($id, $data);
         // Save variations
         $product = get_product($id);
         if ($product->is_type('variable')) {
             if (isset($data['variations']) && is_array($data['variations'])) {
                 $this->save_variations($id, $data);
             } else {
                 // Just sync variations
                 WC_Product_Variable::sync($id);
             }
         }
         do_action('woocommerce_api_edit_product', $id, $data);
         // Clear cache/transients
         wc_delete_product_transients($id);
         return $this->get_product($id);
     } catch (WC_API_Exception $e) {
         return new WP_Error($e->getErrorCode(), $e->getMessage(), array('status' => $e->getCode()));
     }
 }
开发者ID:haltaction,项目名称:woocommerce,代码行数:72,代码来源:class-wc-api-products.php


示例3: woocommerce_process_product_meta_coupons

 /**
  * Function to save coupon code to database
  *
  * @param int $post_id
  * @param object $post
  */
 public function woocommerce_process_product_meta_coupons($post_id, $post)
 {
     if (empty($post_id) || empty($post) || empty($_POST)) {
         return;
     }
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return;
     }
     if (is_int(wp_is_post_revision($post))) {
         return;
     }
     if (is_int(wp_is_post_autosave($post))) {
         return;
     }
     if (empty($_POST['woocommerce_meta_nonce']) || !wp_verify_nonce($_POST['woocommerce_meta_nonce'], 'woocommerce_save_data')) {
         return;
     }
     if (!current_user_can('edit_post', $post_id)) {
         return;
     }
     if ($post->post_type != 'product') {
         return;
     }
     $valid_product_types = function_exists('wc_get_product_types') ? array_keys(wc_get_product_types()) : array('simple', 'variable', 'subscription', 'variable-subscription');
     if (!empty($_POST['product-type']) && in_array($_POST['product-type'], $valid_product_types)) {
         if (!empty($_POST['_coupon_title'])) {
             if ($this->is_wc_gte_23()) {
                 $coupon_titles = array_filter(array_map('trim', explode(',', $_POST['_coupon_title'])));
             } else {
                 $coupon_titles = $_POST['_coupon_title'];
             }
             update_post_meta($post_id, '_coupon_title', $coupon_titles);
         } else {
             update_post_meta($post_id, '_coupon_title', array());
         }
     }
     if ($_POST['product-type'] == 'subscription' || $_POST['product-type'] == 'variable-subscription') {
         if (isset($_POST['send_coupons_on_renewals'])) {
             update_post_meta($post_id, 'send_coupons_on_renewals', $_POST['send_coupons_on_renewals']);
         } else {
             update_post_meta($post_id, 'send_coupons_on_renewals', 'no');
         }
     }
 }
开发者ID:NerdyDillinger,项目名称:ovrride,代码行数:50,代码来源:woocommerce-smart-coupons.php


示例4: output

    /**
     * Output the metabox.
     *
     * @param WP_Post $post
     */
    public static function output($post)
    {
        global $post, $thepostid;
        wp_nonce_field('woocommerce_save_data', 'woocommerce_meta_nonce');
        $thepostid = $post->ID;
        if ($terms = wp_get_object_terms($post->ID, 'product_type')) {
            $product_type = sanitize_title(current($terms)->name);
        } else {
            $product_type = apply_filters('default_product_type', 'simple');
        }
        $type_box = '<label for="product-type"><select id="product-type" name="product-type"><optgroup label="' . esc_attr__('Product Type', 'woocommerce') . '">';
        foreach (wc_get_product_types() as $value => $label) {
            $type_box .= '<option value="' . esc_attr($value) . '" ' . selected($product_type, $value, false) . '>' . esc_html($label) . '</option>';
        }
        $type_box .= '</optgroup></select></label>';
        $product_type_options = apply_filters('product_type_options', array('virtual' => array('id' => '_virtual', 'wrapper_class' => 'show_if_simple', 'label' => __('Virtual', 'woocommerce'), 'description' => __('Virtual products are intangible and aren\'t shipped.', 'woocommerce'), 'default' => 'no'), 'downloadable' => array('id' => '_downloadable', 'wrapper_class' => 'show_if_simple', 'label' => __('Downloadable', 'woocommerce'), 'description' => __('Downloadable products give access to a file upon purchase.', 'woocommerce'), 'default' => 'no')));
        foreach ($product_type_options as $key => $option) {
            $selected_value = get_post_meta($post->ID, '_' . $key, true);
            if ('' == $selected_value && isset($option['default'])) {
                $selected_value = $option['default'];
            }
            $type_box .= '<label for="' . esc_attr($option['id']) . '" class="' . esc_attr($option['wrapper_class']) . ' tips" data-tip="' . esc_attr($option['description']) . '">' . esc_html($option['label']) . ': <input type="checkbox" name="' . esc_attr($option['id']) . '" id="' . esc_attr($option['id']) . '" ' . checked($selected_value, 'yes', false) . ' /></label>';
        }
        ?>
		<div class="panel-wrap product_data">

			<span class="type_box hidden"> &mdash; <?php 
        echo $type_box;
        ?>
</span>

			<ul class="product_data_tabs wc-tabs">
				<?php 
        $product_data_tabs = apply_filters('woocommerce_product_data_tabs', array('general' => array('label' => __('General', 'woocommerce'), 'target' => 'general_product_data', 'class' => array('hide_if_grouped')), 'inventory' => array('label' => __('Inventory', 'woocommerce'), 'target' => 'inventory_product_data', 'class' => array('show_if_simple', 'show_if_variable', 'show_if_grouped', 'show_if_external')), 'shipping' => array('label' => __('Shipping', 'woocommerce'), 'target' => 'shipping_product_data', 'class' => array('hide_if_virtual', 'hide_if_grouped', 'hide_if_external')), 'linked_product' => array('label' => __('Linked Products', 'woocommerce'), 'target' => 'linked_product_data', 'class' => array()), 'attribute' => array('label' => __('Attributes', 'woocommerce'), 'target' => 'product_attributes', 'class' => array()), 'variations' => array('label' => __('Variations', 'woocommerce'), 'target' => 'variable_product_options', 'class' => array('variations_tab', 'show_if_variable')), 'advanced' => array('label' => __('Advanced', 'woocommerce'), 'target' => 'advanced_product_data', 'class' => array())));
        foreach ($product_data_tabs as $key => $tab) {
            ?>
<li class="<?php 
            echo $key;
            ?>
_options <?php 
            echo $key;
            ?>
_tab <?php 
            echo implode(' ', (array) $tab['class']);
            ?>
">
							<a href="#<?php 
            echo $tab['target'];
            ?>
"><?php 
            echo esc_html($tab['label']);
            ?>
</a>
						</li><?php 
        }
        do_action('woocommerce_product_write_panel_tabs');
        ?>
			</ul>
			<div id="general_product_data" class="panel woocommerce_options_panel"><?php 
        echo '<div class="options_group show_if_external">';
        // External URL
        woocommerce_wp_text_input(array('id' => '_product_url', 'label' => __('Product URL', 'woocommerce'), 'placeholder' => 'http://', 'description' => __('Enter the external URL to the product.', 'woocommerce')));
        // Button text
        woocommerce_wp_text_input(array('id' => '_button_text', 'label' => __('Button text', 'woocommerce'), 'placeholder' => _x('Buy product', 'placeholder', 'woocommerce'), 'description' => __('This text will be shown on the button linking to the external product.', 'woocommerce')));
        echo '</div>';
        echo '<div class="options_group pricing show_if_simple show_if_external hidden">';
        // Price
        woocommerce_wp_text_input(array('id' => '_regular_price', 'label' => __('Regular price', 'woocommerce') . ' (' . get_woocommerce_currency_symbol() . ')', 'data_type' => 'price'));
        // Special Price
        woocommerce_wp_text_input(array('id' => '_sale_price', 'data_type' => 'price', 'label' => __('Sale price', 'woocommerce') . ' (' . get_woocommerce_currency_symbol() . ')', 'description' => '<a href="#" class="sale_schedule">' . __('Schedule', 'woocommerce') . '</a>'));
        // Special Price date range
        $sale_price_dates_from = ($date = get_post_meta($thepostid, '_sale_price_dates_from', true)) ? date_i18n('Y-m-d', $date) : '';
        $sale_price_dates_to = ($date = get_post_meta($thepostid, '_sale_price_dates_to', true)) ? date_i18n('Y-m-d', $date) : '';
        echo '<p class="form-field sale_price_dates_fields">
								<label for="_sale_price_dates_from">' . __('Sale price dates', 'woocommerce') . '</label>
								<input type="text" class="short" name="_sale_price_dates_from" id="_sale_price_dates_from" value="' . esc_attr($sale_price_dates_from) . '" placeholder="' . _x('From&hellip;', 'placeholder', 'woocommerce') . ' YYYY-MM-DD" maxlength="10" pattern="[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])" />
								<input type="text" class="short" name="_sale_price_dates_to" id="_sale_price_dates_to" value="' . esc_attr($sale_price_dates_to) . '" placeholder="' . _x('To&hellip;', 'placeholder', 'woocommerce') . '  YYYY-MM-DD" maxlength="10" pattern="[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])" />
								<a href="#" class="cancel_sale_schedule">' . __('Cancel', 'woocommerce') . '</a>' . wc_help_tip(__('The sale will end at the beginning of the set date.', 'woocommerce')) . '
							</p>';
        do_action('woocommerce_product_options_pricing');
        echo '</div>';
        echo '<div class="options_group show_if_downloadable hidden">';
        ?>
					<div class="form-field downloadable_files">
						<label><?php 
        _e('Downloadable files', 'woocommerce');
        ?>
</label>
						<table class="widefat">
							<thead>
								<tr>
									<th class="sort">&nbsp;</th>
									<th><?php 
        _e('Name', 'woocommerce');
        ?>
//.........这里部分代码省略.........
开发者ID:jesusmarket,项目名称:jesusmarket,代码行数:101,代码来源:class-wc-meta-box-product-data.php


示例5: update

 /**
  * Update one or more products.
  *
  * ## OPTIONS
  *
  * <id>
  * : Product ID
  *
  * --<field>=<value>
  * : One or more fields to update.
  *
  * ## AVAILABLE_FIELDS
  *
  * For more fields, see: wp wc product create --help
  *
  * ## EXAMPLES
  *
  *     wp wc product update 123 --title="New Product Title" --description="New description"
  *
  * @since 2.5.0
  */
 public function update($args, $assoc_args)
 {
     try {
         $id = $args[0];
         $data = apply_filters('woocommerce_cli_update_product_data', $this->unflatten_array($assoc_args));
         // Product title.
         if (isset($data['title'])) {
             wp_update_post(array('ID' => $id, 'post_title' => wc_clean($data['title'])));
         }
         // Product name (slug).
         if (isset($data['name'])) {
             wp_update_post(array('ID' => $id, 'post_name' => sanitize_title($data['name'])));
         }
         // Product status.
         if (isset($data['status'])) {
             wp_update_post(array('ID' => $id, 'post_status' => wc_clean($data['status'])));
         }
         // Product short description.
         if (isset($data['short_description'])) {
             // Enable short description html tags.
             $post_excerpt = isset($data['enable_html_short_description']) && true === $data['enable_html_short_description'] ? $data['short_description'] : wc_clean($data['short_description']);
             wp_update_post(array('ID' => $id, 'post_excerpt' => $post_excerpt));
         }
         // Product description.
         if (isset($data['description'])) {
             // Enable description html tags.
             $post_content = isset($data['enable_html_description']) && true === $data['enable_html_description'] ? $data['description'] : wc_clean($data['description']);
             wp_update_post(array('ID' => $id, 'post_content' => $post_content));
         }
         // Validate the product type
         if (isset($data['type']) && !in_array(wc_clean($data['type']), array_keys(wc_get_product_types()))) {
             throw new WC_CLI_Exception('woocommerce_cli_invalid_product_type', sprintf(__('Invalid product type - the product type must be any of these: %s', 'woocommerce'), implode(', ', array_keys(wc_get_product_types()))));
         }
         // Check for featured/gallery images, upload it and set it
         if (isset($data['images'])) {
             $this->save_product_images($id, $data['images']);
         }
         // Save product meta fields
         $this->save_product_meta($id, $data);
         // Save variations
         if (isset($data['type']) && 'variable' == $data['type'] && isset($data['variations']) && is_array($data['variations'])) {
             $this->save_variations($id, $data);
         }
         do_action('woocommerce_cli_update_product', $id, $data);
         // Clear cache/transients
         wc_delete_product_transients($id);
         WP_CLI::success("Updated product {$id}.");
     } catch (WC_CLI_Exception $e) {
         WP_CLI::error($e->getMessage());
     }
 }
开发者ID:rahul13bhati,项目名称:woocommerce,代码行数:72,代码来源:class-wc-cli-product.php


示例6: get_collection_params

 /**
  * Get the query params for collections of attachments.
  *
  * @return array
  */
 public function get_collection_params()
 {
     $params = parent::get_collection_params();
     $params['slug'] = array('description' => __('Limit result set to products with a specific slug.', 'woocommerce'), 'type' => 'string', 'validate_callback' => 'rest_validate_request_arg');
     $params['status'] = array('default' => 'any', 'description' => __('Limit result set to products assigned a specific status.', 'woocommerce'), 'type' => 'string', 'enum' => array_merge(array('any'), array_keys(get_post_statuses())), 'sanitize_callback' => 'sanitize_key', 'validate_callback' => 'rest_validate_request_arg');
     $params['type'] = array('description' => __('Limit result set to products assigned a specific type.', 'woocommerce'), 'type' => 'string', 'enum' => array_keys(wc_get_product_types()), 'sanitize_callback' => 'sanitize_key', 'validate_callback' => 'rest_validate_request_arg');
     $params['sku'] = array('description' => __('Limit result set to products with a specific SKU.', 'woocommerce'), 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', 'validate_callback' => 'rest_validate_request_arg');
     $params['featured'] = array('description' => __('Limit result set to featured products.', 'woocommerce'), 'type' => 'boolean', 'sanitize_callback' => 'wc_string_to_bool', 'validate_callback' => 'rest_validate_request_arg');
     $params['category'] = array('description' => __('Limit result set to products assigned a specific category ID.', 'woocommerce'), 'type' => 'string', 'sanitize_callback' => 'wp_parse_id_list', 'validate_callback' => 'rest_validate_request_arg');
     $params['tag'] = array('description' => __('Limit result set to products assigned a specific tag ID.', 'woocommerce'), 'type' => 'string', 'sanitize_callback' => 'wp_parse_id_list', 'validate_callback' => 'rest_validate_request_arg');
     $params['shipping_class'] = array('description' => __('Limit result set to products assigned a specific shipping class ID.', 'woocommerce'), 'type' => 'string', 'sanitize_callback' => 'wp_parse_id_list', 'validate_callback' => 'rest_validate_request_arg');
     $params['attribute'] = array('description' => __('Limit result set to products with a specific attribute.', 'woocommerce'), 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', 'validate_callback' => 'rest_validate_request_arg');
     $params['attribute_term'] = array('description' => __('Limit result set to products with a specific attribute term ID (required an assigned attribute).', 'woocommerce'), 'type' => 'string', 'sanitize_callback' => 'wp_parse_id_list', 'validate_callback' => 'rest_validate_request_arg');
     if (wc_tax_enabled()) {
         $params['tax_class'] = array('description' => __('Limit result set to products with a specific tax class.', 'woocommerce'), 'type' => 'string', 'enum' => array_map('sanitize_title', array_merge(array('standard'), WC_Tax::get_tax_classes())), 'sanitize_callback' => 'sanitize_text_field', 'validate_callback' => 'rest_validate_request_arg');
     }
     $params['in_stock'] = array('description' => __('Limit result set to products in stock or out of stock.', 'woocommerce'), 'type' => 'boolean', 'sanitize_callback' => 'wc_string_to_bool', 'validate_callback' => 'rest_validate_request_arg');
     $params['on_sale'] = array('description' => __('Limit result set to products on sale.', 'woocommerce'), 'type' => 'boolean', 'sanitize_callback' => 'wc_string_to_bool', 'validate_callback' => 'rest_validate_request_arg');
     $params['min_price'] = array('description' => __('Limit result set to products based on a minimum price.', 'woocommerce'), 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', 'validate_callback' => 'rest_validate_request_arg');
     $params['max_price'] = array('description' => __('Limit result set to products based on a maximum price.', 'woocommerce'), 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', 'validate_callback' => 'rest_validate_request_arg');
     return $params;
 }
开发者ID:shivapoudel,项目名称:woocommerce,代码行数:27,代码来源:class-wc-rest-products-controller.php


示例7: esc_attr_e

<div class="panel-wrap product_data">

	<span class="type_box hidden"> &mdash;
		<label for="product-type">
			<select id="product-type" name="product-type">
				<optgroup label="<?php 
esc_attr_e('Product Type', 'woocommerce');
?>
">
				<?php 
foreach (wc_get_product_types() as $value => $label) {
    ?>
					<option value="<?php 
    echo esc_attr($value);
    ?>
" <?php 
    echo selected($product_object->get_type(), $value, false);
    ?>
><?php 
    echo esc_html($label);
    ?>
</option>
				<?php 
}
?>
				</optgroup>
			</select>
		</label>

		<?php 
foreach (self::get_product_type_options() as $key => $option) {
开发者ID:woocommerce,项目名称:woocommerce,代码行数:31,代码来源:html-product-data-panel.php


示例8: admin_scripts

 /**
  * Enqueue scripts.
  */
 public function admin_scripts()
 {
     global $wp_query, $post;
     $screen = get_current_screen();
     $screen_id = $screen ? $screen->id : '';
     $wc_screen_id = sanitize_title(__('WooCommerce', 'woocommerce'));
     $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
     // Register scripts
     wp_register_script('woocommerce_admin', WC()->plugin_url() . '/assets/js/admin/woocommerce_admin' . $suffix . '.js', array('jquery', 'jquery-blockui', 'jquery-ui-sortable', 'jquery-ui-widget', 'jquery-ui-core', 'jquery-tiptip'), WC_VERSION);
     wp_register_script('jquery-blockui', WC()->plugin_url() . '/assets/js/jquery-blockui/jquery.blockUI' . $suffix . '.js', array('jquery'), '2.70', true);
     wp_register_script('jquery-tiptip', WC()->plugin_url() . '/assets/js/jquery-tiptip/jquery.tipTip' . $suffix . '.js', array('jquery'), WC_VERSION, true);
     wp_register_script('accounting', WC()->plugin_url() . '/assets/js/accounting/accounting' . $suffix . '.js', array('jquery'), '0.4.2');
     wp_register_script('round', WC()->plugin_url() . '/assets/js/round/round' . $suffix . '.js', array('jquery'), WC_VERSION);
     wp_register_script('wc-admin-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes' . $suffix . '.js', array('jquery', 'jquery-ui-datepicker', 'jquery-ui-sortable', 'accounting', 'round', 'wc-enhanced-select', 'plupload-all', 'stupidtable', 'jquery-tiptip'), WC_VERSION);
     wp_register_script('zeroclipboard', WC()->plugin_url() . '/assets/js/zeroclipboard/jquery.zeroclipboard' . $suffix . '.js', array('jquery'), WC_VERSION);
     wp_register_script('qrcode', WC()->plugin_url() . '/assets/js/jquery-qrcode/jquery.qrcode' . $suffix . '.js', array('jquery'), WC_VERSION);
     wp_register_script('stupidtable', WC()->plugin_url() . '/assets/js/stupidtable/stupidtable' . $suffix . '.js', array('jquery'), WC_VERSION);
     wp_register_script('serializejson', WC()->plugin_url() . '/assets/js/jquery-serializejson/jquery.serializejson' . $suffix . '.js', array('jquery'), '2.6.1');
     wp_register_script('flot', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot' . $suffix . '.js', array('jquery'), WC_VERSION);
     wp_register_script('flot-resize', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.resize' . $suffix . '.js', array('jquery', 'flot'), WC_VERSION);
     wp_register_script('flot-time', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.time' . $suffix . '.js', array('jquery', 'flot'), WC_VERSION);
     wp_register_script('flot-pie', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.pie' . $suffix . '.js', array('jquery', 'flot'), WC_VERSION);
     wp_register_script('flot-stack', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.stack' . $suffix . '.js', array('jquery', 'flot'), WC_VERSION);
     wp_register_script('wc-settings-tax', WC()->plugin_url() . '/assets/js/admin/settings-views-html-settings-tax' . $suffix . '.js', array('jquery', 'wp-util', 'underscore', 'backbone', 'jquery-blockui'), WC_VERSION);
     wp_register_script('wc-backbone-modal', WC()->plugin_url() . '/assets/js/admin/backbone-modal' . $suffix . '.js', array('underscore', 'backbone', 'wp-util'), WC_VERSION);
     wp_register_script('wc-shipping-zones', WC()->plugin_url() . '/assets/js/admin/wc-shipping-zones' . $suffix . '.js', array('jquery', 'wp-util', 'underscore', 'backbone', 'jquery-ui-sortable', 'wc-enhanced-select', 'wc-backbone-modal'), WC_VERSION);
     wp_register_script('wc-shipping-zone-methods', WC()->plugin_url() . '/assets/js/admin/wc-shipping-zone-methods' . $suffix . '.js', array('jquery', 'wp-util', 'underscore', 'backbone', 'jquery-ui-sortable', 'wc-backbone-modal'), WC_VERSION);
     wp_register_script('wc-shipping-classes', WC()->plugin_url() . '/assets/js/admin/wc-shipping-classes' . $suffix . '.js', array('jquery', 'wp-util', 'underscore', 'backbone'), WC_VERSION);
     wp_register_script('select2', WC()->plugin_url() . '/assets/js/select2/select2' . $suffix . '.js', array('jquery'), '3.5.4');
     wp_register_script('wc-enhanced-select', WC()->plugin_url() . '/assets/js/admin/wc-enhanced-select' . $suffix . '.js', array('jquery', 'select2'), WC_VERSION);
     wp_localize_script('wc-enhanced-select', 'wc_enhanced_select_params', array('i18n_matches_1' => _x('One result is available, press enter to select it.', 'enhanced select', 'woocommerce'), 'i18n_matches_n' => _x('%qty% results are available, use up and down arrow keys to navigate.', 'enhanced select', 'woocommerce'), 'i18n_no_matches' => _x('No matches found', 'enhanced select', 'woocommerce'), 'i18n_ajax_error' => _x('Loading failed', 'enhanced select', 'woocommerce'), 'i18n_input_too_short_1' => _x('Please enter 1 or more characters', 'enhanced select', 'woocommerce'), 'i18n_input_too_short_n' => _x('Please enter %qty% or more characters', 'enhanced select', 'woocommerce'), 'i18n_input_too_long_1' => _x('Please delete 1 character', 'enhanced select', 'woocommerce'), 'i18n_input_too_long_n' => _x('Please delete %qty% characters', 'enhanced select', 'woocommerce'), 'i18n_selection_too_long_1' => _x('You can only select 1 item', 'enhanced select', 'woocommerce'), 'i18n_selection_too_long_n' => _x('You can only select %qty% items', 'enhanced select', 'woocommerce'), 'i18n_load_more' => _x('Loading more results&hellip;', 'enhanced select', 'woocommerce'), 'i18n_searching' => _x('Searching&hellip;', 'enhanced select', 'woocommerce'), 'ajax_url' => admin_url('admin-ajax.php'), 'search_products_nonce' => wp_create_nonce('search-products'), 'search_customers_nonce' => wp_create_nonce('search-customers')));
     // Accounting
     wp_localize_script('accounting', 'accounting_params', array('mon_decimal_point' => wc_get_price_decimal_separator()));
     // WooCommerce admin pages
     if (in_array($screen_id, wc_get_screen_ids())) {
         wp_enqueue_script('iris');
         wp_enqueue_script('woocommerce_admin');
         wp_enqueue_script('wc-enhanced-select');
         wp_enqueue_script('jquery-ui-sortable');
         wp_enqueue_script('jquery-ui-autocomplete');
         $locale = localeconv();
         $decimal = isset($locale['decimal_point']) ? $locale['decimal_point'] : '.';
         $params = array('i18n_decimal_error' => sprintf(__('Please enter in decimal (%s) format without thousand separators.', 'woocommerce'), $decimal), 'i18n_mon_decimal_error' => sprintf(__('Please enter in monetary decimal (%s) format without thousand separators and currency symbols.', 'woocommerce'), wc_get_price_decimal_separator()), 'i18n_country_iso_error' => __('Please enter in country code with two capital letters.', 'woocommerce'), 'i18_sale_less_than_regular_error' => __('Please enter in a value less than the regular price.', 'woocommerce'), 'decimal_point' => $decimal, 'mon_decimal_point' => wc_get_price_decimal_separator());
         wp_localize_script('woocommerce_admin', 'woocommerce_admin', $params);
     }
     // Edit product category pages
     if (in_array($screen_id, array('edit-product_cat'))) {
         wp_enqueue_media();
     }
     // Products
     if (in_array($screen_id, array('edit-product'))) {
         wp_register_script('woocommerce_quick-edit', WC()->plugin_url() . '/assets/js/admin/quick-edit' . $suffix . '.js', array('jquery', 'woocommerce_admin'), WC_VERSION);
         wp_enqueue_script('woocommerce_quick-edit');
     }
     // Meta boxes
     if (in_array($screen_id, array('product', 'edit-product'))) {
         wp_enqueue_media();
         wp_register_script('wc-admin-product-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-product' . $suffix . '.js', array('wc-admin-meta-boxes', 'media-models'), WC_VERSION);
         wp_register_script('wc-admin-variation-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-product-variation' . $suffix . '.js', array('wc-admin-meta-boxes', 'serializejson', 'media-models'), WC_VERSION);
         wp_enqueue_script('wc-admin-product-meta-boxes');
         wp_enqueue_script('wc-admin-variation-meta-boxes');
         $params = array('post_id' => isset($post->ID) ? $post->ID : '', 'plugin_url' => WC()->plugin_url(), 'ajax_url' => admin_url('admin-ajax.php'), 'woocommerce_placeholder_img_src' => wc_placeholder_img_src(), 'add_variation_nonce' => wp_create_nonce('add-variation'), 'link_variation_nonce' => wp_create_nonce('link-variations'), 'delete_variations_nonce' => wp_create_nonce('delete-variations'), 'load_variations_nonce' => wp_create_nonce('load-variations'), 'save_variations_nonce' => wp_create_nonce('save-variations'), 'bulk_edit_variations_nonce' => wp_create_nonce('bulk-edit-variations'), 'i18n_link_all_variations' => esc_js(sprintf(__('Are you sure you want to link all variations? This will create a new variation for each and every possible combination of variation attributes (max %d per run).', 'woocommerce'), defined('WC_MAX_LINKED_VARIATIONS') ? WC_MAX_LINKED_VARIATIONS : 50)), 'i18n_enter_a_value' => esc_js(__('Enter a value', 'woocommerce')), 'i18n_enter_menu_order' => esc_js(__('Variation menu order (determines position in the list of variations)', 'woocommerce')), 'i18n_enter_a_value_fixed_or_percent' => esc_js(__('Enter a value (fixed or %)', 'woocommerce')), 'i18n_delete_all_variations' => esc_js(__('Are you sure you want to delete all variations? This cannot be undone.', 'woocommerce')), 'i18n_last_warning' => esc_js(__('Last warning, are you sure?', 'woocommerce')), 'i18n_choose_image' => esc_js(__('Choose an image', 'woocommerce')), 'i18n_set_image' => esc_js(__('Set variation image', 'woocommerce')), 'i18n_variation_added' => esc_js(__("variation added", 'woocommerce')), 'i18n_variations_added' => esc_js(__("variations added", 'woocommerce')), 'i18n_no_variations_added' => esc_js(__("No variations added", 'woocommerce')), 'i18n_remove_variation' => esc_js(__('Are you sure you want to remove this variation?', 'woocommerce')), 'i18n_scheduled_sale_start' => esc_js(__('Sale start date (YYYY-MM-DD format or leave blank)', 'woocommerce')), 'i18n_scheduled_sale_end' => esc_js(__('Sale end date (YYYY-MM-DD format or leave blank)', 'woocommerce')), 'i18n_edited_variations' => esc_js(__('Save changes before changing page?', 'woocommerce')), 'i18n_variation_count_single' => esc_js(__('%qty% variation', 'woocommerce')), 'i18n_variation_count_plural' => esc_js(__('%qty% variations', 'woocommerce')), 'variations_per_page' => absint(apply_filters('woocommerce_admin_meta_boxes_variations_per_page', 15)));
         wp_localize_script('wc-admin-variation-meta-boxes', 'woocommerce_admin_meta_boxes_variations', $params);
     }
     if (in_array(str_replace('edit-', '', $screen_id), wc_get_order_types('order-meta-boxes'))) {
         wp_register_script('wc-admin-order-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-order' . $suffix . '.js', array('wc-admin-meta-boxes', 'wc-backbone-modal'), WC_VERSION);
         wp_enqueue_script('wc-admin-order-meta-boxes');
         $params = array('countries' => json_encode(array_merge(WC()->countries->get_allowed_country_states(), WC()->countries->get_shipping_country_states())), 'i18n_select_state_text' => esc_attr__('Select an option&hellip;', 'woocommerce'));
         wp_localize_script('wc-admin-order-meta-boxes', 'woocommerce_admin_meta_boxes_order', $params);
     }
     if (in_array($screen_id, array('shop_coupon', 'edit-shop_coupon'))) {
         wp_register_script('wc-admin-coupon-meta-boxes', WC()->plugin_url() . '/assets/js/admin/meta-boxes-coupon' . $suffix . '.js', array('wc-admin-meta-boxes'), WC_VERSION);
         wp_enqueue_script('wc-admin-coupon-meta-boxes');
     }
     if (in_array(str_replace('edit-', '', $screen_id), array_merge(array('shop_coupon', 'product'), wc_get_order_types('order-meta-boxes')))) {
         $post_id = isset($post->ID) ? $post->ID : '';
         $currency = '';
         if ($post_id && in_array(get_post_type($post_id), wc_get_order_types('order-meta-boxes'))) {
             $order = wc_get_order($post_id);
             $currency = $order->get_order_currency();
         }
         $params = array('remove_item_notice' => __('Are you sure you want to remove the selected items? If you have previously reduced this item\'s stock, or this order was submitted by a customer, you will need to manually restore the item\'s stock.', 'woocommerce'), 'i18n_select_items' => __('Please select some items.', 'woocommerce'), 'i18n_do_refund' => __('Are you sure you wish to process this refund? This action cannot be undone.', 'woocommerce'), 'i18n_delete_refund' => __('Are you sure you wish to delete this refund? This action cannot be undone.', 'woocommerce'), 'i18n_delete_tax' => __('Are you sure you wish to delete this tax column? This action cannot be undone.', 'woocommerce'), 'remove_item_meta' => __('Remove this item meta?', 'woocommerce'), 'remove_attribute' => __('Remove this attribute?', 'woocommerce'), 'name_label' => __('Name', 'woocommerce'), 'remove_label' => __('Remove', 'woocommerce'), 'click_to_toggle' => __('Click to toggle', 'woocommerce'), 'values_label' => __('Value(s)', 'woocommerce'), 'text_attribute_tip' => __('Enter some text, or some attributes by pipe (|) separating values.', 'woocommerce'), 'visible_label' => __('Visible on the product page', 'woocommerce'), 'used_for_variations_label' => __('Used for variations', 'woocommerce'), 'new_attribute_prompt' => __('Enter a name for the new attribute term:', 'woocommerce'), 'calc_totals' => __('Calculate totals based on order items, discounts, and shipping?', 'woocommerce'), 'calc_line_taxes' => __('Calculate line taxes? This will calculate taxes based on the customers country. If no billing/shipping is set it will use the store base country.', 'woocommerce'), 'copy_billing' => __('Copy billing information to shipping information? This will remove any currently entered shipping information.', 'woocommerce'), 'load_billing' => __('Load the customer\'s billing information? This will remove any currently entered billing information.', 'woocommerce'), 'load_shipping' => __('Load the customer\'s shipping information? This will remove any currently entered shipping information.', 'woocommerce'), 'featured_label' => __('Featured', 'woocommerce'), 'prices_include_tax' => esc_attr(get_option('woocommerce_prices_include_tax')), 'tax_based_on' => esc_attr(get_option('woocommerce_tax_based_on')), 'round_at_subtotal' => esc_attr(get_option('woocommerce_tax_round_at_subtotal')), 'no_customer_selected' => __('No customer selected', 'woocommerce'), 'plugin_url' => WC()->plugin_url(), 'ajax_url' => admin_url('admin-ajax.php'), 'order_item_nonce' => wp_create_nonce('order-item'), 'add_attribute_nonce' => wp_create_nonce('add-attribute'), 'save_attributes_nonce' => wp_create_nonce('save-attributes'), 'calc_totals_nonce' => wp_create_nonce('calc-totals'), 'get_customer_details_nonce' => wp_create_nonce('get-customer-details'), 'search_products_nonce' => wp_create_nonce('search-products'), 'grant_access_nonce' => wp_create_nonce('grant-access'), 'revoke_access_nonce' => wp_create_nonce('revoke-access'), 'add_order_note_nonce' => wp_create_nonce('add-order-note'), 'delete_order_note_nonce' => wp_create_nonce('delete-order-note'), 'calendar_image' => WC()->plugin_url() . '/assets/images/calendar.png', 'post_id' => isset($post->ID) ? $post->ID : '', 'base_country' => WC()->countries->get_base_country(), 'currency_format_num_decimals' => wc_get_price_decimals(), 'currency_format_symbol' => get_woocommerce_currency_symbol($currency), 'currency_format_decimal_sep' => esc_attr(wc_get_price_decimal_separator()), 'currency_format_thousand_sep' => esc_attr(wc_get_price_thousand_separator()), 'currency_format' => esc_attr(str_replace(array('%1$s', '%2$s'), array('%s', '%v'), get_woocommerce_price_format())), 'rounding_precision' => wc_get_rounding_precision(), 'tax_rounding_mode' => WC_TAX_ROUNDING_MODE, 'product_types' => array_unique(array_merge(array('simple', 'grouped', 'variable', 'external'), array_keys(wc_get_product_types()))), 'i18n_download_permission_fail' => __('Could not grant access - the user may already have permission for this file or billing email is not set. Ensure the billing email is set, and the order has been saved.', 'woocommerce'), 'i18n_permission_revoke' => __('Are you sure you want to revoke access to this download?', 'woocommerce'), 'i18n_tax_rate_already_exists' => __('You cannot add the same tax rate twice!', 'woocommerce'), 'i18n_product_type_alert' => __('Your product has variations! Before changing the product type, it is a good idea to delete the variations to avoid errors in the stock reports.', 'woocommerce'), 'i18n_delete_note' => __('Are you sure you wish to delete this note? This action cannot be undone.', 'woocommerce'));
         wp_localize_script('wc-admin-meta-boxes', 'woocommerce_admin_meta_boxes', $params);
     }
     // Term ordering - only when sorting by term_order
     if ((strstr($screen_id, 'edit-pa_') || !empty($_GET['taxonomy']) && in_array($_GET['taxonomy'], apply_filters('woocommerce_sortable_taxonomies', array('product_cat')))) && !isset($_GET['orderby'])) {
         wp_register_script('woocommerce_term_ordering', WC()->plugin_url() . '/assets/js/admin/term-ordering' . $suffix . '.js', array('jquery-ui-sortable'), WC_VERSION);
         wp_enqueue_script('woocommerce_term_ordering');
         $taxonomy = isset($_GET['taxonomy']) ? wc_clean($_GET['taxonomy']) : '';
         $woocommerce_term_order_params = array('taxonomy' => $taxonomy);
         wp_localize_script('woocommerce_term_ordering', 'woocommerce_term_ordering_params', $woocommerce_term_order_params);
     }
     // Product sorting - only when sorting by menu order on the products page
     if (current_user_can('edit_others_pages') && $screen_id == 'edit-product' && isset($wp_query->query['orderby']) && $wp_query->query['orderby'] == 'menu_order title') {
         wp_register_script('woocommerce_product_ordering', WC()->plugin_url() . '/assets/js/admin/product-ordering' . $suffix . '.js', array('jquery-ui-sortable'), WC_VERSION, true);
         wp_enqueue_script('woocommerce_product_ordering');
     }
//.........这里部分代码省略.........
开发者ID:websideas,项目名称:Mondova,代码行数:101,代码来源:class-wc-admin-assets.php


示例9: get_collection_params

 /**
  * Get the query params for collections of attachments.
  *
  * @return array
  */
 public function get_collection_params()
 {
     $params = parent::get_collection_params();
     $params['slug'] = array('description' => __('Limit result set to products with a specific slug.', 'woocommerce', 'woocommerce'), 'type' => 'string', 'validate_callback' => 'rest_validate_request_arg');
     $params['status'] = array('default' => 'any', 'description' => __('Limit result set to products assigned a specific status.', 'woocommerce'), 'type' => 'string', 'enum' => array_merge(array('any'), array_keys(get_post_statuses())), 'sanitize_callback' => 'sanitize_key', 'validate_callback' => 'rest_validate_request_arg');
     $params['type'] = array('description' => __('Limit result set to products assigned a specific type.', 'woocommerce'), 'type' => 'string', 'enum' => array_keys(wc_get_product_types()), 'sanitize_callback' => 'sanitize_key', 'validate_callback' => 'rest_validate_request_arg');
     $params['category'] = array('description' => __('Limit result set to products assigned a specific category.', 'woocommerce'), 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', 'validate_callback' => 'rest_validate_request_arg');
     $params['tag'] = array('description' => __('Limit result set to products assigned a specific tag.', 'woocommerce'), 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', 'validate_callback' => 'rest_validate_request_arg');
     $params['shipping_class'] = array('description' => __('Limit result set to products assigned a specific shipping class.', 'woocommerce'), 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', 'validate_callback' => 'rest_validate_request_arg');
     $params['attribute'] = array('description' => __('Limit result set to products with a specific attribute.', 'woocommerce'), 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', 'validate_callback' => 'rest_validate_request_arg');
     $params['attribute_term'] = array('description' => __('Limit result set to products with a specific attribute term (required an assigned attribute).', 'woocommerce'), 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', 'validate_callback' => 'rest_validate_request_arg');
     $params['sku'] = array('description' => __('Limit result set to products with a specific SKU.', 'woocommerce'), 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field', 'validate_callback' => 'rest_validate_request_arg');
     return $params;
 }
开发者ID:pelmered,项目名称:woocommerce,代码行数:19,代码来源:class-wc-rest-products-controller.php


示例10: test_wc_get_product_types

 /**
  * Test wc_get_product_types()
  *
  * @since 2.3
  */
 public function test_wc_get_product_types()
 {
     $product_types = (array) apply_filters('product_type_selector', array('simple' => __('Simple product', 'woocommerce'), 'grouped' => __('Grouped product', 'woocommerce'), 'external' => __('External/Affiliate product', 'woocommerce'), 'variable' => __('Variable product', 'woocommerce')));
     $this->assertEquals($product_types, wc_get_product_types());
 }
开发者ID:nathanielks,项目名称:woocommerce,代码行数:10,代码来源:functions.php


示例11: edit_product

 /**
  * Edit a product
  *
  * @since 2.2
  * @param int $id the product ID
  * @param array $data
  * @return array
  */
 public function edit_product($id, $data)
 {
     $data = isset($data['product']) ? $data['product'] : array();
     $id = $this->validate_request($id, 'product', 'edit');
     if (is_wp_error($id)) {
         return $id;
     }
     $data = apply_filters('woocommerce_api_edit_product_data', $data, $this);
     // Product name.
     if (isset($data['title'])) {
         wp_update_post(array('ID' => $id, 'post_title' => wc_clean($data['title'])));
     }
     // Product status.
     if (isset($data['status'])) {
         wp_update_post(array('ID' => $id, 'post_status' => wc_clean($data['status'])));
     }
     // Product short description.
     if (isset($data['short_description'])) {
         wp_update_post(array('ID' => $id, 'post_excerpt' => wc_clean($data['short_description'])));
     }
     // Product description.
     if (isset($data['description'])) {
         wp_update_post(array('ID' => $id, 'post_content' => wc_clean($data['description'])));
     }
     // Validate the product type
     if (isset($data['type']) && !in_array(wc_clean($data['type']), array_keys(wc_get_product_types()))) {
         return new WP_Error('woocommerce_api_invalid_product_type', sprintf(__('Invalid product type - the product type must be any of these: %s', 'woocommerce'), implode(', ', array_keys(wc_get_product_types()))), array('status' => 400));
     }
     // Check for featured/gallery images, upload it and set it
     if (isset($data['images'])) {
         $images = $this->save_product_images($id, $data['images']);
         if (is_wp_error($images)) {
             return $images;
         }
     }
     // Save produc 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wc_get_product_variation_attributes函数代码示例发布时间:2022-05-23
下一篇:
PHP wc_get_product_terms函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap