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

PHP wc_set_term_order函数代码示例

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

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



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

示例1: wc_set_term_order

/**
 * Set the sort order of a term.
 *
 * @param int $term_id
 * @param int $index
 * @param string $taxonomy
 * @param bool $recursive (default: false)
 * @return int
 */
function wc_set_term_order($term_id, $index, $taxonomy, $recursive = false)
{
    $term_id = (int) $term_id;
    $index = (int) $index;
    // Meta name
    if (taxonomy_is_product_attribute($taxonomy)) {
        $meta_name = 'order_' . esc_attr($taxonomy);
    } else {
        $meta_name = 'order';
    }
    update_woocommerce_term_meta($term_id, $meta_name, $index);
    if (!$recursive) {
        return $index;
    }
    $children = get_terms($taxonomy, "parent={$term_id}&menu_order=ASC&hide_empty=0");
    foreach ($children as $term) {
        $index++;
        $index = wc_set_term_order($term->term_id, $index, $taxonomy, true);
    }
    clean_term_cache($term_id, $taxonomy);
    return $index;
}
开发者ID:Korkey128k,项目名称:woocommerce,代码行数:31,代码来源:wc-term-functions.php


示例2: wc1c_replace_term

function wc1c_replace_term($is_full, $guid, $parent_guid, $name, $taxonomy, $order, $use_guid_as_slug = false)
{
    global $wpdb;
    $term_id = wc1c_term_id_by_meta('wc1c_guid', "{$taxonomy}::{$guid}");
    if ($term_id) {
        $term = get_term($term_id, $taxonomy);
    }
    $parent = $parent_guid ? wc1c_term_id_by_meta('wc1c_guid', "{$taxonomy}::{$parent_guid}") : null;
    if (!$term_id || !$term) {
        $name = wc1c_unique_term_name($name, $taxonomy, $parent);
        $slug = wc1c_unique_term_slug($name, $taxonomy, $parent);
        $args = array('slug' => $slug, 'parent' => $parent);
        if ($use_guid_as_slug) {
            $args['slug'] = $guid;
        }
        $result = wp_insert_term($name, $taxonomy, $args);
        wc1c_check_wpdb_error();
        wc1c_check_wp_error($result);
        $term_id = $result['term_id'];
        update_woocommerce_term_meta($term_id, 'wc1c_guid', "{$taxonomy}::{$guid}");
        $is_added = true;
    }
    if (empty($is_added)) {
        if (trim($name) != $term->name) {
            $name = wc1c_unique_term_name($name, $taxonomy, $parent);
        }
        $parent = $parent_guid ? wc1c_term_id_by_meta('wc1c_guid', "{$taxonomy}::{$parent_guid}") : null;
        $args = array('name' => $name, 'parent' => $parent);
        $result = wp_update_term($term_id, $taxonomy, $args);
        wc1c_check_wp_error($result);
    }
    if ($is_full) {
        wc_set_term_order($term_id, $order, $taxonomy);
    }
    update_woocommerce_term_meta($term_id, 'wc1c_timestamp', WC1C_TIMESTAMP);
}
开发者ID:sgtpep,项目名称:woocommerce-1c,代码行数:36,代码来源:import.php


示例3: woocommerce_set_term_order

/**
 * @deprecated
 */
function woocommerce_set_term_order($term_id, $index, $taxonomy, $recursive = false)
{
    return wc_set_term_order($term_id, $index, $taxonomy, $recursive);
}
开发者ID:nayemDevs,项目名称:woocommerce,代码行数:7,代码来源:wc-deprecated-functions.php


