本文整理汇总了PHP中get_woocommerce_term_meta函数的典型用法代码示例。如果您正苦于以下问题:PHP get_woocommerce_term_meta函数的具体用法?PHP get_woocommerce_term_meta怎么用?PHP get_woocommerce_term_meta使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_woocommerce_term_meta函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: woocommerce_subcategory_thumbnail
function woocommerce_subcategory_thumbnail($category)
{
// Vars
$title = get_the_title();
$thumbnail_id = get_woocommerce_term_meta($category->term_id, 'thumbnail_id', true);
$attachment_url = wp_get_attachment_url($thumbnail_id);
$width = wpex_option('woo_cat_entry_width', '9999');
$height = wpex_option('woo_cat_entry_height', '9999');
$crop = $height == '9999' ? false : true;
// Echo Image
echo '<img src="' . aq_resize($attachment_url, $width, $height, $crop) . '" alt="' . $title . '" />';
}
示例2: brands
/**
* List multiple brands shortcode
*
* @access public
* @param array $atts
* @return string
*/
public static function brands($atts)
{
global $woocommerce_loop;
if (empty($atts)) {
return '';
}
extract(shortcode_atts(array('orderby' => 'title', 'columns' => '6', 'order' => 'asc', 'per_page' => '6', 'carousel' => 'true'), $atts));
$brands = get_categories(array('hide_empty' => 0, 'taxonomy' => 'product_brand', 'orderby' => $orderby, 'order' => $order, 'number' => $per_page));
$output = '';
$columns = intval($columns);
$columns = 12 / $columns;
foreach ($brands as $brand) {
$thumbnail_id = get_woocommerce_term_meta($brand->term_id, 'thumbnail_id');
$image_src = wp_get_attachment_image_src($thumbnail_id, 'full');
$brand_link = get_term_link($brand, 'product_brand');
$brand_item = '<div class="brand-item">';
$brand_item .= "\t" . '<a href="' . $brand_link . '"><img alt="' . $brand->cat_name . '" src="' . $image_src[0] . '" width="144" height="36" /></a>';
$brand_item .= '</div>';
if ($carousel === 'false') {
$output .= '<div class="col-xs-12 col-sm-' . $columns . '">' . $brand_item . '</div>';
} else {
$output .= $brand_item;
}
}
return $output;
}
示例3: ml_get_categories_with_thumbnails_loop
function ml_get_categories_with_thumbnails_loop()
{
$taxonomy = 'product_cat';
$orderby = 'name';
$show_count = 0;
// 1 for yes, 0 for no
$pad_counts = 0;
// 1 for yes, 0 for no
$hierarchical = 1;
// 1 for yes, 0 for no
$title = '';
$empty = 0;
$args = array('taxonomy' => $taxonomy, 'orderby' => $orderby, 'show_count' => $show_count, 'pad_counts' => $pad_counts, 'hierarchical' => $hierarchical, 'title_li' => $title, 'hide_empty' => $empty);
$all_categories = get_categories($args);
foreach ($all_categories as $cat) {
if ($cat->category_parent == 0) {
$category_id = $cat->term_id;
echo '<br /><a href="' . get_term_link($cat->slug, 'product_cat') . '">' . $cat->name . '</a>';
$thumbnail_id = get_woocommerce_term_meta($cat->term_id, 'thumbnail_id', true);
$image = wp_get_attachment_url($thumbnail_id);
if ($image) {
echo '<img src="' . $image . '" alt="" />';
}
}
}
}
示例4: edit_category_fields
/**
* extra fields while editing category.
*
* @author Lukas Juhas
* @date 2016-02-04
*
* @param [type] $term [description]
*
* @return [type] [description]
*/
public function edit_category_fields($term)
{
$wcl_cat_password_protected = absint(get_woocommerce_term_meta($term->term_id, 'wcl_cat_password_protected', true));
$wcl_cat_password = get_woocommerce_term_meta($term->term_id, 'wcl_cat_password', true);
?>
<tr class="form-field">
<th scope="row" valign="top">
Password Protection
</th>
<td>
<label id="wcl_cat_password_protected">
<input type="checkbox" name="wcl_cat_password_protected" value="1" <?php
if ($wcl_cat_password_protected) {
echo 'checked="checked"';
}
?>
/>
<?php
_e('Password Protected', WCL_PLUGIN_DOMAIN);
?>
</label>
<div class="clear"></div>
<div id="wcl_cat_password" style="<?php
if (!$wcl_cat_password_protected) {
echo 'display:none;';
}
?>
float: left;">
<label>
<?php
_e('Password:', WCL_PLUGIN_DOMAIN);
?>
<input type="text" name="wcl_cat_password" value="<?php
echo $wcl_cat_password;
?>
" <?php
if (!$wcl_cat_password_protected) {
echo 'disabled="disabled"';
}
?>
required="required" />
</label>
</div>
<script>
jQuery('#wcl_cat_password_protected').on('click', function() {
var $checked = jQuery('input[name="wcl_cat_password_protected"]:checkbox:checked').length > 0;
if($checked) {
jQuery('#wcl_cat_password').find('input').prop('disabled', false);
jQuery('#wcl_cat_password').slideDown();
} else {
jQuery('#wcl_cat_password').find('input').prop('disabled', true);
jQuery('#wcl_cat_password').slideUp();
}
});
</script>
<div class="clear"></div>
</td>
</tr>
<?php
}
示例5: on_init
public function on_init()
{
global $woocommerce, $_wp_additional_image_sizes;
$this->init_size($this->size);
$type = get_woocommerce_term_meta($this->term_id, $this->meta_key() . '_type', true);
$color = get_woocommerce_term_meta($this->term_id, $this->meta_key() . '_color', true);
$this->thumbnail_id = get_woocommerce_term_meta($this->term_id, $this->meta_key() . '_photo', true);
$this->type = $type;
$this->thumbnail_src = $woocommerce->plugin_url() . '/assets/images/placeholder.png';
$this->color = '#FFFFFF';
if ($type == 'photo') {
if ($this->thumbnail_id) {
$imgsrc = wp_get_attachment_image_src($this->thumbnail_id, $this->size);
if ($imgsrc && is_array($imgsrc)) {
$this->thumbnail_src = current($imgsrc);
} else {
$this->thumbnail_src = $woocommerce->plugin_url() . '/assets/images/placeholder.png';
}
} else {
$this->thumbnail_src = $woocommerce->plugin_url() . '/assets/images/placeholder.png';
}
} elseif ($type == 'color') {
$this->color = $color;
}
}
示例6: prepare_item_for_response
/**
* Prepare a single product category output for response.
*
* @param WP_Term $item Term object.
* @param WP_REST_Request $request
* @return WP_REST_Response $response
*/
public function prepare_item_for_response($item, $request)
{
// Get category display type.
$display_type = get_woocommerce_term_meta($item->term_id, 'display_type');
// Get category order.
$menu_order = get_woocommerce_term_meta($item->term_id, 'order');
$data = array('id' => (int) $item->term_id, 'name' => $item->name, 'slug' => $item->slug, 'parent' => (int) $item->parent, 'description' => $item->description, 'display' => $display_type ? $display_type : 'default', 'image' => array(), 'menu_order' => (int) $menu_order, 'count' => (int) $item->count);
// Get category image.
if ($image_id = get_woocommerce_term_meta($item->term_id, 'thumbnail_id')) {
$attachment = get_post($image_id);
$data['image'] = array('id' => (int) $image_id, 'date_created' => wc_rest_prepare_date_response($attachment->post_date_gmt), 'date_modified' => wc_rest_prepare_date_response($attachment->post_modified_gmt), 'src' => wp_get_attachment_url($image_id), 'title' => get_the_title($attachment), 'alt' => get_post_meta($image_id, '_wp_attachment_image_alt', true));
}
$context = !empty($request['context']) ? $request['context'] : 'view';
$data = $this->add_additional_fields_to_object($data, $request);
$data = $this->filter_response_by_context($data, $context);
$response = rest_ensure_response($data);
$response->add_links($this->prepare_links($item, $request));
/**
* Filter a term item returned from the API.
*
* Allows modification of the term data right before it is returned.
*
* @param WP_REST_Response $response The response object.
* @param object $item The original term object.
* @param WP_REST_Request $request Request used to generate the response.
*/
return apply_filters("woocommerce_rest_prepare_{$this->taxonomy}", $response, $item, $request);
}
示例7: dhwc_get_product_brand_thumbnail_url
/**
* get thumbnail product brand by id
* @param int $brand_id
* @param string $size
*/
function dhwc_get_product_brand_thumbnail_url($brand_id, $size = 'full')
{
$thumbnail_id = get_woocommerce_term_meta($brand_id, 'thumbnail_id', true);
if ($thumbnail_id) {
return current(wp_get_attachment_image_src($thumbnail_id, $size));
}
}
示例8: panel
/**
* Renders our panel.
*/
public static function panel($tag = null)
{
global $post, $wpdb;
global $wp_roles;
if (class_exists('WP_Roles')) {
if (!isset($wp_roles)) {
$wp_roles = new WP_Roles();
}
}
$output = '';
$term_id = isset($tag->term_id) ? $tag->term_id : null;
$output .= '<div class="form-field">';
$pricing_options = array();
foreach ($wp_roles->role_objects as $role) {
$pricing_options['value_' . $role->name] = get_woocommerce_term_meta($term_id, 'role_pricing_value_' . $role->name, true);
}
$output .= '<div class="options_role" style="border: 1px solid #ccc; padding:10px;">';
$output .= '<h4>' . __('Woocommerce Role Pricing', WOO_ROLE_PRICING_DOMAIN) . '</h4>';
$output .= '<p class="description">';
$output .= __('Leave empty if no custom role discount should be applied to this category.', WOO_ROLE_PRICING_DOMAIN);
$output .= '</p>';
foreach ($wp_roles->role_objects as $role) {
$output .= '<p>';
$output .= '<label style="width:120px;float:left;">' . ucwords($role->name) . '</label>';
$output .= '<input type="text" style="width:auto;" size="10" name="role_pricing_value_' . $role->name . '" value="' . @$pricing_options['value_' . $role->name] . '" />';
$output .= '</p>';
}
$output .= '</div>';
$output .= '</div>';
// .form-field
echo $output;
}
示例9: wc1c_manage_taxonomy_custom_column
function wc1c_manage_taxonomy_custom_column($columns, $column, $id)
{
if ($column == 'wc1c_guid') {
$guid = get_woocommerce_term_meta($id, 'wc1c_guid');
list($taxonomy, $guid) = explode('::', $guid);
$columns .= $guid ? "<small>{$guid}</small>" : '<span class="na">–</span>';
}
return $columns;
}
示例10: get_categories
public static function get_categories()
{
global $wp_query;
$defaults = array('before' => '', 'after' => '', 'force_display' => false);
$args = array();
$args = wp_parse_args($args, $defaults);
extract($args);
$term = get_queried_object();
$parent_id = empty($term->term_id) ? 0 : $term->term_id;
if (is_product_category()) {
$display_type = get_woocommerce_term_meta($term->term_id, 'display_type', true);
switch ($display_type) {
case 'products':
return;
break;
case '':
if (get_option('woocommerce_category_archive_display') == '') {
return;
}
break;
}
}
$product_categories = get_categories(apply_filters('woocommerce_product_subcategories_args', array('parent' => $parent_id, 'menu_order' => 'ASC', 'hide_empty' => 0, 'hierarchical' => 1, 'taxonomy' => 'product_cat', 'pad_counts' => 1)));
if (!apply_filters('woocommerce_product_subcategories_hide_empty', false)) {
$product_categories = wp_list_filter($product_categories, array('count' => 0), 'NOT');
}
if ($product_categories) {
echo $before;
foreach ($product_categories as $category) {
wc_get_template('content-product_cat.php', array('category' => $category));
}
if (is_product_category()) {
$display_type = get_woocommerce_term_meta($term->term_id, 'display_type', true);
switch ($display_type) {
case 'subcategories':
$wp_query->post_count = 0;
$wp_query->max_num_pages = 0;
break;
case '':
if (get_option('woocommerce_category_archive_display') == 'subcategories') {
$wp_query->post_count = 0;
$wp_query->max_num_pages = 0;
}
break;
}
}
if (is_shop() && get_option('woocommerce_shop_page_display') == 'subcategories') {
$wp_query->post_count = 0;
$wp_query->max_num_pages = 0;
}
echo $after;
return true;
}
}
示例11: wcl_get_locked_categories
/**
* ID list of categories that are locked
* @author Lukas Juhas
* @date 2016-02-08
* @return [type] [description]
*/
function wcl_get_locked_categories()
{
$locked = array();
$shop_terms = get_terms('product_cat');
foreach ($shop_terms as $term) {
$is_password_protected = get_woocommerce_term_meta($term->term_id, 'wcl_cat_password_protected');
if ($is_password_protected) {
$locked[] = $term->term_id;
}
}
return $locked;
}
示例12: woocommerce_category_image
function woocommerce_category_image()
{
if (is_product_category()) {
global $wp_query;
$cat = $wp_query->get_queried_object();
$thumbnail_id = get_woocommerce_term_meta($cat->term_id, 'thumbnail_id', true);
$image = wp_get_attachment_url($thumbnail_id);
if ($image) {
echo '<img src="' . $image . '" alt="" class="img-responsive" />';
}
}
}
示例13: widget
function widget($args, $instance)
{
extract($args);
$title = $instance['title'];
echo $before_widget;
if (!$title == '') {
echo $before_title;
echo $title;
echo $after_title;
}
$current_term = get_queried_object();
$args = array('hide_empty' => false);
$terms = get_terms('brand', $args);
$count = count($terms);
$i = 0;
if ($count > 0) {
?>
<ul>
<?php
foreach ($terms as $term) {
$i++;
$curr = false;
$thumbnail_id = absint(get_woocommerce_term_meta($term->term_id, 'thumbnail_id', true));
if (isset($current_term->term_id) && $current_term->term_id == $term->term_id) {
$curr = true;
}
?>
<li>
<a href="<?php
echo get_term_link($term);
?>
" title="<?php
echo sprintf(__('View all products from %s', ETHEME_DOMAIN), $term->name);
?>
"><?php
if ($curr) {
echo '<strong>';
}
echo $term->name;
if ($curr) {
echo '</strong>';
}
?>
</a>
</li>
<?php
}
?>
</ul>
<?php
}
echo $after_widget;
}
示例14: woocommerce_taxonomy_archive_description
/**
* Overrides the default woocommerce_taxonomy_archive_description() function
*/
function woocommerce_taxonomy_archive_description()
{
if (is_tax(array('product_cat', 'product_tag')) && get_query_var('paged') == 0) {
global $wp_query;
$term = $wp_query->get_queried_object();
$thumbnail_id = get_woocommerce_term_meta($term->term_id, 'thumbnail_id', true);
$image = wp_get_attachment_url($thumbnail_id);
$image_class = $image ? ' has-term-image' : null;
$description = wc_format_content(term_description());
if ($description) {
echo '<div class="term-description' . $image_class . '">' . $description . '</div>';
}
}
}
示例15: start_lvl
/**
* @see Walker::start_lvl()
*
* @param string $output Passed by reference. Used to append additional content.
* @param int $depth Depth of page. Used for padding.
*/
public function start_lvl(&$output, $depth = 0, $args = array())
{
$indent = str_repeat("\t", $depth);
$class = '';
$after = '';
if ($this->product_category) {
if ($image_id = get_woocommerce_term_meta($this->product_category, 'thumbnail_id', true)) {
$image_attributes = wp_get_attachment_image_src($image_id, 'thumbnail');
$after = sprintf('<img src="%s" class="pull-right">', $image_attributes[0]);
$class = 'has-image';
}
}
$output .= "\n{$indent}<ul role=\"menu\" class=\" dropdown-menu {$class}\">\n{$after}";
}