I need to get all variation id and update price in loop. Simple query and loop looks like: I think not working this: or this: Answer First in your code ‘ or ’ should be replaced by ‘. Also if used $post-ID should be replaced by $post->ID Depending on where and how you are using this code, you should try
Tag: product
Custom conditional redirections after WooCommerce checkout payment
I use Lirox One theme on Wordpress with WooCommerce. I want make custom redirections after payment: If a customer buy product ID 333, It will be redirected to product 444 (for example). I have make some custom code but it doesn’t works, I get an error 500 (and debug is empty). What I am doing wrong and how can I
Get WooCommerce featured products with a custom shortcode
I tried to get array of featured products to use theme in my own plugin with jquery slider I have made this function and get attrs from class-wc-shortcodes.php but no results what I must add or change to get it works I use it now as shortcode in welcome page just for testing Answer There was some errors in your
how to get particular product quantity from the cart page in the woocommerce
With this code: foreach ( WC()->cart->get_cart() as $cart_item ) { $quantity = $cart_item[‘quantity’]; echo $quantity; } I can get the quantity of all the products added in cart but I …
WooCommerce Show Product Total Sales after Custom a Date in Frontend
I want to show product total sales after custom date: I have this code, but I would like to custom it for showing only the total sales after a custom date for example 05/26/2016 Answer total_sales holds the total sales count of all time, So you need to write custom query to get sold count between specific date. Code goes
Get all Orders IDs from a product ID in Woocommerce
How can I get an array with Order IDs by Product ID? I mean receive all orders where specific product is presented. I know how to do this by MySQL, but is there a way to do this by WP_Query function? Answer Updates: 2017 – SQL query changed to “SELECT DISTINCT” instead of “SELECT” to avoid duplicated Order IDs in
WooCommerce Check stock of product ID before adding
I have some custom code in my WooCommerce site that adds a product to the users cart. I already have it check the cart contents to make sure there is another product in the cart first, but I also …
Check if user have permission or not to download any file in WooCommerce
I want to check whether any user have permission or not to download any file. I have product id and user id so How I can check? I have explored a lot on google and in woocommerce documentation but didn’t find any solution. Any help? Thanks in advance. Answer 2020 – Code update for WooCommerce 3+ Here is the process
Adding a promotional product when a certain cart amount is reached
I am looking for the right hook in WooCommerce because I need to add a promotional product to the cart when a certain cart amount of is reached, such as 100 conventional units. I have also used the …
Disable add to cart button for an array of products IDs in WooCommerce
In WooCommerce, I’m trying to disable add to cart button for an array of product IDs but I can’t find the problem. I am trying to use this function: And this is my check() function code (update): But this doesn’t work. What am I doing wrong? Thanks Answer Updated for WooCommerce 3+ Use in_array() instead like: Where not_purchasable_ids() is the