Questions tagged [custom-taxonomy]

1

votes
0

answer
262

Views

Display custom taxonomy child terms with category image on parent term archive

I have a CPT with a custom taxonomy called 'equipment_cat'. I'm currently displaying the subcategories of a category on the category archive using the following code: I'm using Taxonomy Images plugin to attach an image to each category. I've created a custom page template to display all top level ca...
Ciaran Gaffey
1

votes
1

answer
116

Views

Customizing Woocommerce tags built-in structure issue

I'm trying to change the Woocommerce tags to hierarchical by using: function wd_hierarchical_tags_register() { $labels = array( 'name' => 'Items', 'singular_name' => 'Item', 'menu_name' => 'Item', 'all_items' => 'All Items', 'paren...
Galili Omri
1

votes
1

answer
310

Views

Wordpress: custom post type category link + add to menu

I am currently developing my own travel website/blog. I would like to add 'hotels' and 'tips and tricks' to this website. I have made two custom post types that use the default post categories as a taxonomy (as shown below). I haven't bothered making custom taxonomies, as it would triple my work loa...
Michiel Standaert
1

votes
1

answer
542

Views

Display item product categories names in Woocommerce cart and checkout

Im using Woocommerce 3.3.3. and Visual Products Configurator 4.0 In My web site you can add some product to cart and proceed to checkout I have edited cart/cart.php template to show my product category name in cart (from line 75 to 79). The code
g3ar
1

votes
0

answer
120

Views

Is it possible to have a two segments value for the slug rewrite for a custom taxonomy?

I have a custom taxonomy for location that is assigned to two post types which are post and events. To make it easier, I have created two separate location taxonomies and assigned each to the two posts types. Now, my concern is the URL structure. I am hoping to be able to use the same slug which is...
Jeda Dragon
1

votes
1

answer
232

Views

If statements in a foreach loop based on Woocommerce product attributes

