product

Filter products from a specific custom meta data in Woocommerce shop page

ぐ巨炮叔叔 提交于 2020-08-07 03:21:24
问题 I need to filter the WooCommerce shop page and only want to display products which expects a custom product meta data. This is what I've found in the archive-product.php : /** * Hook: woocommerce_before_shop_loop. * * @hooked wc_print_notices - 10 * @hooked woocommerce_result_count - 20 * @hooked woocommerce_catalog_ordering - 30 */ do_action( 'woocommerce_before_shop_loop' ); woocommerce_product_loop_start(); if ( wc_get_loop_prop( 'total' ) ) { while ( have_posts() ) { the_post(); /** *

How to display the variation name in Woocommerce Items

空扰寡人 提交于 2020-08-05 11:11:27
问题 I am trying to make a Ajax popup cart where product will be add dynamically. Everything is working fine except the product variation. when a variable product added to cart its not showing the variation name: <?php $items = WC()->cart->get_cart(); foreach($items as $item => $values) { $_product = wc_get_product( $values['data']->get_id() ); $product_link = get_permalink( $values['data']->get_id() ); $title = $_product->get_title(); $variations = wc_get_formatted_cart_item_data($values,true);

Get WooCommerce featured products in a WP_Query

三世轮回 提交于 2020-08-04 04:02:23
问题 I updated WooCommerce to version 3.0 but I can't show the featured products on my theme, I googled a while and get WC deleted the _feature and add this in taxonomy. But I don't understand so much how my theme get the featured products. Here is the code of the wrong featured productcs. $meta_query = WC()->query->get_meta_query(); $meta_query[] = array( 'key' => '_featured', 'value' => 'yes' ); $args = array( 'post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1,

Woocommerce: Only show related products from same subcategory

…衆ロ難τιáo~ 提交于 2020-08-03 01:56:40
问题 Related products is a section that pulls other products from your store that share the same tags or categories as the current product. src: Woocommerce Docs Lets say I sell tables (and other items) in my store. Tables is a category. I have 3 subcategorys that go with the table category: Small, Medium and Large. What I want: when you click on a small table. The related products should only show small tables. What it does: When you click on a small table. The related products shows a table from

Woocommerce: Only show related products from same subcategory

雨燕双飞 提交于 2020-08-03 01:56:30
问题 Related products is a section that pulls other products from your store that share the same tags or categories as the current product. src: Woocommerce Docs Lets say I sell tables (and other items) in my store. Tables is a category. I have 3 subcategorys that go with the table category: Small, Medium and Large. What I want: when you click on a small table. The related products should only show small tables. What it does: When you click on a small table. The related products shows a table from

How to get the Product ID from a WC_Subscription instance Object

雨燕双飞 提交于 2020-07-23 05:47:08
问题 This one for completed initial subscription payments and subscription renewals. function payment_made($subscription){ // How do I get the Product ID from subscription? (Definitely need this) } add_action("woocommerce_subscription_payment_complete", "payment_made"); And this one for when a status is changed, so I can handle manual and system changes either manual overrides or failed/pending/active/whatever status based of payments or switches. function status_update($subscription, $old_status,

How to get the Product ID from a WC_Subscription instance Object

北城以北 提交于 2020-07-23 05:46:09
问题 This one for completed initial subscription payments and subscription renewals. function payment_made($subscription){ // How do I get the Product ID from subscription? (Definitely need this) } add_action("woocommerce_subscription_payment_complete", "payment_made"); And this one for when a status is changed, so I can handle manual and system changes either manual overrides or failed/pending/active/whatever status based of payments or switches. function status_update($subscription, $old_status,

How to get the Product ID from a WC_Subscription instance Object

心已入冬 提交于 2020-07-23 05:45:19
问题 This one for completed initial subscription payments and subscription renewals. function payment_made($subscription){ // How do I get the Product ID from subscription? (Definitely need this) } add_action("woocommerce_subscription_payment_complete", "payment_made"); And this one for when a status is changed, so I can handle manual and system changes either manual overrides or failed/pending/active/whatever status based of payments or switches. function status_update($subscription, $old_status,

Hide products with zero or empty price from Woocommerce archives pages

折月煮酒 提交于 2020-07-19 11:12:50
问题 I am setting wholesale store with Woocommerce and can't figure out following issue. I want to auto hide or delate all products, that have price set to zero or if product don't have price at all! I surf the web and found following code that should do exactly what i need, but i put it in my child theme functions.php file and it is not working for me! Hide products with the price set to zero in WooCommerce add_action( 'woocommerce_product_query', 'react2wp_hide_products_higher_than_zero' );

Get the regular price of variable product in Woocommerce

纵饮孤独 提交于 2020-07-18 06:17:05
问题 I found a lot of answers, but none works for a variable products. I would like to display both, sales price and regular price for variable products. global $product; if( $product->is_on_sale() ) { $sale_price = $product->get_sale_price(); } $regular_price = $product->get_regular_price(); This is working, but only if it is a normal product. I think there must be a possibility even for product variations, but I don't find it. Any help is appreciated 回答1: For prices in variable products you need