hook-wordpress

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

Run a function on custom button click in woocommerce admin order page

不打扰是莪最后的温柔 提交于 2019-12-24 14:40:01
问题 Based on "Add a button on top of admin orders list in woocommerce" answer code, I was able to add a custom button on woocommerce admin orders list. Here is that code (lightly customized) : add_action( 'manage_posts_extra_tablenav', 'admin_order_list_top_bar_button', 20, 1 ); function admin_order_list_top_bar_button( $which ) { global $typenow; if ( 'shop_order' === $typenow && 'top' === $which ) { ?> <div class="alignleft actions custom"> <button type="submit" name="custom_" style="height

Create a Woocommerce product when post is created

亡梦爱人 提交于 2019-12-08 07:33:49
问题 I am using Woocommerce on my WordPress site. and I am Selling Various items on my site. What I want is that every time I create a small post about a particular item.it also creates a Woocommerce product page with the one item available to be sold. For example: I create a post about custom-made jewelry and I write a small post about it, and the customer can look at the post and buy it from the Woocommerce product section. Once the product is out of stock the post disappears"Hidden" until I

Hooks and their hooked functions execution queue in Wordpress and Woocommerce

别说谁变了你拦得住时间么 提交于 2019-12-08 04:32:10
问题 I am new to Wordpress/WooCommerce and PHP, although I have experience in other web platforms and languages. I have searched, but have not found the answer to my question which is... Are hooks that are created by the "add_action" "added" to the list of actions called by that specific hook, or do they override any existing hooks of that action? For example, if I add a woocommerce_thankyou hook using: add_action( 'woocommerce_thankyou', 'order_created_get_skus',#); Question: Does this override

Reduce product long description in Woocommerce

那年仲夏 提交于 2019-12-02 01:56:47
I have found the following code from this answer thread , but it only applied under the product title. So how can apply to the detailed description of the product. add_action( 'woocommerce_after_shop_loop_item_title', 'shorten_product_excerpt', 35 ); function shorten_product_excerpt() { global $post; $limit = 14; $text = $post->post_excerpt; if (str_word_count($text, 0) > $limit) { $arr = str_word_count($text, 2); $pos = array_keys($arr); $text = substr($text, 0, $pos[$limit]) . '...'; // $text = force_balance_tags($text); // may be you dont need this… } echo '<span class="excerpt"><p>' .

Reduce product long description in Woocommerce

空扰寡人 提交于 2019-12-02 01:45:33
问题 I have found the following code from this answer thread, but it only applied under the product title. So how can apply to the detailed description of the product. add_action( 'woocommerce_after_shop_loop_item_title', 'shorten_product_excerpt', 35 ); function shorten_product_excerpt() { global $post; $limit = 14; $text = $post->post_excerpt; if (str_word_count($text, 0) > $limit) { $arr = str_word_count($text, 2); $pos = array_keys($arr); $text = substr($text, 0, $pos[$limit]) . '...'; //

Adding “Sale” product category to products that are on sale in Woocommerce

烈酒焚心 提交于 2019-11-30 20:20:53
As part of a WooCommerce site I want to have a sale page that lists sale items (with pagination and filtering). I think the best way to do this is to have a 'Sale' category that is added automatically to any posts that are part of the sale (as category pages allow for filtering and pagination automatically. I have this code so far to programatically add the sale category to products when you save them: function update_test( $product) { wp_set_object_terms($product, 'sale', 'product_cat', true ); } add_action( 'save_post', 'update_test', 1, 2);` However, I only want this to happen if a product

Adding “Sale” product category to products that are on sale in Woocommerce

时光总嘲笑我的痴心妄想 提交于 2019-11-30 04:44:08
问题 As part of a WooCommerce site I want to have a sale page that lists sale items (with pagination and filtering). I think the best way to do this is to have a 'Sale' category that is added automatically to any posts that are part of the sale (as category pages allow for filtering and pagination automatically. I have this code so far to programatically add the sale category to products when you save them: function update_test( $product) { wp_set_object_terms($product, 'sale', 'product_cat', true