woocommerce,products , Woocommerce - Only show grouped products parent in the loop


Woocommerce - Only show grouped products parent in the loop

Question:

Tag: woocommerce,products

I'm building a store for books. I have a bunch of grouped products. My pain is, that woocommerce lists both type by default. I only need the parent of the group to be listed without childrens.

Is there any hook or workaround for this?

Thanks.


Answer:

Try the following:

add_action( 'woocommerce_product_query', 'so_27975262_product_query' );

function so_27975262_product_query( $q ){
    $q->set( 'post_parent', 0 );
}

The idea is that we're modifying the query such that it will only show top-level items.... thus (in theory) nothing that has been assigned to a group, which would then have the group product's ID as the post_parent.


Related:


WordPress - Failing to override woocommerce templates


wordpress,templates,woocommerce,override
I am trying to override Woocommerce's templates files by duplicating them in my custom theme directory / woocommerce / templates, but the changes don't appear (I tried simply adding classes to begin with) on the website. Is there something I am doing wrong ? Thank you for your concern....

WooCommerce query quantity on product page


php,forms,woocommerce
I have a button that I've added to my product page, and I want to query the quantity in the woocommerce_quantity_input() control. For the life of me I can't find how to do that. I can get $product information, and $cart information, but I can't find how to get the...

Woocommerce hide payment gateway for user roles


php,wordpress,woocommerce
Hey guys I have a cash on delivery payment method on my wordpress/woocomerce website that I want to hide from the customer user role and non-logged in users. I've been searching up and down and the only thing I found close was this bit of code. function paypal_disable_manager( $available_gateways )...

how to set different minimum order amount for free shipping for different user roles in woocommerce


