当前位置: 首页>>代码示例>>PHP>>正文


PHP update_woocommerce_term_meta函数代码示例

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


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

示例1: yith_vendors_update_db_1_0_1

function yith_vendors_update_db_1_0_1()
{
    $vendors_db_option = get_option('yith_product_vendors_db_version', '1.0.0');
    if ($vendors_db_option && version_compare($vendors_db_option, '1.0.1', '<')) {
        global $wpdb;
        $sql = "SELECT woocommerce_term_id as vendor_id, meta_value as user_id\r\n                    FROM {$wpdb->woocommerce_termmeta} as wtm\r\n                    WHERE wtm.meta_key = %s\r\n                    AND woocommerce_term_id IN (\r\n                        SELECT DISTINCT term_id as vendor_id\r\n                        FROM {$wpdb->term_taxonomy} as tt\r\n                        WHERE tt.taxonomy = %s\r\n                    )";
        $results = $wpdb->get_results($wpdb->prepare($sql, 'owner', YITH_Vendors()->get_taxonomy_name()));
        foreach ($results as $result) {
            $user = get_user_by('id', $result->user_id);
            if ($user) {
                update_woocommerce_term_meta($result->vendor_id, 'registration_date', get_date_from_gmt($user->user_registered));
                update_woocommerce_term_meta($result->vendor_id, 'registration_date_gmt', $user->user_registered);
                if (defined('YITH_WPV_PREMIUM')) {
                    $user->add_cap('view_woocommerce_reports');
                }
            }
        }
        update_option('yith_product_vendors_db_version', '1.0.1');
    }
}
开发者ID:yarwalker,项目名称:ecobyt,代码行数:20,代码来源:functions.yith-update.php

示例2: update_term_meta_fields

 /**
  * Update term meta fields.
  *
  * @param WP_Term $term
  * @param WP_REST_Request $request
  * @return bool|WP_Error
  */
 protected function update_term_meta_fields($term, $request)
 {
     $id = (int) $term->term_id;
     update_woocommerce_term_meta($id, 'display_type', $request['display']);
     if (!empty($request['image'])) {
         $upload = wc_rest_upload_image_from_url(esc_url_raw($request['image']));
         if (is_wp_error($upload)) {
             return $upload;
         }
         $image_id = wc_rest_set_uploaded_image_as_attachment($upload);
         // Check if image_id is a valid image attachment before updating the term meta.
         if ($image_id && wp_attachment_is_image($image_id)) {
             update_woocommerce_term_meta($id, 'thumbnail_id', $image_id);
         }
     }
     return true;
 }
开发者ID:unfulvio,项目名称:woocommerce,代码行数:24,代码来源:class-wc-rest-product-categories-controller.php

示例3: edit_product_category

 /**
  * Edit a product category.
  *
  * @since  2.5.0
  * @param  int            $id   Product category term ID
  * @param  array          $data Posted data
  * @return array|WP_Error       Product category if succeed, otherwise WP_Error
  *                              will be returned
  */
 public function edit_product_category($id, $data)
 {
     global $wpdb;
     try {
         if (!isset($data['product_category'])) {
             throw new WC_API_Exception('woocommerce_api_missing_product_category', sprintf(__('No %1$s data specified to edit %1$s', 'woocommerce'), 'product_category'), 400);
         }
         $id = absint($id);
         $data = $data['product_category'];
         // Check permissions.
         if (!current_user_can('manage_product_terms')) {
             throw new WC_API_Exception('woocommerce_api_user_cannot_edit_product_category', __('You do not have permission to edit product categories', 'woocommerce'), 401);
         }
         $data = apply_filters('woocommerce_api_edit_product_category_data', $data, $this);
         $category = $this->get_product_category($id);
         if (is_wp_error($category)) {
             return $category;
         }
         $display_type = '';
         if (isset($data['display'])) {
             $display_type = $data['display'];
             unset($data['display']);
         }
         if (isset($data['image'])) {
             // If value of image is numeric, assume value as image_id.
             $image = $data['image'];
             if (is_numeric($image)) {
                 $image_id = absint($image);
             } else {
                 if (!empty($image)) {
                     $upload = $this->upload_product_image(esc_url_raw($image));
                     $image_id = $this->set_product_category_image_as_attachment($upload);
                 }
             }
             // In case client supplies invalid image or wants to unset category
             // image.
             if (!wp_attachment_is_image($image_id)) {
                 $image_id = '';
             }
             unset($data['image']);
         }
         $update = wp_update_term($id, 'product_cat', $data);
         if (is_wp_error($update)) {
             throw new WC_API_Exception('woocommerce_api_cannot_edit_product_catgory', __('Could not edit the category', 'woocommerce'), 400);
         }
         if (!empty($display_type)) {
             update_woocommerce_term_meta($update['term_taxonomy_id'], 'display_type', esc_attr($display_type));
         }
         if (isset($image_id)) {
             update_woocommerce_term_meta($update['term_taxonomy_id'], 'thumbnail_id', $image_id);
         }
         do_action('woocommerce_api_edit_product_category', $id, $data);
         return $this->get_product_category($id);
     } catch (WC_API_Exception $e) {
         return new WP_Error($e->getErrorCode(), $e->getMessage(), array('status' => $e->getCode()));
     }
 }
