product

Exclude a WooCommerce product category from a WP_Query

无人久伴 提交于 2021-01-05 07:19:24
问题 I've got the following args defined as a part of my query: $args = apply_filters('woocommerce_related_products_args', array( 'post_type' => 'product', 'author' => $artist, 'post_status' => 'publish', 'meta_query' => array( array( 'key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN' ) ) ) ); $products = new WP_Query( $args ); I need to exclude a category called Magazines (slug "magazines") or ID 351 from the query. I've been trying to include 'category__not_in' =>

Exclude a WooCommerce product category from a WP_Query

孤街浪徒 提交于 2021-01-05 07:17:09
问题 I've got the following args defined as a part of my query: $args = apply_filters('woocommerce_related_products_args', array( 'post_type' => 'product', 'author' => $artist, 'post_status' => 'publish', 'meta_query' => array( array( 'key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN' ) ) ) ); $products = new WP_Query( $args ); I need to exclude a category called Magazines (slug "magazines") or ID 351 from the query. I've been trying to include 'category__not_in' =>

Add image file upload field to WooCommerce single products

故事扮演 提交于 2020-12-31 06:20:04
问题 i have created a custom plugin which dynamically displays custom fields in woocommerce single product page. Fields are displayed, added to cart and added to order data and emails. However i'm trying for days to add a file upload field with no luck. The field is displayed in the frontend like: add_action( 'woocommerce_before_add_to_cart_button', 'display_custom_fields' ); function display_custom_fields() { ?> <p class="form-row validate-required" id="image" > <span class="woocommerce-input

Add image file upload field to WooCommerce single products

陌路散爱 提交于 2020-12-31 06:19:02
问题 i have created a custom plugin which dynamically displays custom fields in woocommerce single product page. Fields are displayed, added to cart and added to order data and emails. However i'm trying for days to add a file upload field with no luck. The field is displayed in the frontend like: add_action( 'woocommerce_before_add_to_cart_button', 'display_custom_fields' ); function display_custom_fields() { ?> <p class="form-row validate-required" id="image" > <span class="woocommerce-input

Add a line break to Woocommerce cart item names and order item names

时光总嘲笑我的痴心妄想 提交于 2020-12-13 20:59:11
问题 Context This question is a follow-up on the previous question titled Add a line break in Woocommerce Product Titles To me the code in this topic (seen here below) works like a charm, when adding it to my child astra theme. I have a question to upgrade this code a bit, hoping some smart developers out there might help me. //ADD LINE BREAK add_filter( 'the_title', 'custom_the_title', 10, 2 ); function custom_the_title( $title, $post_id ) { $post_type = get_post_field( 'post_type', $post_id,

Split cart items when quantity is updated on cart page in WooCommerce

两盒软妹~` 提交于 2020-12-13 12:08:49
问题 I want to split cart items of same product in individual lines. When I increase quantity on single product page and add to cart, it shows as separate cart items. Im using WooCommerce - Treat cart items separate if quantity is more than 1 answer code. I want when quantity is updated on cart page and clicked on 'Update cart', then items must split on individual lines. How can I do that? 回答1: The code below will split items on individual lines when quantity is updated on the cart page. Comment

Split cart items when quantity is updated on cart page in WooCommerce

 ̄綄美尐妖づ 提交于 2020-12-13 12:07:13
问题 I want to split cart items of same product in individual lines. When I increase quantity on single product page and add to cart, it shows as separate cart items. Im using WooCommerce - Treat cart items separate if quantity is more than 1 answer code. I want when quantity is updated on cart page and clicked on 'Update cart', then items must split on individual lines. How can I do that? 回答1: The code below will split items on individual lines when quantity is updated on the cart page. Comment

Get WooCommerce Product total sales amount

≡放荡痞女 提交于 2020-12-13 03:30:34
问题 I have created a shortcode that will returns all products in a loop. I am looking for a way to get the total sales for each product. Right now i'm still having hard time finding the solution. This is my code: function loop_ffh_function() { ?> <div class="row"> <?php $args = array( 'numberposts' => -1, 'post_type' => 'product', 'orderby' => 'date'); $loop = new WP_Query($args); while ($loop->have_posts()) : $loop->the_post(); global $product; ?> <?php $productID = get_the_ID(); ?> <div class=

Remove add cart button in Woocommerce for a specific product category

醉酒当歌 提交于 2020-12-05 11:35:22
问题 I have an issue how to remove a cart from a category product. It works just fine if I apply it to a specific id or all in general, but I am unable to do it for a category. Below is my code I have done regarding it. Also, I am struggling to apply this same pattern to Related Articles section, so any help would be appreciated. Thank you. //function for deleting .... function remove_product_description_add_cart_button(){ global $product; //Remove Add to Cart button from product description of

Hide WooCommerce variable product from catalog if all variations are out of stock

可紊 提交于 2020-11-30 02:03:04
问题 Within my WooCommerce shop, there are products with variations in color. The update on the stock is on variations level because the external feed sees every color as a different product. Now I've got a issue where all the variations of a variable product are out of stock , but the product itself still show up in the catalog of the Webshop. Even tho I turn on the setting "Hide out of stock items from the catalog". But this setting only works for products without variations. When you click on a