示例4: import_product_categories

 /**
  * Import product categories
  *
  * @return int Number of product categories imported
  */
 private function import_product_categories()
 {
     $cat_count = 0;
     $terms = array();
     $taxonomy = 'product_cat';
     $term_metakey = '_fgm2wc_old_product_category_id';
     $used_slugs = array();
     // Set the list of previously imported categories
     $this->imported_categories = $this->get_term_metas_by_metakey($term_metakey);
     $categories = $this->get_all_product_categories();
     foreach ($categories as $category) {
         // Check if the category is already imported
         if (array_key_exists($category['entity_id'], $this->imported_categories)) {
             continue;
             // Do not import already imported category
         }
         // Other fields
         $category = array_merge($category, $this->get_attribute_values($category['entity_id'], $category['entity_type_id'], array('name', 'description', 'url_key', 'image')));
         // Date
         $date = $category['created_at'];
         // Slug
         $slug = isset($category['url_key']) ? $category['url_key'] : sanitize_title($category['name']);
         $slug = $this->build_unique_slug($slug, $used_slugs);
         $used_slugs[] = $slug;
         // Insert the category
         $new_category = array('description' => isset($category['description']) ? $category['description'] : '', 'slug' => $slug);
         // Hook before inserting the category
         $new_category = apply_filters('fgm2wc_pre_insert_category', $new_category, $category);
         $new_term = wp_insert_term($category['name'], $taxonomy, $new_category);
         if (!is_wp_error($new_term)) {
             $cat_count++;
             $terms[] = $new_term['term_id'];
             // Store the Magento category ID
             add_term_meta($new_term['term_id'], $term_metakey, $category['entity_id'], true);
             // Category ordering
             if (function_exists('wc_set_term_order')) {
                 wc_set_term_order($new_term['term_id'], $category['position'], $taxonomy);
             }
             // Category image
             if (!$this->plugin_options['skip_media'] && function_exists('update_woocommerce_term_meta')) {
                 if (isset($category['image']) && !empty($category['image'])) {
                     $image_path = '/media/catalog/category/' . $category['image'];
                     $thumbnail_id = $this->import_media($category['name'], $image_path, $date);
                     if (!empty($thumbnail_id)) {
                         $this->media_count++;
                         update_woocommerce_term_meta($new_term['term_id'], 'thumbnail_id', $thumbnail_id);
                     }
                 }
             }
             // Hook after inserting the category
             do_action('fgm2wc_post_insert_category', $new_term['term_id'], $category);
         }
     }
     // Set the list of imported categories
     $this->imported_categories = $this->get_term_metas_by_metakey($term_metakey);
     // Update the categories with their parent ids
     foreach ($categories as $category) {
         if (array_key_exists($category['entity_id'], $this->imported_categories) && array_key_exists($category['parent_id'], $this->imported_categories)) {
             $cat_id = $this->imported_categories[$category['entity_id']];
             $parent_cat_id = $this->imported_categories[$category['parent_id']];
             $cat = get_term_by('term_taxonomy_id', $cat_id, $taxonomy);
             $parent_cat = get_term_by('term_taxonomy_id', $parent_cat_id, $taxonomy);
             if ($cat && $parent_cat) {
                 // Hook before editing the category
                 $cat = apply_filters('fgm2wc_pre_edit_category', $cat, $parent_cat);
                 wp_update_term($cat->term_id, $taxonomy, array('parent' => $parent_cat->term_id));
                 // Hook after editing the category
                 do_action('fgm2wc_post_edit_category', $cat);
             }
         }
     }
     // Hook after importing all the categories
     do_action('fgm2wc_post_import_categories', $categories);
     // Update cache
     if (!empty($terms)) {
         wp_update_term_count_now($terms, $taxonomy);
         $this->clean_cache($terms, $taxonomy);
     }
     $this->display_admin_notice(sprintf(_n('%d product category imported', '%d product categories imported', $cat_count, 'fg-magento-to-woocommerce'), $cat_count));
 }
开发者ID:mike-a-b,项目名称:teeninstyle,代码行数:85,代码来源:class-fg-magento-to-woocommerce-admin.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP wc_setcookie函数代码示例发布时间:2022-05-23
下一篇:
PHP wc_set_customer_auth_cookie函数代码示例发布时间: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