开发者ID:haltaction,项目名称:woocommerce,代码行数:66,代码来源:class-wc-api-products.php

示例4: save_category_fields

 /**
  * save_category_fields function.
  *
  * @param mixed $term_id Term ID being saved
  * @param mixed $tt_id
  * @param string $taxonomy
  */
 public function save_category_fields($term_id, $tt_id = '', $taxonomy = '')
 {
     if (isset($_POST['display_type']) && 'product_cat' === $taxonomy) {
         update_woocommerce_term_meta($term_id, 'display_type', esc_attr($_POST['display_type']));
     }
     if (isset($_POST['product_cat_thumbnail_id']) && 'product_cat' === $taxonomy) {
         update_woocommerce_term_meta($term_id, 'thumbnail_id', absint($_POST['product_cat_thumbnail_id']));
     }
 }
开发者ID:jameztrue,项目名称:woocommerce,代码行数:16,代码来源:class-wc-admin-taxonomies.php

示例5: dhwc_brand_thumbnail_save

/**
 * dhwc_brand_thumbnail_save function.
 *
 * @access public
 * @param mixed $term_id Term ID being saved
 * @param mixed $tt_id
 * @param mixed $taxonomy Taxonomy of the term being saved
 * @return void
 */
function dhwc_brand_thumbnail_save($term_id, $tt_id, $taxonomy)
{
    if (isset($_POST['product_brand_thumbnail_id'])) {
        update_woocommerce_term_meta($term_id, 'thumbnail_id', absint($_POST['product_brand_thumbnail_id']));
    }
}
开发者ID:jmead,项目名称:trucell-cms,代码行数:15,代码来源:dhwc-brand-admin.php

示例6: save_fields

 /**
  * save_fields function
  * saves the form fields to the term meta
  *
  * @see WC_Admin_Taxonomies
  *
  * @access public
  * @param int $term_id Id of the term that's being updated
  * @param int $tt_id I don't know
  * @param string $taxonomy Slug of the taxonomy type being updated
  * @return void
  */
 public function save_fields($term_id, $tt_id = '', $taxonomy = '')
 {
     if (isset($_POST['wc_category_diagram_id']) && 'product_cat' === $taxonomy) {
         update_woocommerce_term_meta($term_id, 'wc_category_diagram_id', esc_attr($_POST['wc_category_diagram_id']));
     }
     if (isset($_POST['wc_category_diagram_text']) && 'product_cat' === $taxonomy) {
         update_woocommerce_term_meta($term_id, 'wc_category_diagram_text', esc_attr($_POST['wc_category_diagram_text']));
     }
 }
开发者ID:RainyDayMedia,项目名称:carbide-probes,代码行数:21,代码来源:woocommerce-category-diagram-widget.php

示例7: _woocommerce_term_recount

/**
 * Function for recounting product terms, ignoring hidden products.
 *
 * @access public
 * @param mixed $term
 * @param mixed $taxonomy
 * @return void
 */