php,wordpress,woocommerce
I want to set different minimum order price for different user roles for free shipping. How can I implement it? I am currently using the below code. add_filter( 'woocommerce_available_shipping_methods', 'filter_woocommerce_available_shipping_methods'); filter_woocommerce_available_shipping_methods() function: function filter_woocommerce_available_shipping_methods( $methods ) { global $woocommerce; get_currentuserinfo(); global $current_user; $roles = $current_user->roles[0]; if($roles == '') { $roles...

Add second single product page in Woocommerce


wordpress,woocommerce
Is it possible to add a second single product page in Woocommerce? So basically when I am at the single product page I click the "next" button and I get directed to the same single product page with another template. So I just want to retrieve the same data on...

How to add user roles dropdown in registration and login woocommerce wordpress


wordpress,woocommerce,wordpress-plugin-dev,wordpress-loop
I have a job site but i want to set drop down with roles i have 2 roles candidate and employer so i want to set a drop down select they roles i am using woocommerce registration and login i want to integrate dropdown with that roles for registration and...

WooCommerce seems to only orderby date and not price


php,ajax,wordpress,woocommerce
I am loading in variable products via a custom WP_Query $args = array( 'post_type' => 'product', 'posts_per_page' => 100, 'product_cat' => 'beast-balls', 'orderby' => 'date', 'order' => 'desc' ); $loop = new WP_Query( $args ); if ( $loop->have_posts() ) { while ( $loop->have_posts() ) : $loop->the_post(); ?> <div class="product-node cat-beast-balls">...

WooCommerce - Change the shop page layout but keep the archive-product.php


php,wordpress,woocommerce
I am new to WooCommerce and I am trying to build a shop using my custom theme created from scratch. The home page is a static page (custom template) just giving details about the shop . I created a folder in my themes folder named woocommerce and copied the template...

dont allow PO BOX shipping woocommerce not working


wordpress,woocommerce
add_action('woocommerce_after_checkout_validation', 'deny_pobox_postcode'); function deny_pobox_postcode( $posted ) { global $woocommerce; $address = ( isset( $posted['shipping_address_1'] ) ) ? $posted['shipping_address_1'] : $posted['billing_address_1']; $postcode = ( isset( $posted['shipping_postcode'] ) ) ? $posted['shipping_postcode'] : $posted['billing_postcode']; $replace = array(" ", ".", ","); $address = strtolower( str_replace( $replace, '', $address ) ); $postcode = strtolower( str_replace(...

WooCommerce - Display categories and its products on front page


php,wordpress,woocommerce
when the user visits my shop homepage he sees all the products which are in the shop. I want to change the view, so that the user sees: - Category 1 Products of cat 1 - Category 2 Products of cat 2 How can I achieve this? I looked in...

woocommerce_add_order_item_meta hook sending only one argument; three expected


wordpress,woocommerce,wordpress-plugin-dev
I am using WC v. 2.3.9. woocommerce_add_order_item_meta gets fired but my callback function only gets one parameter, three expected. I want to add order item meta at the creation of the order. Is this hook really available? Some rumour say that it's deprecated. Edit : after a few research it's...

How get variation's stock quantity woocommerce


php,woocommerce,stock,variations,variation
I'm developing a theme for wordpress and woocommerce. I need show variation's stock. <p class="stock-m13"><?php echo $product->get_stock_quantity(); ?></p> (here: How to get the stock quantity of an article from woocommerce?) but this code only show me the global stock quantity, not each variation quantity. I need another function to get...

fabricjs: how to show object size after scaling


javascript,jquery,wordpress,woocommerce,fabricjs
I am using wordpress plugin called "Woocommerce Product Designer" which includes a JavaScript library called fabicjs in version 1.4.9. I need a way to show the width and height of an object in fabric after (or while) I re-scale them. I made some adjustments directly in file fabric-all.min.js: _beforeTransform: function...

Upgrade to Woocommerce 2.3.10 caused checkout to block


php,wordpress,woocommerce
Environment: Wordpress - 4.2.2 Woocommerce - 2.3.10 Woocommerce Product Add-Ons - 2.7.4 WooThemes StoreFront Theme - 1.4.5 I just upgraded to WC 2.3.10 and then tried a test purchase. When I got to the checkout page the checkout area is grayed out (class="blockUI blockOverlay") and you cannot continue the purchase....

How to display grouped products in a list with quantity in woocommerce?


wordpress,woocommerce
I want to change the way grouped products are shown by two different versions of wordpress. case 1: Wordpress 4.1.5 running WooCommerce 2.3.11 with custom theme. case 2: Wordpress 4.2.2 running WooCommerce 2.3.11 with default theme. I need to display grouped products (child products) in a tabular form with quantity...

WooCommerce - Checking for brand page


php,wordpress,wordpress-plugin,woocommerce
I'm using WooCommerce on our site along with their Brands add-on to be able to group products together by brand - I know WooCommerce has it's own built in selection of hooks and filters but I want to write a function that checks if I'm on a Brand page or...

Woocommerce Return False with message


php,wordpress,woocommerce
I am using a function to remove the ability to purchase a product if its price is equal to, or greater than £50,000. I would like to add a message where the add to cart button usually is, to say "this product is over £50,000 - please contact us" add_filter(...

Show product-category thumbnails in loop which have n price of products in woocommerce


php,wordpress,woocommerce,category
I want to show category thumbnails in loop which has n price of products. Here n price will put from admin panel where a amount will fill and that products-category thumbnail will appear on a page which having that amount or greater than that amount of products. so please help...

Show product's image in “Orders” page - Woocommerce


php,wordpress,woocommerce
I am working with WC for the first time and I am chasing my tail with this one. In "Orders" page where customer's can see all the purchases they've made the array shows some basic info about the order. I need to also show the image of the product the...

Woocommerce API returns 1, but works


php,wordpress,woocommerce
I'm trying to write my own payment gateway for WooCommerce and it's going pretty well. Now my payment provider can do a callback to verify the payment status, so i created a callback function. add_action('woocommerce_api_'.strtolower(get_class($this)), array(&$this, 'callback')); public function callback() { mail('[email protected]', 'callback ideal', print_r($_REQUEST,true) . print_r($_SERVER,true)); echo '+'; return...

How To check Product Have Variation in woocommerce


php,wordpress,woocommerce,product
Is there any way to check the product has variation something like Please help me. <?php If (product has variation) { echo"This Product have Variations "; } else { echo "This Product does not have Variations "; } ?> ...

trouble using AFOAuth2manager to generate HTTPSOauthToken


ios,oauth,woocommerce,afoauth2client
I'm building an iOS app where costumers can login (with the same website username and password) into the app and purchase items from the app. The rest api for woo commerce says to use HTTP Basic Auth by providing the API Consumer Key as the username and the API Consumer...

How to remove the quantity field from cart page for specific product attribute WooCommerce


php,wordpress,woocommerce
I need to hide the "quantity" field for specific product in cart.php Here Is my cart.php . WHere the attribute is Color the quantity field should hide. I have try $attributes = $product->get_attributes(); but I failed or I was missing something . I have share the cart Image and my...

Woocommerce simple filter php


php,wordpress,woocommerce
My php skills is very low. I need some help this this function. What it should do: When a order is marked as "failed" it should redirect to the woocommerce cart with an error message. But problem is that this code redirect ALL status to the cart with the error...

Woocommerce Filter Product by Attribute


filter,attributes,woocommerce,product
I've been searching for many blogs and forum but this seems not yet answered yet. So i am trying to find a way how to filter product by attribute. I am using ajax to pull data and append it.The question is what will be the query to make a loop...

Remove item with $product_id - Woocommerce


php,wordpress,woocommerce
Made a function where the customer get a product added to the cart when they reach a specific amount. Example of when customer reaches level 3 and get the product added. // Bonus products $product_1 = '4751'; $product_2 = '4752'; $product_3 = '4753'; // Get cart value in a clean...

Select woocommerce chosen shipping method price


php,wordpress,woocommerce
I'm trying to select the chosen_shipping_method price in woocommerce using this code: $packages = WC()->shipping->get_packages(); foreach ($packages as $i => $package) { $chosen_method = isset(WC()->session->chosen_shipping_methods[$i]) ? WC()->session->chosen_shipping_methods[$i] : ''; } echo $chosen_method; the code works, but it prints the ID, and i cannot figure out how to make it print...

Add custom functionality on WooCommerce complete button


php,ajax,wordpress,wordpress-plugin,woocommerce
I've a situation to add some data to the database tables on order status completed button. I can see the url in class-wc-admin-post-types.php Can someone help me for any hook? Or how the admin-ajax.php works? I have to add status to some of mine custom database tables....

woocommerce redirect after registration


woocommerce
I am trying to redirect user after woocommerce registration. I have tried everything and it is not working. I tried this methods to no avail: http://wtheme.co/wordpress/questions/185926/woocommerce-registration-custom-redirect When I change 'myaccount' to another permalink it just freezes when you click register.. not sure why. wp_safe_redirect( apply_filters( 'woocommerce_registration_redirect', wp_get_referer() ? wp_get_referer() :...

Wordpress woocommerce - hide flat rate when free shipping


wordpress,woocommerce,shopping-cart
I have one wordpress/woocommerce site. When user cart amount is over 500 i must have free shipping in cart subtotal. Right now i have setup flat rate 25 and free shipping if amount is more then 500. I google it from help and add some code into functions.php but still...

Wordpress - customized pages with blocks - prohibit google seo index of blocks


wordpress,seo,woocommerce,robots.txt,google-sitemap
I'm using Wordpress and WooCommerce for my online shop. With the theme I'm using you can customize the product-category pages by adding "blocks". So if I want to have a text on the top of a product category page I simply create a block page, lets say its called "category-info"....

Woocommece login URL


wordpress,woocommerce
I have a custom page for login in Wordpress with Woocommerce integrated, and need that when a user click on my-account page, instead of using the login form from woocommerce, redirect to my custom login url. my-account page only must be seen in case the user is logged in,else, I...

woocommerce conditional products/categories on user role


wordpress,wordpress-plugin,woocommerce
Looking for a plugin that helps me to restrict woocommerce products or product categories based on role. Let's say that I only want to sell bulk products to whole sale buyers. Any help is awesome, thanks!...

Wordpress & Advanced Custom Fields - Retrieving categories


php,wordpress,woocommerce,advanced-custom-fields
I seem to be having problems retrieving posts/attachments after connecting them to Woocommerce categories while using advanced custom fields. I've tried using the advanced example as detailed here and this is as close as I can get using that example: $images = get_posts(array( 'numberposts' => -1, 'post_type' => 'attachment', 'meta_query'...

PHP date not taking into account AM/PM properly


php,wordpress,woocommerce
I have a booking system based on Woocommerce and the Woocommerce Bookings plugin. This means essentially I don't have control over the format of the data given to me. At the end of the checkout process I am given a start date and duration for the booking, and I need...

“Validation error: PayPal currencies do not match” in WooCommerce


wordpress,validation,paypal,woocommerce,currency
Using WooCommerce and the standard PayPal gateway to accept payments. When testing in Sandbox mode, everything works great. When we test live with a real transaction, payment goes through no problem, but within WooCommerce there is a note as follows: "Validation error: PayPal currencies do not match (code USD). Order...

woocommerce - make order notes required


wordpress,woocommerce
is it posible to make woo 'order_comments' field required - and show message If the field is not filled I have tried the following code but I can not get it to work. add_action('woocommerce_checkout_process', 'my_custom_checkout_field_process'); function my_custom_checkout_field_process() { // Check if set, if its not set add an error. if...

Wordpress ordered by two custom fields meta_key's


php,wordpress,woocommerce
I have a Woocomerce query working with one meta_key ( 'countdown_date' or 'hour' ). It sorts the products by a custom 'meta_key' => 'countdown_date' or 'hour' and orders them using 'orderby' => 'meta_value_num'. I need to join two meta_key's together. ('hour' key only returns the first two ints of a...

How to store the_title() into a variable to reutrn the value, not just echo it


php,arrays,wordpress,variables,woocommerce
I have a loop, and need to pass one more argument through it. I need to get the current page's single post title, and then use that as the value. I tried going about it like this: $tagz = the_title(); $args = array( 'post_type' => 'product', 'posts_per_page' => 5, 'product_tag'...

Woocommerce product dimensions not showing on first product


php,html,wordpress,web,woocommerce
I am using Wordpress with Woocommerce and would like the shop and archive pages to show the product dimensions along with the price and title of the product. I added this code to my content-product.php woocommerce file: http://docs.woothemes.com/document/display-product-dimensions-on-archive-pages/ Which worked great! Except for the first product in the shop loop....

How can I set the Image of woocommerce category as the background of the category title? [duplicate]


php,html,wordpress,woocommerce
This question already has an answer here: How to display Woocommerce Category image? 3 answers I want to set the woocommerce category image as the title background. This is the title line in archive-product.php <h1 class="page-title"><?php woocommerce_page_title(); ?></h1> I wrote <h1 style="background: url(<?php if ( is_product_category() ){ global $wp_query;...

WooCommerce display product categories in product title


php,wordpress,woocommerce,taxonomy
I have a Wordpress (version 4.2.2) eCommerce site running WooCommerce (version 2.3.8). On my individual product page I wish to set the title of the product to also include the custom categories I have created in WooCommerce and that this product belongs to. I find the following file (wp-content/themes/mytheme/woocommerce/single-product/title.php) that...

WooCommerce orders page add customer role custom column


php,wordpress,woocommerce
I want to add column to show the customer role on the WooCommerce orders, I search and everything I found is for one user. I also found this code on this link (WooCommerce show custom column) but I do not understand where I put what I need. I also found...

How to control HTML output of variable $image in WooCommerce


wordpress,woocommerce,thumbnails
I'm using WooCommerce and on my single product page I have an overview of the product images. I call the images with the product-thumbnails.php template, but the result conflicts with my CSS because the output of $image adds the pixel size in the HTML. now: <img src="http://example.com/image.jpg" height="480" width="360"> desired:...

Wordpress End If Statements


php,wordpress,woocommerce
Apologies, PHP is not my strongest area so this might seem super easy to others. I am trying to implement a statement to say, when there is something in my WooCommerce Cart to show the cart. If there's nothing in the cart then show nothing. The code I have so...

Displaying all woocommerce product liks with title in Footer for SEO - Wordpress PHP


php,wordpress,woocommerce,e-commerce
I am wanting to display all woocommerce products with links with the woocommerce title on the links top help my SEO. I have managed to find some code below which gets the product categories but cant seem to get the code to display all products with the title on the...

WooCommerce REST API v2: How to process payment?


rest,woocommerce,payment-gateway
Using the WooCommerce REST API v2, I'm successfully creating an order in a pending, unpaid state. I can see that I can set the order.payment_details.paid field to true which will create the order in a completed state and send out a completed order email, but it doesn't actually process the...

How to read data sent by webhooks?


php,wordpress,woocommerce
I have the latest woocommerce plugin, and I have to set a webhook to one of my url. But I am not able to read it in my $_REQUEST and nor in $input = file_get_contents("php://input"); Can someone please help. Thanks....

WooCommerce: How to display Category Name in single-product.php


php,wordpress,woocommerce
How can I display the category name in single-product.php? In archive-product.php the code is: <?php woocommerce_page_title(); ?> but what could I use to show the category name in the single-product.php that belong to the category?...

How to set woocommerce checkout form values to empty


wordpress,wordpress-plugin,woocommerce
I am using Woocommerce plugin for a WordPress site. But when as user I checkout I can see form populated with last user's details. How to set form entries to blank in Woocommerce. Please help. Fields are pre-populated with last user's detail. Is there a way to avoid this?