I was using the following code to set images for each attribute term and it worked just fine only if there was just one term assigned to each product: function tutsplus_list_attributes( $product ) { global $product; $style = array_shift( wc_get_product_terms( $product->id, 'pa_style', array( 'fiel...
Michelle Britton
1

votes
0

answer
30

Views

Trying to display custom field data in custom taxonomy all categories list wordpress

I have created custom taxonomy stores and added custom field store_url. How can I display the store_url from meta data in to the table for each store. I am not able to find the exact answer. Can anyone please help me? I have also created custom column as Url I need to display data into it
Ahmed
1

votes
1

answer
62

Views

Exclude a product category from custom displayed button on Woocommerce archives

I'm using the following code to add a 'Back to All Categories' link on product category pages: add_filter( 'woocommerce_after_shop_loop', 'wc_add_content_on_category_pages', 30 ); function wc_add_content_on_category_pages() { if ( is_product_category() ) { echo 'Back to All Categories'; } } However...
amber
1

votes
1

answer
251

Views

Mandatory Coupon code for specific Woocommerce product category items

In Woocommerce, I'm trying to make a Coupon Code mandatory for all Products from a specific Category. The following code (placed in functions.php) works well, but makes Coupon Codes mandatory for all Products regardless of the product category: add_action('woocommerce_check_cart_items', 'make_coupo...
Crundi
1

votes
1

answer
355

Views

Display specific product attribute in Woocommerce single product pages below price

In woocommerce, If a specific product attribute has a value, then I would like to display its corresponding text/value on product single product pages under the price. How to check if a specific product attribute has a value? How to get a specific product attribute name and value to display it in si...
Tommy
1

votes
1

answer
113

Views

Send email if woocommerce order has items from a specific product category

I am having some problems with the code below, i am looking to send an email when an order completes on woo commerce, that catch is that it must be of a certain category can someone please help. add_action( 'woocommerce_catmail', 'my_function' ); function my_function($order_id) { $order = wc_get_ord...
Marc Jones
1

votes
1

answer
143

Views

Filter product loop based on user dynamic product attribute value in Woocommerce

How do I modify the main loop of WooCommerce to filter based on a logged in user's ACF field? I have added a new field to the user profile using ACF, it pulls a select list from a product attribute (Vehicle Year). I want to make it so products only show up for the user based on what vehicle year the...
I'm A Mac Geek
1

votes
1

answer
1.6k

Views

Get Woocommerce products by custom taxonomy term values in a WP_Query

I'm developing a plugin that will be placed in my woocommerce product sidebar. I need that, given the product id/object, it will find 2 product with the same custom taxonomy I created before. With this code I got the list of terms used in my product where 'collane' is the custom taxonomy: get_the_te...
Kryuko
1

votes
1

answer
388

Views

Display Related products for a specific product attribute value in single product pages

In Woocommerce, I have set a COLLECTION_ID product attribute for my products. I would like to display all related products to this COLLECTION_ID product attribute value on single product pages. Any suggestions?
Subhonkulov
1

votes
1

answer
1k

Views

Shortcode to display Woocommerce product attributes

I am new to WooCommerce and am looking for a solution to display Product attributes on a post page. I've made research and some test but nothing seems to work. Ideally, I would like to use a shortcode taking the Product ID and displaying all his attributes on my post page. something like [product_p...
Rémi
1

votes
1

answer
381

Views

Change product's attribute term names in dopdowns with ACF in Woocommerce

I have Variable products with Attributes and Term inside them. I created (with ACF) an additional Custom field for every Product Attribute term 'external_name'. I am using this code to get custom rules in ACF (see the screenshot at the end): add_filter( 'acf/location/rule_types', function( $choices...
1

votes
0

answer
145

Views

Change Add To Cart button text based on Woocommerce parent product categories

I am using the following code to change the wording on a Woo product add to cart button based on its parent category. The code works but has the following bug. If one of the parent categories is empty (i.e. does not have any sub cats) then the code no longer works. So the current code must be missi...
khunmax
1

votes
0

answer
134

Views

WooCommerce first last issues with product loop

I have an issue with a product loop in WooCommerce. My code is as follows: As you can see the loop shows featured products and excludes products out of stock. The problem is that the WC classes 'first' and 'last' is not added correctly to the results. The first product in the loop gets the class 'la...
Virik
1

votes
2

answer
211

Views

Add a product category linked button to Woocommerce single product pages

I am trying to add a link to single product page that goes back to category page of that product add_action ('woocommerce_before_single_product','add_backbtn_fcategory', 5); function add_backbtn_fcategory(){ $category_id = get_cat_ID(); $category_link = get_category_link( $category_id ); ?>
1

votes
1

answer
36

Views

Hide cart coupon field for specific products category in Woocommerce 3

function hidding_coupon_field_on_cart_for_a_category($enabled) { // Set your special category name, slug or ID here: $special_cat = 'clothing'; $bool = false; foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) { $wc_product = $cart_item['data']; // Woocommerce compatibility $product_...
Lars Hanck
1

votes
1

answer
251

Views

Get product ids from specific product attributes values using SQL in Woocommerce

I am trying to get product ids where product attributes pa_color = 'Black' and pa_waterproof = 'Yes'. But I have not succeeded yet. This is my code: global $wpdb; $product_id = $wpdb->get_results( ' SELECT post_id FROM $wpdb->postmeta WHERE meta_key='pa_color' AND meta_value='Black' AND meta_key...
cham
1

votes
1

answer
220

Views

Remove checkout fields for a defined product category in Woocommerce

In woocommerce I am trying to remove unwanted checkout shipping fields for a product category 'house'. Here is my code: function woo_custom_category_is_in_the_cart( $categories ) { // Products currently in the cart $cart_ids = array(); // Categories currently in the cart $cart_categories = array('ho...
lrvanjan
1

votes
1

answer
206

Views

Change the order from additional checkout fields in WooCommerce checkout manager

In Woocommerce, I would like to change additional checkout fields order (programmatically) made with WooCommerce checkout manager plugin. This is what I have actually: I will need to change the order from 'Rolls per Carton' field after 'Format' field. Any help is appreciated.
Vladymyr Grey
1

votes
1

answer
55

Views

Change header based on parent product category in Woocommerce

I am running an e-commerce store where I have two custom headers for different sides of the store. I am wondering if is possible that for: the parent product category A to display header A the parent product category B to display header B I just don't know where to put it in my theme. Here is my act...
Spade
1

votes
1

answer
159

Views

Change a specific product button text in a Woocommerce product category page

How can I change the 'Select Options' button to a 'Buy Now' button for a specific variable product being shown on a specific archive category page in WooCommerce? The Select Options button to be changed on the specific product category page:
Huy
1

votes
1

answer
239

Views

Limit the number of products displayed in woocommerce product category pages

I am using the sober theme and I want to limit number of products to be show on the category page of each category. Currently it is showing more than 10 products on a single page, what if I want to limit this to 10? I was able to limit number of related products on products description page. How do...
Mustanish Altamash
1

votes
1

answer
185

Views

Get product attribute labels from variations of a variable product in Woocommerce

I create a sample 'woocommerce' product list, then the single product page has didn't get the attribute label of the product. below show the code
Abdul Rafi
1

votes
0

answer
35

Views

Change custom post category/taxonomy url

I have created custom post Movies and named it taxonomy as genre. So now i have a comedy genre, it's url i get is example.com/genre/comedy What i am trying to achieve is this i want re-write it's url to example.com/comedy-genre and another example would be example.com/action-genre Please help me h...
Nimesh Deo
1

votes
0

answer
70

Views

Woocommerce product attributes not queried with get_terms()

When I try to query my custom product attributes using get_terms(array( 'taxonomy' => array('pa_kolor'), 'hide_empty' => false )); It's working just fine. However, when I add any additional taxonomies, for example: get_terms(array( 'taxonomy' => array('category', 'pa_kolor', 'product_cat'), 'hide_e...
Tomasz Lisek
1

votes
1

answer
202

Views

How to order products by custom taxonomies in Woocommerce?

I have searching for a long time to find a solution to my problem, but it seems I can't find it (or maybe I don't understand well some posts I have found here). The thing is that I have create a custom tag on my site, which is 'marca' (label, in English). My client wants to sort all her products by...
Rafa
1

votes
1

answer
47

Views

Show brand tags in read more button on Woocommerce archive pages

In Woocommerce, I am using YITH WooCommerce Brands plugin to handle product brands. I would like to show brand tags in woocommerce read more button. This is my code: // Shop Catalog mode if ( zget_option( 'woo_catalog_mode', 'zn_woocommerce_options', false, 'no' ) == 'yes' ) { remove_action( 'woocom...
2 Rings
1

votes
1

answer
116

Views

Replace Upsells with products from a specific product category in Woocommerce 3

I have the following case - So far I've always set the Upsell products custom, 1 by 1, as choosing a product category in the admin is not possible. Now after a big cleaning of products that are no longer available, there are many product pages on the site with 1, 2 or 3 instead of the default number...
StephanG
1

votes
1

answer
186

Views

Display specific product attributes under product title in Woocommerce archive pages

In woocommerce, I would like to show some product attributes on shop page under the product titles. This product attributes are 'year', 'model' and 'oil'. This is what I have for now: add_action('woocommerce_shop_loop_item_title', 'wh_insertAfterShopProductTitle', 15); function wh_insertAfterShopPro...
poirotohercules
1

votes
0

answer
38

Views

How can I fire a custom function just once in Woocommerce

I need to add variations to my Woocommerce products programmatically and I borrowed the code from this answer thread: Create programmatically a WooCommerce product variation with new attribute values It works, but gives me two variations when I pass this data array: $variation_data = array( 'attri...
Marvin
1

votes
1

answer
226

Views

List product categories hierarchy from a product id in Woocommerce

I have a products that can be in multiple categories, example take a look at the following strings: Cat1>Product1 Cat1>Product2 Cat2>subcat1>Product1 Cat3>subcat1>subcat2>Product1 In woocommerce, if I have a productid, I can do the following: function alg_product_categories_names2( $atts ) { $produc...
mrD
1

votes
0

answer
36

Views

Allow backorders and notify customer for parent product categories in Woocommerce Bug with Variable products

I'm using this code to enable backorders in products for all categories: Allow backorders and notify customer for parent product categories in Woocommerce it works well, but when I add this code which adds the stocks of all variant in variable products Display the stock availability for all product...
Erwin Manalang
1

votes
1

answer
164

Views

Get product attributes values from cart items in Woocommerce

I need to change the weight of product after adding it to cart. The weight depends on the product attribute 'quantite-avec-fenetre'. Based on Change cart items weight to update the shipping costs in Woocommerce, I am trying to use the following function in my theme's functions.php file: add_action(...
Jérémie Czk
1

votes
1

answer
140

Views

Allow only one product purchase for a specific product category in Woocommerce

I want to limit the number of times a user can purchase a product from a particular category. I have this code (from here) in function.php that limits the whole store to one time purchase. add_filter('woocommerce_add_to_cart_validation','rei_woocommerce_add_to_cart_validation',20, 2); function rei_w...
nighter
1

votes
1

answer
68

Views

Replace Woocommerce taxonomy archive pages title with ACF custom field

I am trying to figure out how to replace 'woocommerce_page_title' with an ACF field? If there isn't one then it should fall back to 'woocommerce_page_title();'. I can't seem to find anything super helpful. Your help would be greatly appreciated. add_filter( 'woocommerce_page_title', 'custom_title' )...
Tamlyn Holmes
1

votes
1

answer
237

Views

Display specific product attribute in Woocommerce archive pages

I've been looking around SO trying to find an answer to this, but no luck yet. Basically, I want to display some meta data under the title of my products on the archive / shop page(s). My attribute is 'colors', so after trying various pieces of code, I came up with this: add_action( 'woocommerce_aft...
Adam Bell

View additional questions