本文整理汇总了PHP中wc_attribute_taxonomy_name函数的典型用法代码示例。如果您正苦于以下问题:PHP wc_attribute_taxonomy_name函数的具体用法?PHP wc_attribute_taxonomy_name怎么用?PHP wc_attribute_taxonomy_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wc_attribute_taxonomy_name函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: attribute_taxonomies
public static function attribute_taxonomies()
{
global $woocommerce;
if (!isset($woocommerce)) {
return array();
}
$attributes = array();
if (function_exists('wc_get_attribute_taxonomies')) {
$attribute_taxonomies = wc_get_attribute_taxonomies();
} else {
$attribute_taxonomies = $woocommerce->get_attribute_taxonomies();
}
if (empty($attribute_taxonomies)) {
return array();
}
foreach ($attribute_taxonomies as $attribute) {
/* FIX TO WOOCOMMERCE 2.1 */
if (function_exists('wc_attribute_taxonomy_name')) {
$taxonomy = wc_attribute_taxonomy_name($attribute->attribute_name);
} else {
$taxonomy = $woocommerce->attribute_taxonomy_name($attribute->attribute_name);
}
if (taxonomy_exists($taxonomy)) {
$attributes[] = $attribute->attribute_name;
}
}
return $attributes;
}
开发者ID:GaryJones,项目名称:goombiel,代码行数:28,代码来源:class.yith-wcan-helper.php
示例2: get_item_data
function get_item_data($other_data, $cart_item)
{
if (isset($cart_item["wpb_cart_items"])) {
$wpb_cart_items = $cart_item["wpb_cart_items"];
$other_data = array();
$variation_data = $cart_item["variation"];
if (!empty($variation_data)) {
foreach ($variation_data as $attribute => $variation) {
$taxonomy = wc_attribute_taxonomy_name(str_replace('attribute_pa_', '', urldecode($attribute)));
$term = get_term_by('slug', $variation, $taxonomy);
$attribute_type = WPB_Common_Functions::get_variation_attribute_type($taxonomy);
if ($attribute_type == "carousel") {
$other_data[] = array('name' => wc_attribute_label($taxonomy), 'display' => $term->name, 'value' => '', 'hidden' => false);
}
if ($attribute_type == "extra") {
$extra_options = $wpb_cart_items["extra"];
$display_label = !empty($extra_options[$taxonomy]) ? $term->name . '(' . $extra_options[$taxonomy] . ')' : $term->name;
$other_data[] = array('name' => wc_attribute_label($taxonomy), 'display' => $display_label, 'value' => '', 'hidden' => false);
}
if ($attribute_type == "size") {
$size_options = $wpb_cart_items["size"];
$display_label = !empty($size_options[$taxonomy]) ? $size_options[$taxonomy] : "";
$other_data[] = array('name' => wc_attribute_label($taxonomy), 'display' => $display_label, 'value' => '', 'hidden' => false);
}
}
}
}
return $other_data;
}
开发者ID:shirso,项目名称:wc-product-builder,代码行数:29,代码来源:class-product-cart.php
示例3: attribute_taxonomies
public static function attribute_taxonomies()
{
global $woocommerce;
if (!isset($woocommerce)) {
return array();
}
$attributes = array();
if (function_exists('wc_get_attribute_taxonomies') && function_exists('wc_attribute_taxonomy_name')) {
$attribute_taxonomies = wc_get_attribute_taxonomies();
if (empty($attribute_taxonomies)) {
return array();
}
foreach ($attribute_taxonomies as $attribute) {
$tax = wc_attribute_taxonomy_name($attribute->attribute_name);
if (taxonomy_exists($tax)) {
$attributes[$tax] = ucfirst($attribute->attribute_name);
}
}
} else {
$attribute_taxonomies = $woocommerce->get_attribute_taxonomies();
if (empty($attribute_taxonomies)) {
return array();
}
foreach ($attribute_taxonomies as $attribute) {
$tax = $woocommerce->attribute_taxonomy_name($attribute->attribute_name);
if (taxonomy_exists($tax)) {
$attributes[$tax] = ucfirst($attribute->attribute_name);
}
}
}
return $attributes;
}
开发者ID:GaryJones,项目名称:goombiel,代码行数:32,代码来源:class.yith-woocompare-helper.php
示例4: addAttributeSetToProduct
static function addAttributeSetToProduct()
{
ob_start();
global $wc_product_attributes;
$attributeSetKey = $_POST['key'];
$db = new WCAttributeSetsDb();
$attributeSet = $db->get($attributeSetKey);
if (empty($attributeSet->attributes)) {
die;
}
foreach ($attributeSet->attributes as $attributeKey) {
$thepostid = 0;
$taxonomy = wc_attribute_taxonomy_name($attributeKey);
$i = absint($_POST['i']);
$position = 0;
$metabox_class = array();
$attribute = array('name' => $taxonomy, 'value' => '', 'is_visible' => apply_filters('woocommerce_attribute_default_visibility', 1), 'is_variation' => 0, 'is_taxonomy' => $taxonomy ? 1 : 0);
if ($taxonomy) {
$attribute_taxonomy = $wc_product_attributes[$taxonomy];
$metabox_class[] = 'taxonomy';
$metabox_class[] = $taxonomy;
$attribute_label = wc_attribute_label($taxonomy);
} else {
$attribute_label = '';
}
include WC()->plugin_path() . '/includes/admin/meta-boxes/views/html-product-attribute.php';
}
die;
}
开发者ID:galalaly,项目名称:wc-attribute-sets,代码行数:29,代码来源:class-wc-attribute-sets-woocommerce.php
示例5: LoadRestrictions
/**
* Load the restrictions from the database
*/
private function LoadRestrictions()
{
if ($this->restrictions_loaded) {
return;
}
// Attribute/Variation Restrictions
$attribute_taxonomies = wc_get_attribute_taxonomies();
$taxonomies = array();
foreach ($attribute_taxonomies as $taxonomy) {
$taxonomies[] = wc_attribute_taxonomy_name($taxonomy->attribute_name);
}
$restrictions = get_terms(array('taxonomy' => $taxonomies, 'meta_query' => array(array('key' => 'multiple_of', 'compare' => 'EXISTS')), 'hide_empty' => false));
if (is_array($restrictions)) {
foreach ($restrictions as $restriction) {
$this->multiple_ofs_attributes[$restriction->term_id] = $this->GetMultipleOfForAttribute($restriction->term_id);
if (!$this->multiple_ofs_attributes[$restriction->term_id]) {
unset($this->multiple_ofs_attributes[$restriction->term_id]);
}
}
}
// Category Restrictions
$restrictions = get_terms(array('taxonomy' => 'product_cat', 'meta_query' => array(array('key' => 'cat_multiple_of', 'compare' => 'EXISTS')), 'hide_empty' => false));
if (is_array($restrictions)) {
foreach ($restrictions as $restriction) {
$this->multiple_ofs_categories[$restriction->term_id] = $this->GetMultipleOfForCategory($restriction->term_id);
if (!$this->multiple_ofs_categories[$restriction->term_id]) {
unset($this->multiple_ofs_categories[$restriction->term_id]);
}
}
}
$this->cart_must_be_multiple_of = intval(get_option('woocommerce_cart_multiple_of', 0));
$this->restrictions_loaded = true;
}
开发者ID:OM4,项目名称:WooCommerce-Product-Restrictions,代码行数:36,代码来源:product-restrictions.php
示例6: woocommerce_layered_nav_init
/**
* Layered Nav Init
*
* @package WooCommerce/Widgets
* @access public
* @return void
*/
public function woocommerce_layered_nav_init()
{
if (is_active_widget(false, false, 'yith-woo-ajax-navigation', true) && !is_admin()) {
global $_chosen_attributes, $woocommerce;
$_chosen_attributes = array();
/* FIX TO WOOCOMMERCE 2.1 */
$attibute_taxonomies = function_exists('wc_get_attribute_taxonomies') ? $attribute_taxonomies = wc_get_attribute_taxonomies() : ($attribute_taxonomies = $woocommerce->get_attribute_taxonomies());
if ($attribute_taxonomies) {
foreach ($attribute_taxonomies as $tax) {
$attribute = wc_sanitize_taxonomy_name($tax->attribute_name);
/* FIX TO WOOCOMMERCE 2.1 */
if (function_exists('wc_attribute_taxonomy_name')) {
$taxonomy = wc_attribute_taxonomy_name($attribute);
} else {
$taxonomy = $woocommerce->attribute_taxonomy_name($attribute);
}
$name = 'filter_' . $attribute;
$query_type_name = 'query_type_' . $attribute;
if (!empty($_GET[$name]) && taxonomy_exists($taxonomy)) {
$_chosen_attributes[$taxonomy]['terms'] = explode(',', $_GET[$name]);
if (empty($_GET[$query_type_name]) || !in_array(strtolower($_GET[$query_type_name]), array('and', 'or'))) {
$_chosen_attributes[$taxonomy]['query_type'] = apply_filters('woocommerce_layered_nav_default_query_type', 'and');
} else {
$_chosen_attributes[$taxonomy]['query_type'] = strtolower($_GET[$query_type_name]);
}
}
}
}
if (version_compare(preg_replace('/-beta-([0-9]+)/', '', $woocommerce->version), '2.1', '<')) {
add_filter('loop_shop_post_in', 'woocommerce_layered_nav_query');
} else {
add_filter('loop_shop_post_in', array(WC()->query, 'layered_nav_query'));
}
}
}
开发者ID:Inteleck,项目名称:hwc,代码行数:42,代码来源:class.yith-wcan-frontend.php
示例7: automatic_add_features
/**
* Automatic Set all Product Attribute as Compare Features
*
*/
public function automatic_add_features()
{
$current_db_version = get_option('woocommerce_db_version', null);
if (version_compare($current_db_version, '2.1.0', '<') && null !== $current_db_version) {
global $woocommerce;
$top_variations = $woocommerce->get_attribute_taxonomies();
} else {
$top_variations = wc_get_attribute_taxonomies();
}
if ($top_variations) {
foreach ($top_variations as $top_variation) {
$check_existed = WC_Compare_Data::get_count("field_name='" . trim(addslashes($top_variation->attribute_label)) . "'");
if ($check_existed < 1) {
$child_variations = get_terms(version_compare($current_db_version, '2.1.0', '<') && null !== $current_db_version ? $woocommerce->attribute_taxonomy_name($top_variation->attribute_name) : wc_attribute_taxonomy_name($top_variation->attribute_name), array('parent' => 0, 'hide_empty' => 0, 'hierarchical' => 0));
$default_value = '';
if (count($child_variations) > 0) {
$line = '';
foreach ($child_variations as $child_variation) {
$default_value .= $line . addslashes($child_variation->name);
$line = '
';
}
}
if (trim($default_value) != '') {
$feature_id = WC_Compare_Data::insert_row(array('field_name' => trim(addslashes($top_variation->attribute_label)), 'field_type' => 'checkbox', 'field_unit' => '', 'default_value' => $default_value));
} else {
$feature_id = WC_Compare_Data::insert_row(array('field_name' => trim(addslashes($top_variation->attribute_label)), 'field_type' => 'input-text', 'field_unit' => '', 'default_value' => ''));
}
}
}
}
}
开发者ID:shubham79,项目名称:Jhintaak,代码行数:36,代码来源:class-wc-compare-install.php
示例8: register_taxonomies
/**
* Register core taxonomies.
*/
public static function register_taxonomies()
{
if (taxonomy_exists('product_type')) {
return;
}
do_action('woocommerce_register_taxonomy');
$permalinks = get_option('woocommerce_permalinks');
register_taxonomy('product_type', apply_filters('woocommerce_taxonomy_objects_product_type', array('product')), apply_filters('woocommerce_taxonomy_args_product_type', array('hierarchical' => false, 'show_ui' => false, 'show_in_nav_menus' => false, 'query_var' => is_admin(), 'rewrite' => false, 'public' => false)));
register_taxonomy('product_cat', apply_filters('woocommerce_taxonomy_objects_product_cat', array('product')), apply_filters('woocommerce_taxonomy_args_product_cat', array('hierarchical' => true, 'update_count_callback' => '_wc_term_recount', 'label' => __('Product Categories', 'woocommerce'), 'labels' => array('name' => __('Product Categories', 'woocommerce'), 'singular_name' => __('Product Category', 'woocommerce'), 'menu_name' => _x('Categories', 'Admin menu name', 'woocommerce'), 'search_items' => __('Search Product Categories', 'woocommerce'), 'all_items' => __('All Product Categories', 'woocommerce'), 'parent_item' => __('Parent Product Category', 'woocommerce'), 'parent_item_colon' => __('Parent Product Category:', 'woocommerce'), 'edit_item' => __('Edit Product Category', 'woocommerce'), 'update_item' => __('Update Product Category', 'woocommerce'), 'add_new_item' => __('Add New Product Category', 'woocommerce'), 'new_item_name' => __('New Product Category Name', 'woocommerce')), 'show_ui' => true, 'query_var' => true, 'capabilities' => array('manage_terms' => 'manage_product_terms', 'edit_terms' => 'edit_product_terms', 'delete_terms' => 'delete_product_terms', 'assign_terms' => 'assign_product_terms'), 'rewrite' => array('slug' => empty($permalinks['category_base']) ? _x('product-category', 'slug', 'woocommerce') : $permalinks['category_base'], 'with_front' => false, 'hierarchical' => true))));
register_taxonomy('product_tag', apply_filters('woocommerce_taxonomy_objects_product_tag', array('product')), apply_filters('woocommerce_taxonomy_args_product_tag', array('hierarchical' => false, 'update_count_callback' => '_wc_term_recount', 'label' => __('Product Tags', 'woocommerce'), 'labels' => array('name' => __('Product Tags', 'woocommerce'), 'singular_name' => __('Product Tag', 'woocommerce'), 'menu_name' => _x('Tags', 'Admin menu name', 'woocommerce'), 'search_items' => __('Search Product Tags', 'woocommerce'), 'all_items' => __('All Product Tags', 'woocommerce'), 'edit_item' => __('Edit Product Tag', 'woocommerce'), 'update_item' => __('Update Product Tag', 'woocommerce'), 'add_new_item' => __('Add New Product Tag', 'woocommerce'), 'new_item_name' => __('New Product Tag Name', 'woocommerce'), 'popular_items' => __('Popular Product Tags', 'woocommerce'), 'separate_items_with_commas' => __('Separate Product Tags with commas', 'woocommerce'), 'add_or_remove_items' => __('Add or remove Product Tags', 'woocommerce'), 'choose_from_most_used' => __('Choose from the most used Product tags', 'woocommerce'), 'not_found' => __('No Product Tags found', 'woocommerce')), 'show_ui' => true, 'query_var' => true, 'capabilities' => array('manage_terms' => 'manage_product_terms', 'edit_terms' => 'edit_product_terms', 'delete_terms' => 'delete_product_terms', 'assign_terms' => 'assign_product_terms'), 'rewrite' => array('slug' => empty($permalinks['tag_base']) ? _x('product-tag', 'slug', 'woocommerce') : $permalinks['tag_base'], 'with_front' => false))));
register_taxonomy('product_shipping_class', apply_filters('woocommerce_taxonomy_objects_product_shipping_class', array('product', 'product_variation')), apply_filters('woocommerce_taxonomy_args_product_shipping_class', array('hierarchical' => true, 'update_count_callback' => '_update_post_term_count', 'label' => __('Shipping Classes', 'woocommerce'), 'labels' => array('name' => __('Shipping Classes', 'woocommerce'), 'singular_name' => __('Shipping Class', 'woocommerce'), 'menu_name' => _x('Shipping Classes', 'Admin menu name', 'woocommerce'), 'search_items' => __('Search Shipping Classes', 'woocommerce'), 'all_items' => __('All Shipping Classes', 'woocommerce'), 'parent_item' => __('Parent Shipping Class', 'woocommerce'), 'parent_item_colon' => __('Parent Shipping Class:', 'woocommerce'), 'edit_item' => __('Edit Shipping Class', 'woocommerce'), 'update_item' => __('Update Shipping Class', 'woocommerce'), 'add_new_item' => __('Add New Shipping Class', 'woocommerce'), 'new_item_name' => __('New Shipping Class Name', 'woocommerce')), 'show_ui' => false, 'show_in_nav_menus' => false, 'query_var' => is_admin(), 'capabilities' => array('manage_terms' => 'manage_product_terms', 'edit_terms' => 'edit_product_terms', 'delete_terms' => 'delete_product_terms', 'assign_terms' => 'assign_product_terms'), 'rewrite' => false)));
global $wc_product_attributes;
$wc_product_attributes = array();
if ($attribute_taxonomies = wc_get_attribute_taxonomies()) {
foreach ($attribute_taxonomies as $tax) {
if ($name = wc_attribute_taxonomy_name($tax->attribute_name)) {
$tax->attribute_public = absint(isset($tax->attribute_public) ? $tax->attribute_public : 1);
$label = !empty($tax->attribute_label) ? $tax->attribute_label : $tax->attribute_name;
$wc_product_attributes[$name] = $tax;
$taxonomy_data = array('hierarchical' => true, 'update_count_callback' => '_update_post_term_count', 'labels' => array('name' => $label, 'singular_name' => $label, 'search_items' => sprintf(__('Search %s', 'woocommerce'), $label), 'all_items' => sprintf(__('All %s', 'woocommerce'), $label), 'parent_item' => sprintf(__('Parent %s', 'woocommerce'), $label), 'parent_item_colon' => sprintf(__('Parent %s:', 'woocommerce'), $label), 'edit_item' => sprintf(__('Edit %s', 'woocommerce'), $label), 'update_item' => sprintf(__('Update %s', 'woocommerce'), $label), 'add_new_item' => sprintf(__('Add New %s', 'woocommerce'), $label), 'new_item_name' => sprintf(__('New %s', 'woocommerce'), $label)), 'show_ui' => false, 'query_var' => 1 === $tax->attribute_public, 'rewrite' => false, 'sort' => false, 'public' => 1 === $tax->attribute_public, 'show_in_nav_menus' => 1 === $tax->attribute_public && apply_filters('woocommerce_attribute_show_in_nav_menus', false, $name), 'capabilities' => array('manage_terms' => 'manage_product_terms', 'edit_terms' => 'edit_product_terms', 'delete_terms' => 'delete_product_terms', 'assign_terms' => 'assign_product_terms'));
if (1 === $tax->attribute_public) {
$taxonomy_data['rewrite'] = array('slug' => empty($permalinks['attribute_base']) ? '' : trailingslashit($permalinks['attribute_base']) . sanitize_title($tax->attribute_name), 'with_front' => false, 'hierarchical' => true);
}
register_taxonomy($name, apply_filters("woocommerce_taxonomy_objects_{$name}", array('product')), apply_filters("woocommerce_taxonomy_args_{$name}", $taxonomy_data));
}
}
do_action('woocommerce_after_register_taxonomy');
}
}
开发者ID:flasomm,项目名称:Montkailash,代码行数:32,代码来源:class-wc-post-types.php
示例9: widget
/**
* Output widget.
*
* @see WP_Widget
*
* @param array $args
* @param array $instance
*/
public function widget($args, $instance)
{
if (!is_post_type_archive('product') && !is_tax(get_object_taxonomies('product'))) {
return;
}
$_chosen_attributes = WC_Query::get_layered_nav_chosen_attributes();
$taxonomy = isset($instance['attribute']) ? wc_attribute_taxonomy_name($instance['attribute']) : $this->settings['attribute']['std'];
$query_type = isset($instance['query_type']) ? $instance['query_type'] : $this->settings['query_type']['std'];
$display_type = isset($instance['display_type']) ? $instance['display_type'] : $this->settings['display_type']['std'];
if (!taxonomy_exists($taxonomy)) {
return;
}
$get_terms_args = array('hide_empty' => '1');
$orderby = wc_attribute_orderby($taxonomy);
switch ($orderby) {
case 'name':
$get_terms_args['orderby'] = 'name';
$get_terms_args['menu_order'] = false;
break;
case 'id':
$get_terms_args['orderby'] = 'id';
$get_terms_args['order'] = 'ASC';
$get_terms_args['menu_order'] = false;
break;
case 'menu_order':
$get_terms_args['menu_order'] = 'ASC';
break;
}
$terms = get_terms($taxonomy, $get_terms_args);
if (0 === sizeof($terms)) {
return;
}
switch ($orderby) {
case 'name_num':
usort($terms, '_wc_get_product_terms_name_num_usort_callback');
break;
case 'parent':
usort($terms, '_wc_get_product_terms_parent_usort_callback');
break;
}
ob_start();
$this->widget_start($args, $instance);
if ('dropdown' === $display_type) {
$found = $this->layered_nav_dropdown($terms, $taxonomy, $query_type);
} else {
$found = $this->layered_nav_list($terms, $taxonomy, $query_type);
}
$this->widget_end($args);
// Force found when option is selected - do not force found on taxonomy attributes
if (!is_tax() && is_array($_chosen_attributes) && array_key_exists($taxonomy, $_chosen_attributes)) {
$found = true;
}
if (!$found) {
ob_end_clean();
} else {
echo ob_get_clean();
}
}
开发者ID:shivapoudel,项目名称:woocommerce,代码行数:66,代码来源:class-wc-widget-layered-nav.php
示例10: wc_attribute_taxonomy_name
public static function wc_attribute_taxonomy_name($name)
{
if (self::is_wc_version_gte_2_1()) {
return wc_attribute_taxonomy_name($name);
} else {
global $woocommerce;
return $woocommerce->attribute_taxonomy_name($name);
}
}
开发者ID:AndyA,项目名称:River,代码行数:9,代码来源:class-wc-swatches-compatibility.php
示例11: wc_get_attribute_taxonomy_names
/**
* Get an array of product attribute taxonomies.
*
* @access public
* @return array
*/
function wc_get_attribute_taxonomy_names()
{
$taxonomy_names = array();
$attribute_taxonomies = wc_get_attribute_taxonomies();
if ($attribute_taxonomies) {
foreach ($attribute_taxonomies as $tax) {
$taxonomy_names[] = wc_attribute_taxonomy_name($tax->attribute_name);
}
}
return $taxonomy_names;
}
开发者ID:uwitec,项目名称:findgreatmaster,代码行数:17,代码来源:wc-attribute-functions.php
示例12: br_aapf_get_attributes
/**
* Get all possible woocommerce attribute taxonomies
*
* @return mixed|void
*/
function br_aapf_get_attributes()
{
$attribute_taxonomies = wc_get_attribute_taxonomies();
$attributes = array();
if ($attribute_taxonomies) {
foreach ($attribute_taxonomies as $tax) {
$attributes[wc_attribute_taxonomy_name($tax->attribute_name)] = $tax->attribute_label;
}
}
return apply_filters('berocket_aapf_get_attributes', $attributes);
}
开发者ID:kalaveras,项目名称:awaProject,代码行数:16,代码来源:functions.php
示例13: get_list_attribute_slug
public function get_list_attribute_slug()
{
$list = $this->get_list_attributes();
$return = array();
foreach ($list as $item) {
$return[$item->attribute_id]['id'] = $item->attribute_id;
$return[$item->attribute_id]['tax_slug'] = wc_attribute_taxonomy_name($item->attribute_name);
$return[$item->attribute_id]['name'] = $item->attribute_name;
$return[$item->attribute_id]['label'] = $item->attribute_label;
}
return $return;
}
开发者ID:BennyHudson,项目名称:eaton,代码行数:12,代码来源:class-product-attributes.php
示例14: get_woo_attribute_taxonomies
protected function get_woo_attribute_taxonomies()
{
$attribute_array = array();
$attribute_taxonomies = wc_get_attribute_taxonomies();
if ($attribute_taxonomies) {
foreach ($attribute_taxonomies as $tax) {
if (taxonomy_exists(wc_attribute_taxonomy_name($tax->attribute_name))) {
$attribute_array[$tax->attribute_name] = $tax->attribute_name;
}
}
}
return $attribute_array;
}
开发者ID:jmead,项目名称:trucell-cms,代码行数:13,代码来源:class.php
示例15: constant
function constant()
{
$this->attr_slug = '';
$attribute_name = wc_attribute_taxonomy_name($this->term_slug);
$attribute_name_array = wc_get_attribute_taxonomy_names();
$taxonomy_exists = in_array($attribute_name, $attribute_name_array);
if ($taxonomy_exists) {
$this->attr_slug = $attribute_name;
add_image_size('ts_prod_color_thumb', 30, 30, true);
$this->init_handle();
add_action('admin_enqueue_scripts', array($this, 'register_admin_scripts'));
}
}
开发者ID:ericsoncardosoweb,项目名称:dallia,代码行数:13,代码来源:woo_filter_by_color.php
示例16: yith_ywraq_get_product_meta
function yith_ywraq_get_product_meta($raq, $echo = true)
{
/**
* Return the product meta in a varion product
*
* @param array $raq
* @param bool $echo
*
* @return string
* @since 1.0.0
*/
$item_data = array();
// Variation data
if (!empty($raq['variation_id']) && is_array($raq['variations'])) {
foreach ($raq['variations'] as $name => $value) {
if ('' === $value) {
continue;
}
$taxonomy = wc_attribute_taxonomy_name(str_replace('attribute_pa_', '', urldecode($name)));
// If this is a term slug, get the term's nice name
if (taxonomy_exists($taxonomy)) {
$term = get_term_by('slug', $value, $taxonomy);
if (!is_wp_error($term) && $term && $term->name) {
$value = $term->name;
}
$label = wc_attribute_label($taxonomy);
} else {
$custom_att = str_replace('attribute_', '', $name);
if ($custom_att != '') {
$label = wc_attribute_label($custom_att);
} else {
$label = $name;
}
}
$item_data[] = array('key' => $label, 'value' => $value);
}
}
$out = "";
// Output flat or in list format
if (sizeof($item_data) > 0) {
foreach ($item_data as $data) {
if ($echo) {
echo esc_html($data['key']) . ': ' . wp_kses_post($data['value']) . "\n";
} else {
$out .= ' - ' . esc_html($data['key']) . ': ' . wp_kses_post($data['value']) . ' ';
}
}
}
return $out;
}
开发者ID:patrickcurl,项目名称:monks,代码行数:50,代码来源:functions.yith-request-quote.php
示例17: test_translate_attributes_label_in_wp_taxonomies
function test_translate_attributes_label_in_wp_taxonomies()
{
global $wp_taxonomies, $sitepress, $WPML_String_Translation;
$WPML_String_Translation->init_active_languages();
$label = 'Test attr';
$name = wc_attribute_taxonomy_name($label);
$taxonomy_data = array('hierarchical' => true, 'update_count_callback' => '_update_post_term_count', 'labels' => array('name' => $label, 'singular_name' => $label, 'search_items' => sprintf(__('Search %s', 'woocommerce'), $label), 'all_items' => sprintf(__('All %s', 'woocommerce'), $label), 'parent_item' => sprintf(__('Parent %s', 'woocommerce'), $label), 'parent_item_colon' => sprintf(__('Parent %s:', 'woocommerce'), $label), 'edit_item' => sprintf(__('Edit %s', 'woocommerce'), $label), 'update_item' => sprintf(__('Update %s', 'woocommerce'), $label), 'add_new_item' => sprintf(__('Add New %s', 'woocommerce'), $label), 'new_item_name' => sprintf(__('New %s', 'woocommerce'), $label)), 'show_ui' => true, 'show_in_menu' => false, 'show_in_nav_menus' => false, 'meta_box_cb' => false, 'query_var' => 1, 'rewrite' => false, 'sort' => false, 'public' => 1, 'show_in_nav_menus' => 1, 'capabilities' => array('manage_terms' => 'manage_product_terms', 'edit_terms' => 'edit_product_terms', 'delete_terms' => 'delete_product_terms', 'assign_terms' => 'assign_product_terms'));
$taxonomy_data['rewrite'] = array('slug' => empty($permalinks['attribute_base']) ? '' : trailingslashit($permalinks['attribute_base']) . sanitize_title($label), 'with_front' => false, 'hierarchical' => true);
do_action('wpml_register_single_string', 'WordPress', 'taxonomy singular name: ' . $label, $label);
$string_id = icl_get_string_id($label, 'WordPress', 'taxonomy singular name: ' . $label);
icl_add_string_translation($string_id, 'es', 'Test attr es', ICL_TM_COMPLETE);
$WPML_String_Translation->clear_string_filter('es');
$sitepress->switch_lang('es');
register_taxonomy($name, apply_filters("woocommerce_taxonomy_objects_{$name}", array('product')), apply_filters("woocommerce_taxonomy_args_{$name}", $taxonomy_data));
$this->assertTrue((bool) has_filter('wpml_translate_single_string'));
$this->assertEquals('Test attr es', $wp_taxonomies[$name]->labels->name);
}
开发者ID:helgatheviking,项目名称:woocommerce-multilingual,代码行数:17,代码来源:test-strings.php
示例18: __construct
/**
* Constructor
*
* @param WC_Variation_Restrictions $instance
*/
public function __construct()
{
add_filter('woocommerce_products_general_settings', array($this, 'Settings'));
// Category restriction settings
add_action("product_cat_edit_form_fields", array($this, 'EditProductCategory'));
add_action("edit_product_cat", array($this, 'SaveProductCategory'));
// Product attribute/variation restriction setings
$attribute_taxonomies = wc_get_attribute_taxonomies();
if ($attribute_taxonomies) {
foreach ($attribute_taxonomies as $tax) {
// For each of WooCommerce's custom product attributes
$attribute_name = wc_attribute_taxonomy_name($tax->attribute_name);
add_action("{$attribute_name}_edit_form_fields", array($this, 'EditAttributeTerm'));
add_action("edit_{$attribute_name}", array($this, 'SaveAttributeTerm'), 10, 2);
}
}
}
开发者ID:OM4,项目名称:WooCommerce-Product-Restrictions,代码行数:22,代码来源:WC_Product_Restrictions_Admin.php
示例19: get_cart_item_data
private function get_cart_item_data($cart_item)
{
$item_data = array();
// Variation data
if (!empty($cart_item['data']->variation_id) && is_array($cart_item['variation'])) {
foreach ($cart_item['variation'] as $name => $value) {
if ('' === $value) {
continue;
}
$taxonomy = wc_attribute_taxonomy_name(str_replace('attribute_pa_', '', urldecode($name)));
// If this is a term slug, get the term's nice name
if (taxonomy_exists($taxonomy)) {
$term = get_term_by('slug', $value, $taxonomy);
if (!is_wp_error($term) && $term && $term->name) {
$value = $term->name;
}
$label = wc_attribute_label($taxonomy);
// If this is a custom option slug, get the options name
} else {
$value = apply_filters('woocommerce_variation_option_name', $value);
$product_attributes = $cart_item['data']->get_attributes();
if (isset($product_attributes[str_replace('attribute_', '', $name)])) {
$label = wc_attribute_label($product_attributes[str_replace('attribute_', '', $name)]['name']);
} else {
$label = $name;
}
}
$item_data[] = array('key' => $label, 'value' => $value);
}
}
// Filter item data to allow 3rd parties to add more to the array
$item_data = apply_filters('woocommerce_get_item_data', $item_data, $cart_item);
// Format item data ready to display
foreach ($item_data as $key => $data) {
// Set hidden to true to not display meta on cart.
if (!empty($data['hidden'])) {
unset($item_data[$key]);
continue;
}
$item_data[$key]['key'] = !empty($data['key']) ? $data['key'] : $data['name'];
$item_data[$key]['display'] = !empty($data['display']) ? $data['display'] : $data['value'];
}
return $item_data;
}
开发者ID:lucasstark,项目名称:gravityforms-woocommerce-cart-capture,代码行数:44,代码来源:gravity-cart-capture.php
示例20: widget
function widget($args, $instance)
{
extract($args, EXTR_SKIP);
global $woocommerce;
$_attributes_array = array();
if (version_compare(WOOCOMMERCE_VERSION, "2.0.99") >= 0) {
$attribute_taxonomies = wc_get_attribute_taxonomies();
} else {
$attribute_taxonomies = $woocommerce->get_attribute_taxonomies();
}
if ($attribute_taxonomies) {
foreach ($attribute_taxonomies as $tax) {
$attribute = sanitize_title($tax->attribute_name);
if (version_compare(WOOCOMMERCE_VERSION, "2.0.99") >= 0) {
$taxonomy = wc_attribute_taxonomy_name($attribute);
} else {
$taxonomy = $woocommerce->attribute_taxonomy_name($attribute);
}
// create an array of product attribute taxonomies
$_attributes_array[] = $taxonomy;
}
}
if (!is_post_type_archive('product') && !is_tax(array_merge($_attributes_array, array('product_cat', 'product_tag')))) {
return;
}
if (is_tax('product_tag')) {
return;
}
echo $before_widget;
if (!empty($instance['title'])) {
echo $before_title . $instance['title'] . $after_title;
}
// Tag list
$tags = get_terms('product_tag');
$html = '<ul class="woo-ajax-tags taglist">';
foreach ($tags as $tag) {
$term_id = (int) $tag->term_id;
$tag_link = get_term_link($term_id, 'product_tag');
$html .= "<li><input type=checkbox id='{$tag->slug}' class=tags name=tag value='{$tag->slug}'> <label for='{$tag->slug}'>{$tag->name}</label></li>";
}
$html .= '</ul>';
echo $html;
echo $after_widget;
}
开发者ID:AlexOreshkevich,项目名称:velomode.by,代码行数:44,代码来源:woocommerce-ajax-tags.php
注:本文中的wc_attribute_taxonomy_name函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论