function _woocommerce_term_recount($terms, $taxonomy, $callback = true, $terms_are_term_taxonomy_ids = true)
{
    global $wpdb;
    // Standard callback
    if ($callback) {
        _update_post_term_count($terms, $taxonomy);
    }
    // Stock query
    if (get_option('woocommerce_hide_out_of_stock_items') == 'yes') {
        $stock_join = "LEFT JOIN {$wpdb->postmeta} AS meta_stock ON posts.ID = meta_stock.post_id";
        $stock_query = "\n\t\tAND (\n\t\t\tmeta_stock.meta_key = '_stock_status'\n\t\t\tAND\n\t\t\tmeta_stock.meta_value = 'instock'\n\t\t)";
    } else {
        $stock_query = $stock_join = '';
    }
    // Main query
    $count_query = $wpdb->prepare("\n\t\tSELECT COUNT( DISTINCT posts.ID ) FROM {$wpdb->posts} as posts\n\n\t\tLEFT JOIN {$wpdb->postmeta} AS meta_visibility ON posts.ID = meta_visibility.post_id\n\t\tLEFT JOIN {$wpdb->term_relationships} AS rel ON posts.ID = rel.object_ID\n\t\tLEFT JOIN {$wpdb->term_taxonomy} AS tax USING( term_taxonomy_id )\n\t\tLEFT JOIN {$wpdb->terms} AS term USING( term_id )\n\t\t{$stock_join}\n\n\t\tWHERE \tposts.post_status \t= 'publish'\n\t\tAND \tposts.post_type \t= 'product'\n\t\tAND \t(\n\t\t\tmeta_visibility.meta_key = '_visibility'\n\t\t\tAND\n\t\t\tmeta_visibility.meta_value IN ( 'visible', 'catalog' )\n\t\t)\n\t\tAND \ttax.taxonomy\t= %s\n\t\t{$stock_query}\n\t", $taxonomy->name);
    // Store terms + counts here
    $term_counts = array();
    $counted_terms = array();
    $maybe_count_parents = array();
    // Pre-process term taxonomy ids
    if ($terms_are_term_taxonomy_ids) {
        $term_ids = array();
        foreach ((array) $terms as $term) {
            $the_term = $wpdb->get_row("SELECT term_id, parent FROM {$wpdb->term_taxonomy} WHERE term_taxonomy_id = {$term} AND taxonomy = '{$taxonomy->name}'");
            $term_ids[$the_term->term_id] = $the_term->parent;
        }
        $terms = $term_ids;
    }
    // Count those terms!
    foreach ((array) $terms as $term_id => $parent_id) {
        $term_ids = array();
        if (is_taxonomy_hierarchical($taxonomy->name)) {
            // Grab the parents to count later
            $parent = $parent_id;
            while (!empty($parent) && $parent > 0) {
                $maybe_count_parents[] = $parent;
                $parent_term = get_term_by('id', $parent, $taxonomy->name);
                if ($parent_term) {
                    $parent = $parent_term->parent;
                } else {
                    $parent = 0;
                }
            }
            // We need to get the $term's hierarchy so we can count its children too
            $term_ids = get_term_children($term_id, $taxonomy->name);
        }
        $term_ids[] = absint($term_id);
        // Generate term query
        $term_query = 'AND term.term_id IN ( ' . implode(',', $term_ids) . ' )';
        // Get the count
        $count = $wpdb->get_var($count_query . $term_query);
        update_woocommerce_term_meta($term_id, 'product_count_' . $taxonomy->name, absint($count));
        $counted_terms[] = $term_id;
    }
    // Re-count parents
    if (is_taxonomy_hierarchical($taxonomy->name)) {
        $terms = array_diff($maybe_count_parents, $counted_terms);
        foreach ((array) $terms as $term) {
            $term_ids = get_term_children($term, $taxonomy->name);
            $term_ids[] = $term;
            // Generate term query
            $term_query = 'AND term.term_id IN ( ' . implode(',', $term_ids) . ' )';
            // Get the count
            $count = $wpdb->get_var($count_query . $term_query);
            update_woocommerce_term_meta($term, 'product_count_' . $taxonomy->name, absint($count));
        }
    }
}
开发者ID:iplaydu,项目名称:Bob-Ellis-Shoes,代码行数:77,代码来源:woocommerce-core-functions.php

示例8: woocommerce_attribute_thumbnail_field_save

 public function woocommerce_attribute_thumbnail_field_save($term_id, $tt_id, $taxonomy)
 {
     if (isset($_POST['product_attribute_meta'])) {
         $metas = $_POST['product_attribute_meta'];
         if (isset($metas[$this->meta_key])) {
             $data = $metas[$this->meta_key];
             $photo = isset($data['photo']) ? $data['photo'] : '';
             $color = isset($data['color']) ? $data['color'] : '';
             $type = isset($data['type']) ? $data['type'] : '';
             update_woocommerce_term_meta($term_id, $taxonomy . '_' . $this->meta_key . '_type', $type);
             update_woocommerce_term_meta($term_id, $taxonomy . '_' . $this->meta_key . '_photo', $photo);
             update_woocommerce_term_meta($term_id, $taxonomy . '_' . $this->meta_key . '_color', $color);
         }
     }
 }
