custom-taxonomy

Display specific product attributes under product title in Woocommerce archive pages

倖福魔咒の 提交于 2021-02-18 18:19:33
问题 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_insertAfterShopProductTitle() { global $product; $abv = $product->get_attribute('pa_year'); if (empty($abv)) return; echo __($abv, 'woocommerce'); } Any help is appreciated. 回答1: To display "year", "model" and "oil"

Display specific product attributes under product title in Woocommerce archive pages

≯℡__Kan透↙ 提交于 2021-02-18 18:18:48
问题 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_insertAfterShopProductTitle() { global $product; $abv = $product->get_attribute('pa_year'); if (empty($abv)) return; echo __($abv, 'woocommerce'); } Any help is appreciated. 回答1: To display "year", "model" and "oil"

Display specific product attribute in Woocommerce single product pages below price

余生长醉 提交于 2021-02-10 19:35:26
问题 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 single product pages? 回答1: The following will display a specific product attribute label name + values under the price in single product pages only if it has a value. This can be done using WC

wp_list_categories() - display first level categories and only current term's children in subcategory page

人盡茶涼 提交于 2021-02-08 03:58:13
问题 I'm using WordPress. Have multiple categories with its subcategories. In general page, I'm displaying all first level categories. Here is my code: $args = array( 'type' => 'product-items', 'child_of' => 0, 'parent' => '', 'order' => 'DESC', 'hide_empty' => 0, 'hierarchical' => 1, 'exclude' => '', 'include' => '', 'number' => '', 'taxonomy' => 'product-category', 'pad_counts' => false, 'depth' => 1, 'title_li' => '' ); wp_list_categories($args); Once you click and go inside a first level

Load specific element on Woocommerce product category archives

拥有回忆 提交于 2021-02-07 08:27:50
问题 is their a way via the functions.php or an other php method to don't load a specific div element on the shop / main page in woocommerce? <div id="nm-shop" class="nm-shop nm-shop-sidebar-header images-lazyload images-show" style="min-height: 288px;"> ... </div> This code includes a filter and the product archives of my shop page, but i only wanna display this at the category pages, where it already works, but not on the main page. How can i stop loading this div element on the shop / main page

Load specific element on Woocommerce product category archives

两盒软妹~` 提交于 2021-02-07 08:27:35
问题 is their a way via the functions.php or an other php method to don't load a specific div element on the shop / main page in woocommerce? <div id="nm-shop" class="nm-shop nm-shop-sidebar-header images-lazyload images-show" style="min-height: 288px;"> ... </div> This code includes a filter and the product archives of my shop page, but i only wanna display this at the category pages, where it already works, but not on the main page. How can i stop loading this div element on the shop / main page

Check a product category for a product in Woocommerce

女生的网名这么多〃 提交于 2021-02-05 08:16:06
问题 I want to check the category of a WooCommerce product post right after it's created(or updated) and then run some more code based on the category. To check post on creation/update I used save_post and for category has_category . Something goes wrong with has_category and it doesn't return anything at all. I tried replacing $post_id with $post and $post->ID as suggested in other issues but that didn't change anything. function doFruitStuff($post_id){ // Function in functions.php $fruits =

Allow only one item in cart from defined product categories in Woocommerce

梦想与她 提交于 2021-02-04 16:30:10
问题 In Woocommerce, I found a bit of code that restricts a users purchase to one per category for category a or b. So currently the user could purchase 2 items 1 from cat a and 1 from cat b. I would like to limit the user to only one product from category a or b. The code I am working with is below, thanks in advance. add_filter( 'woocommerce_add_to_cart_validation', 'allowed_quantity_per_category_in_the_cart', 10, 2 );function allowed_quantity_per_category_in_the_cart( $passed, $product_id) {

Custom category page title in Woocommerce

安稳与你 提交于 2021-01-28 14:38:10
问题 On some Woocommerce category pages I would like to change the default Category Page title to something custom. I dont want to change the original "name" on the backend. Is there some code that I can use for this in functions.php? 回答1: The following will allow you to customize the page title on Woocommerce product category pages, for specific product categories: add_filter( 'woocommerce_page_title', 'customize_woocommerce_page_title', 10, 1 ); function customize_woocommerce_page_title( $page

Add a body class for product category archive page in Woocommerce

情到浓时终转凉″ 提交于 2021-01-28 08:36:31
问题 I want to add product category slug in the body class on product category archive pages. Here is an example of what I would like (url of the product category page example) : https://example.com/product-category/canon/ … So I would like "canon" in the body class. 回答1: Your example link doesn't seem to work; however, WooCommerce should already be adding a term-specific class to your category pages: something along the lines of archive tax-product_cat term-{slug} term-{id} to a product category