custom-taxonomy

Set item quantity to multiples of “x” for products in a specific category in Woocommerce

偶尔善良 提交于 2019-12-02 12:33:11
问题 I found online a snippet that allows you to set in the cart a minimum purchase to multiple quantities of “6”. Here it is: add_action( ‘woocommerce_check_cart_items’, ‘woocommerce_check_cart_quantities’ ); function woocommerce_check_cart_quantities() { $multiples = 6; $total_products = 0; foreach ( WC()->cart->get_cart() as $cart_item_key => $values ) { $total_products += $values['quantity']; } if ( ( $total_products % $multiples ) > 0 ) wc_add_notice( sprintf( __('You need to buy in

Custom Post Type and Taxonomy pagination 404 error

蓝咒 提交于 2019-12-02 09:46:54
Pagination is not working on taxonomy.php. Here is my code for register custom post type and taxonomy add_action('init', 'ep_add_equipment'); function ep_add_equipment() { $labels = array( 'name' => _x('Equipments', 'post type general name', 'epanel'), 'singular_name' => _x('Equipments', 'post type singular name', 'epanel'), 'add_new' => _x('Add New Equipment', 'slide', 'epanel'), 'add_new_item' => __('Add New Equipment', 'epanel'), 'edit_item' => __('Edit Equipment', 'epanel'), 'new_item' => __('New Equipment', 'epanel'), 'view_item' => __('View Equipments', 'epanel'), 'search_items' => __(

Display category and brand name on single product page

回眸只為那壹抹淺笑 提交于 2019-12-02 06:22:59
In Woocommerce, I am using YITH WooCommerce Brands plugin to handle product brands. I'm currently struggling with a fixed text That I want under my short description in WooCommerce. I want to display dynamically the product name in that text (which works) , but also the product category name [CATEGORY_NAME] and brand name [BRAND_NAME] . But I can't seem to get those to work. Based on this answer thread: Add Text under Single Product Short Description in Woocommerce Here is my code version: // Add text after short description add_action( 'woocommerce_single_product_summary', 'custom_single

Custom product price suffix for selected product categories in Woocommerce

与世无争的帅哥 提交于 2019-12-02 00:18:01
I would like to display a piece of text after the price tag in WooCommerce. I have a code that is working for my functions.php, but it shows on all product categories. I was wondering if someone knows how to make this custom text to show for only selected categories; or even better, unselected product categories as there are a lot more product categories that will display the text than the ones who doesn't. My actual code: add_filter( 'woocommerce_get_price_html', 'custom_price_message' ); function custom_price_message( $price ) { $mt = ' per M/T'; return $price . $mt; } Any help on this

getting custom taxonomies terms of a post

China☆狼群 提交于 2019-12-01 13:15:40
问题 I am trying to get print names of custom taxonomy that i have created for products. function create_product_taxonomies() { // Add new taxonomy, make it hierarchical (like categories) $labels = array( 'name' => _x('product_categories', 'taxonomy general name'), 'singular_name' => _x('Product', 'taxonomy singular name'), 'search_items' => __('Search Product Category'), 'all_items' => __('All Product Categorie(s)'), 'parent_item' => __('Parent Product Category'), 'parent_item_colon' => __(

Sort Woocommerce Products from a product category and custom meta_key

本秂侑毒 提交于 2019-12-01 10:37:36
问题 Im successfully filtering ALL my Wordpress posts by Likes (count) with a Custom Plugin (and meta_key) wich also let me filter the most liked posts in categories. I display (query) the result in a custom page template. Everything works fine. The Like function works also on Woocommerce Products. But so far i was not able to set up a page where i sort the Products (post_type) the same way in a specific shop cateogry as i do it with my posts. The closest i came was to display the most liked posts

Allow backorders and notify customer for parent product categories in Woocommerce

99封情书 提交于 2019-11-29 17:19:44
With woocommerce, I used some code based on my previous thread: Allow backorders and notify customer for specific product categories in Woocommerce add_filter( 'woocommerce_product_is_in_stock', 'filter_product_is_in_stock', 10, 2 ); function filter_product_is_in_stock( $is_in_stock, $product ){ // Here set the products categories in the array (can be terms ids, slugs or names) $categories = array("clothing"); if( has_term( $categories, 'product_cat', $product->get_id() ) ){ $is_in_stock = true; } return $is_in_stock; } add_filter( 'woocommerce_product_backorders_allowed', 'filter_products

Change default sorting for specific Woocommerce product category archive pages

与世无争的帅哥 提交于 2019-11-29 17:05:45
I need to change the default product sorting option to "Newness" for a specific product category on my site. I know you can go to WooCommerce > Settings > Product > Display to globally change the default sorting option, but thats not what I need to do. I need something like: function change_default_sorting_option(){ if(is_product_category('3555')){ //change default sorting option to newness } } add_action('', 'change_default_sorting_option'); I haven't done much with the sorting functionalities so I'm not exactly sure where to start. I know the function should go in my child theme's functions

Replace default “Select Option” text in Woocommerce variation attribute dropdowns by different custom ones

别说谁变了你拦得住时间么 提交于 2019-11-29 13:04:43
I am just starting out with Woocommerce and have a question about drop down select field for variable products. In woocommerce when nothing is selected on this dropdowns, "Select Option" text is displayed. I need each dropdown select field option to display a different text when nothing has been selected yet. I found this code which replaces the standard "Select Option" text with what ever I want, but it does to all dropdowns select fields. function custom_woocommerce_product_add_to_cart_text($args){ $args['show_option_none'] = __( 'Select Framed or Unframed Sizes', 'woocommerce' ); return

Change default sorting for specific Woocommerce product category archive pages

拥有回忆 提交于 2019-11-28 10:49:18
问题 I need to change the default product sorting option to "Newness" for a specific product category on my site. I know you can go to WooCommerce > Settings > Product > Display to globally change the default sorting option, but thats not what I need to do. I need something like: function change_default_sorting_option(){ if(is_product_category('3555')){ //change default sorting option to newness } } add_action('', 'change_default_sorting_option'); I haven't done much with the sorting