taxonomy-terms

Set minimum Order amount for specific Products and Categories in Woocommerce

删除回忆录丶 提交于 2020-01-06 04:06:12
问题 I've searched extensively to see if other folks had this situation and received an answer with no luck. Essentially, I have two items customers can add to their cart. I want to make it so they cannot checkout with either of those items if their subtotal is not $15 or more. Having the ability to just drop their IDs into the code would be fine. Or, I can assign them to the same category and set this minimum by category. So far all I have is the basic PHP that sets a universal minimum. I just

Add Product Attributes with values to a product in Woocommerce

会有一股神秘感。 提交于 2020-01-04 05:39:05
问题 I am using this code to add custom attributes $attributes = array( array("name"=>"Size","options"=>array("S","L","XL","XXL"),"position"=>1,"visible"=>1,"variation"=>1), array("name"=>"Color","options"=>array("Red","Blue","Black","White"),"position"=>2,"visible"=>1,"variation"=>1) ); if($attributes){ $productAttributes=array(); foreach($attributes as $attribute){ $attr = wc_sanitize_taxonomy_name(stripslashes($attribute["name"])); // remove any unwanted chars and return the valid string for

How to get real term_meta using ACF with custom fields on taxonomy terms (instead of wp_options)

谁说我不能喝 提交于 2020-01-03 03:46:06
问题 Having a simple Woocommerce site, I'm using ACF pro to add some custom fields to the terms of a given taxonomy. Using this, I can, for example, add a "color" field to my "product category" taxonomy terms. Good. The issue: Wanting to do some query using get_terms() (codex), I discovered that my meta_query parameters were not working (unexpected results). Why ? My custom fields were not saved (from backend) as term_meta but as wp_option . It seems that ACF 4 is saving those fields, not as term

Wordpress: tax_query multiple terms using OR operator

流过昼夜 提交于 2019-12-12 19:21:32
问题 Simple query but for some reason is not displaying the correct posts, trying to display a post with the monthly-to-do-list term, if no results then display a post with the community-events' term. Any suggestions? $todo_args = array( 'cat' => $my_category_id, 'posts_per_page' => 1, 'tax_query' => array( 'relation' => 'OR', array( 'taxonomy' => 'postkicker', 'field' => 'slug', 'terms' => 'monthly-to-do-list', ), array( 'taxonomy' => 'postkicker', 'field' => 'slug', 'terms' => 'community-events'

Woocommerce display sub-categories in parent category page

百般思念 提交于 2019-12-11 08:07:16
问题 I am trying to create a template for sub-category where I can display products under sub-category and in parent category page want to display only related sub-categories of the parent category. Can anyone suggest me with the example of code? how to start this. 回答1: Try the following: if ( is_product_category() ) { $terms = get_terms( array('taxonomy' => 'product_cat', 'parent' => get_queried_object_id() ) ); foreach ( $terms as $term ){ $term_link = get_term_link( $term, $taxonomy ); echo '<a

Add a custom field to Woocommerce products for a specific product category

[亡魂溺海] 提交于 2019-12-11 00:37:44
问题 I'm trying to add a custom field to the single product page for products in a specific category. I'm having problems with the conditional logic tho. This is what I've got so far: function cfwc_create_custom_field() { global $product; $terms = get_the_terms( $product->get_id(), 'product_cat' ); if (in_array("tau-ende", $terms)) { $args = array( 'id' => 'custom_text_field_title', 'label' => __( 'Custom Text Field Title', 'cfwc' ), 'class' => 'cfwc-custom-field', 'desc_tip' => true, 'description

Display Product Brand and Name in Woocommerce Orders and email notifications

☆樱花仙子☆ 提交于 2019-12-08 03:58:11
问题 In WooCommerce I have enabled Perfect Brands Woocommerce plugin to display product Brands. I would like the Brand to appear before the product name throughout the whole cycle (single product page, cart, checkout, mini cart, order and emails). I am able to display the related brand before the product name in cart and checkout pages, using "Adding Woocommerce Brands names to cart item product names" answer code lightly changed (using pbw-brand plugin custom taxonomy) : // Display product brand

How to get real term_meta using ACF with custom fields on taxonomy terms (instead of wp_options)

ぐ巨炮叔叔 提交于 2019-12-06 16:17:48
Having a simple Woocommerce site, I'm using ACF pro to add some custom fields to the terms of a given taxonomy. Using this, I can, for example, add a "color" field to my "product category" taxonomy terms. Good. The issue: Wanting to do some query using get_terms() ( codex ), I discovered that my meta_query parameters were not working (unexpected results). Why ? My custom fields were not saved (from backend) as term_meta but as wp_option . It seems that ACF 4 is saving those fields, not as term_meta (as it's designed for), but as wp_option , in the Wordpress options table. So you cannot "query