开发者ID:k2jysy,项目名称:kshop,代码行数:15,代码来源:class-wc-swatches-product-attribute-images.php

示例9: setData

 public function setData($dataId, $dataValue)
 {
     update_woocommerce_term_meta($dataId, $this->getOptionName(), $dataValue);
 }
开发者ID:j-kenneth,项目名称:Expeero,代码行数:4,代码来源:TdStorageWoocommerceTermMeta.php

示例10: et_brands_fields_save

 function et_brands_fields_save($term_id, $tt_id, $taxonomy)
 {
     if (isset($_POST['brand_thumbnail_id'])) {
         update_woocommerce_term_meta($term_id, 'thumbnail_id', absint($_POST['brand_thumbnail_id']));
     }
     delete_transient('wc_term_counts');
 }
开发者ID:baridavid,项目名称:themes,代码行数:7,代码来源:woo.php

示例11: save

 /**
  * Save the freight class
  *
  * @param  int $term_id
  * @param  int $tt_id
  * @param  string $taxonomy
  */
 public function save($term_id, $tt_id, $taxonomy)
 {
     if (isset($_POST['fedex_freight_class'])) {
         update_woocommerce_term_meta($term_id, 'fedex_freight_class', sanitize_text_field($_POST['fedex_freight_class']));
     }
 }
开发者ID:avijitdeb,项目名称:flatterbox.com,代码行数:13,代码来源:class-wc-fedex-freight-mapping.php

示例12: category_field_save

 function category_field_save($term_id, $tt_id, $taxonomy)
 {
     $restrictions_enabled = isset($_POST['_wc_restrictions']) ? $_POST['_wc_restrictions'] : false;
     if (empty($restrictions_enabled) || $restrictions_enabled == 'no-restriction-setting') {
         delete_woocommerce_term_meta($term_id, '_wc_restrictions');
         delete_woocommerce_term_meta($term_id, '_wc_restrictions_allowed');
     } else {
         update_woocommerce_term_meta($term_id, '_wc_restrictions', $restrictions_enabled);
         delete_woocommerce_term_meta($term_id, '_wc_restrictions_allowed');
         if ($restrictions_enabled == 'restricted') {
             $restrictions = isset($_POST['wc_restrictions_allowed']) ? $_POST['wc_restrictions_allowed'] : array('');
             foreach ($restrictions as $role) {
                 add_woocommerce_term_meta($term_id, '_wc_restrictions_allowed', $role);
             }
         }
     }
     $restrictions_location_enabled = isset($_POST['_wc_restrictions_location']) ? $_POST['_wc_restrictions_location'] : false;
     if (empty($restrictions_location_enabled) || $restrictions_location_enabled == 'no-restriction-setting') {
         delete_woocommerce_term_meta($term_id, '_wc_restrictions_location');
         delete_woocommerce_term_meta($term_id, '_wc_restrictions_locations');
     } else {
         update_woocommerce_term_meta($term_id, '_wc_restrictions_location', $restrictions_location_enabled);
         delete_woocommerce_term_meta($term_id, '_wc_restrictions_locations');
         if ($restrictions_location_enabled == 'restricted') {
             $restrictions = isset($_POST['wc_restrictions_locations']) ? $_POST['wc_restrictions_locations'] : array('');
             foreach ($restrictions as $location) {
                 add_woocommerce_term_meta($term_id, '_wc_restrictions_locations', $location);
             }
         }
     }
 }
开发者ID:Junaid-Farid,项目名称:gocnex,代码行数:31,代码来源:class-wc-catalog-restrictions-category-admin.php

示例13: attribute_save

 /**
  * Save attribute field
  *
  * @access public
  * @since 1.0.0
  */
 public function attribute_save($term_id, $tt_id, $taxonomy)
 {
     if (isset($_POST['term-value'])) {
         update_woocommerce_term_meta($term_id, $taxonomy . '_yith_wccl_value', $_POST['term-value']);
     }
 }
开发者ID:yarwalker,项目名称:ecobyt,代码行数:12,代码来源:class.yith-wccl-admin.php

