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

Woocommerce - Only show grouped products parent in the loop


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?



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.


How to display grouped products in a list with quantity in 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...

fabricjs: how to show object size after scaling

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...

WooCommerce orders page add customer role custom column

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...

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

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?...

WooCommerce query quantity on product page

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...

Wordpress woocommerce - hide flat rate when free shipping

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...

How to remove the quantity field from cart page for specific product attribute 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...

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

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...

How To check Product Have Variation in woocommerce

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 "; } ?> ...

Wordpress ordered by two custom fields meta_key's

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...

Woocommerce Filter Product by Attribute

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...

WooCommerce - Checking for brand page

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 - Change the shop page layout but keep the archive-product.php

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...

Woocommerce hide payment gateway for user roles

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 )...

WooCommerce display product categories in product title

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...

How get variation's stock quantity woocommerce

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...

WooCommerce REST API v2: How to process payment?

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...

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

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"....

Select woocommerce chosen shipping method price

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 second single product page in 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 set woocommerce checkout form values to empty

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?

WooCommerce - Display categories and its products on front page

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...

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

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

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...

How to control HTML output of variable $image in WooCommerce

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:...

Show product's image in “Orders” page - 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...

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

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'...

how to set different minimum order amount for free shipping for different user roles in 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...

PHP date not taking into account AM/PM properly

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...

dont allow PO BOX shipping woocommerce not working

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(...

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

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 API returns 1, but works

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...

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

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...

Woocommerce Return False with message

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(...

trouble using AFOAuth2manager to generate HTTPSOauthToken

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...

Upgrade to Woocommerce 2.3.10 caused checkout to block

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....

woocommerce_add_order_item_meta hook sending only one argument; three expected

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 to read data sent by webhooks?

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 simple filter php

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 conditional products/categories on user role

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 End If Statements

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...

woocommerce redirect after registration

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() :...

Woocommerce product dimensions not showing on first product

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....

WordPress - Failing to override woocommerce templates

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....

Woocommece login URL

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...

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

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;...

Add custom functionality on WooCommerce complete button

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....

Wordpress & Advanced Custom Fields - Retrieving categories

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'...

WooCommerce seems to only orderby date and not price

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">...

Remove item with $product_id - 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...