示例14: trbl_sync_categories

 function trbl_sync_categories()
 {
     if (!wp_verify_nonce($_REQUEST['wcml_nonce'], 'trbl_sync_categories')) {
         die('Invalid nonce');
     }
     $page = isset($_POST['page']) ? $_POST['page'] : 0;
     global $wpdb, $sitepress;
     $all_categories = $wpdb->get_results($wpdb->prepare("SELECT t.term_taxonomy_id,t.term_id FROM {$wpdb->term_taxonomy} AS t LEFT JOIN {$wpdb->prefix}icl_translations AS tr ON tr.element_id = t.term_taxonomy_id WHERE t.taxonomy = 'product_cat' AND tr.element_type = 'tax_product_cat' AND tr.source_language_code is NULL ORDER BY t.term_taxonomy_id LIMIT %d,5", $page * 5));
     foreach ($all_categories as $category) {
         $trid = $sitepress->get_element_trid($category->term_taxonomy_id, 'tax_product_cat');
         $translations = $sitepress->get_element_translations($trid, 'tax_product_cat');
         $type = get_woocommerce_term_meta($category->term_id, 'display_type', true);
         $thumbnail_id = get_woocommerce_term_meta($category->term_id, 'thumbnail_id', true);
         foreach ($translations as $translation) {
             if ($translation->language_code != $sitepress->get_default_language()) {
                 update_woocommerce_term_meta($translation->term_id, 'display_type', $type);
                 update_woocommerce_term_meta($translation->term_id, 'thumbnail_id', icl_object_id($thumbnail_id, 'attachment', true, $translation->language_code));
             }
         }
     }
     echo 1;
     die;
 }
开发者ID:jgabrielfreitas,项目名称:MultipagosTestesAPP,代码行数:23,代码来源:functions-troubleshooting.class.php

示例15: save

 function save($post_id)
 {
     $people = $this->_meta_box['people_fields'];
     foreach ($people as $people_field) {
         $key = $people_field['id'];
         if (!empty($_POST[$key])) {
             update_woocommerce_term_meta($post_id, $key, $_POST[$key]);
         }
     }
     foreach ($this->_meta_box['org_fields'] as $org_field) {
         $org_key = $org_field['id'];
         if (!empty($_POST[$org_key])) {
             update_woocommerce_term_meta($post_id, $org_key, $_POST[$org_key]);
         }
     }
     foreach ($this->_meta_box['events_fields'] as $event_field) {
         $event_key = $event_field['id'];
         if (!empty($_POST[$event_key])) {
             update_woocommerce_term_meta($post_id, $event_key, $_POST[$event_key]);
         }
     }
     foreach ($this->_meta_box['product_fields'] as $product_field) {
         $product_key = $product_field['id'];
         if (!empty($_POST[$product_key])) {
             update_woocommerce_term_meta($post_id, $product_key, $_POST[$product_key]);
         }
     }
     foreach ($this->_meta_box['music_fields'] as $music_field) {
         $music_key = $music_field['id'];
         if (!empty($_POST[$music_key])) {
             update_woocommerce_term_meta($post_id, $music_key, $_POST[$music_key]);
         }
     }
     foreach ($this->_meta_box['receipes_fields'] as $receipes_field) {
         $receipes_key = $receipes_field['id'];
         if (!empty($_POST[$receipes_key])) {
             update_woocommerce_term_meta($post_id, $receipes_key, $_POST[$receipes_key]);
         }
     }
     foreach ($this->_meta_box['software_fields'] as $software_field) {
         $software_key = $software_field['id'];
         if (!empty($_POST[$software_key])) {
             update_woocommerce_term_meta($post_id, $software_key, $_POST[$software_key]);
         }
     }
     foreach ($this->_meta_box['videos_fields'] as $videos_field) {
         $videos_key = $videos_field['id'];
         if (!empty($_POST[$videos_key])) {
             update_woocommerce_term_meta($post_id, $videos_key, $_POST[$videos_key]);
         }
     }
     $review = $this->_meta_box['review_fields'];
     foreach ($review as $review_fields) {
         $review_key = $review_fields['id'];
         if (!empty($_POST[$review_key])) {
             update_woocommerce_term_meta($post_id, $review_key, $_POST[$review_key]);
         }
     }
     $review_rating = $this->_meta_box['review_rating_fields'];
     foreach ($review_rating as $review_rating_fields) {
         $review_rating_key = $review_rating_fields['id'];
         if (!empty($_POST[$review_rating_key])) {
             update_woocommerce_term_meta($post_id, $review_rating_key, $_POST[$review_rating_key]);
         }
     }
 }
开发者ID:kanhaiyasharma,项目名称:Bestswiss,代码行数:66,代码来源:custom-meta.php


注:本文中的update_woocommerce_term_meta函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。