33,251
questions
145
votes
7
answers
454k
views
How to get WooCommerce order details
In WooCommerce from the following line code:
$order = new WC_Order( $order_id );
How can I get WooCommerce order details from the order id?
105
votes
9
answers
296k
views
Get custom product attributes in Woocommerce
In Woocommerce, I am trying to get product custom attribute values but I fail miserably and I don't get anything.
So I tried:
global $woocommerce, $post, $product;
$res = get_post_meta($product->...
81
votes
9
answers
231k
views
Get WooCommerce product categories from WordPress
I am trying to get the product categories from WooCommerce through a function in my WordPress theme
function get_me_list_of($atts, $content = null)
{
$args = array( 'post_type' =&...
80
votes
5
answers
195k
views
WooCommerce: Finding the products in database
I'm creating a website using WooCommerce and I want to restrict the available products to users depending on the postcode that they enter in the search form on my home page.
To be able to achieve ...
74
votes
7
answers
259k
views
Get cart item name, quantity all details woocommerce
I am trying to send the woocommerce cart items to third party shipping tool. I need the item name, quantity and individual price to be sent to the third party. How can this be achieved?
$items = $...
69
votes
4
answers
259k
views
Woocommerce get products
I used the following code to get the list of product categories form WooCommerce in my WordPress website:
<?php
$taxonomy = 'product_cat';
$orderby = 'name';
$show_count = 0; ...
64
votes
7
answers
295k
views
Woocommerce, get current product id
I'm currently working on a WooCommerce theme and attempting to add a sidebar to the product detail page.
I've been able to get the sidebar added (specifically, this one: https://web.archive.org/web/...
63
votes
3
answers
80k
views
WooCommerce - Remove downloads from menu in my account page
I would like to remove downloads menu from my account page.
How can I do this? Is it any hook to remove a specific item from the menu?
Thanks.
63
votes
6
answers
304k
views
WooCommerce - get category for product page
For my WC product pages, I need to add a class to the body tag so that I can perform some custom styling. Here's the function I'm creating for this...
function my_add_woo_cat_class($classes) {
$...
62
votes
15
answers
225k
views
How can I get customer details from an order in WooCommerce?
I have a function that does this:
$order = new WC_Order($order_id);
$customer = new WC_Customer($order_id);
How can I get customer details from this?
I have tried everything in the documentation, but ...
60
votes
9
answers
257k
views
How to get featured image of a product in woocommerce
Please tell me where I am going wrong . Product featured image is not showing up.
$args = array( 'post_type' => 'product', 'posts_per_page' => 80, 'product_cat' => 'profiler', 'orderby' =&...
60
votes
4
answers
167k
views
WooCommerce return product object by id
I am creating a custom theme for woocommerce and I need to be able to create a mini product display. I am having problems finding documentation on the woocommerce api. I have a comma delimited list of ...
58
votes
3
answers
207k
views
How to display Woocommerce product price by ID number on a custom page?
I'm trying to display a price of a product in Woocommerce, on a custom page.
There is a short code for that, but it gives product price and also adds an "Add to cart button", I don't want the button, ...
51
votes
3
answers
89k
views
WooCommerce payment complete hook
After a long search, I found this post:
WooCommerce hook for "after payment complete" actions
which talks about creating web hooks in WooCommerce to notify a script to do...something......
51
votes
8
answers
71k
views
WooCommerce products showing “Out of stock” message when not actually out of stock
Having an issue with a client website where products are randomly displaying
"This product is currently out of stock and unavailable."
The thing is that we don't have inventory tracking turned on,...
50
votes
8
answers
138k
views
woocommerce get_woocommerce_currency_symbol()
I am developing an extension for woocommerce WordPress plugin.
I would like to display the currency symbol outside of the loop in a custom function
I have the following:
function my_function( ) {
...
48
votes
3
answers
63k
views
WooCommerce hook for "after payment complete" actions
I'm using WooCommerce and Wordpress. I have a custom license key generator, and I'd like it to generate a license key when someone successfully purchases my plugin through WooCommerce.
It seems ...
45
votes
10
answers
91k
views
WooCommerce: Add product to cart with price override?
$replace_order = new WC_Cart();
$replace_order->empty_cart( true );
$replace_order->add_to_cart( "256", "1");
The above code add product 256 to the Cart 1 time. But the issue I'm having is that ...
44
votes
5
answers
40k
views
How to autocomplete paid orders in WooCommerce?
Normally, WooCommerce should autocomplete orders for virtual products. But it doesn't and this is a real problem, even a BUG like.
So at this point you can find some helpful things (but not really ...
41
votes
3
answers
73k
views
Apply a coupon programmatically in Woocommerce
In Woocommerce I'm trying to find a way to apply a 10% discount to an entire customer's order if the weight in the cart is over 100 lbs. I'm partway to achieving this. For the next step, I'm looking ...
40
votes
15
answers
65k
views
WooCommerce - woocommerce_rest_cannot_view - Status 401
I have generated a consumer key and consumer secret. The website has SSL installed. I have also installed plugins required for JSON and REST services. This is how the url looks like:
https://<url&...
39
votes
1
answer
2k
views
Having trouble working with SelectWoo instances of Select2 within WooCommerce
I am using Select2 within WooCommerce in some of my own custom areas and I am targeting it with some code to add and removes certain classes and it's working fine except for the SelectWoo instances ...
38
votes
13
answers
127k
views
How to disable the quantity field in the product detail page in woocommerce?
I need to hide the "quantity" field (where one enters the quantity before adding to cart) in Woocommerce on the product detail page, and only show the "add-to-cart"-button, which would then put the ...
38
votes
11
answers
156k
views
How to display Woocommerce Category image?
I use this code in PHP:
$idcat = 147;
$thumbnail_id = get_woocommerce_term_meta( $idcat, 'thumbnail_id', true );
$image = wp_get_attachment_url( $thumbnail_id );
echo '<img src="'.$image.'" alt="" ...
38
votes
4
answers
83k
views
Programmatically creating new order in Woocommerce
I am having the hardest time programmatically creating an order in WooCommerce. I am using the code below and is DOES create an order BUT I cannot get customer information OR product line items added ...
37
votes
5
answers
100k
views
Woocommerce - how to tell if product post has variations or not
I am trying to edit the short-description template to be different on variable (single) product pages than on simple products. the code in that page is here:
global $post;
if ( ! $post->...
37
votes
1
answer
115k
views
WooCommerce hooks and overriding templates
I have started to learn how to create templates with WooCommerce and I had faced with a little problem. For instance, in the php file content-single-product.php of Woocommerce plugin I have strings ...
37
votes
1
answer
72k
views
How to get Woocommerce Product Gallery image URLs? [closed]
I am developing a wordpress woo commerce shopping site and added some products. i want to get the product gallery image urls of each products.
how can I get the URLs of images?
36
votes
3
answers
89k
views
Getting order data after successful checkout hook
In WooCommerce, I would like to send a request to an API once the customer has successfully checked out. Its basically a website where the client is selling online courses (Like udemy).
When the ...
35
votes
6
answers
89k
views
where is a woocommerce order placed in wordpress database
Where do order and everything in it is stored in the database after it is placed from a WordPress woo-commerce website? To be more precise, how can I get my shipping address without using woocommerce ...
34
votes
3
answers
143k
views
Woocommerce - Getting the order item price and quantity.
Using Woocommerce 2.6.8 , I can't get the Order Item Data information as described in the docs and here on SO.
All I want is to get the Line Item price and Quantity, which should be as simple as:
$...
34
votes
9
answers
117k
views
Woocommerce add to cart button redirect to checkout
I created an ecommerce using the plugin woocommerce. I am selling only a subscription so the "/cart/" page is useless. I'm trying to get rid of it so that when my customer click on "Add to cart" ...
34
votes
4
answers
109k
views
Add extra meta for orders in Woocommerce
I'm creating a custom plugin for my website.
In some part of this plugin I need to store extra meta in wp_postmeta for each orders.
I added this in my plugin's class:
add_action ('...
34
votes
2
answers
42k
views
WooCommerce - where can I edit HTML generated by hooks?
I'm new to WooCommerce. Anyhow, I want to create my own theme, so I followed the guidelines and copied accross the core template files to /mywordpresstheme/woocommerce/.
That all works great and I'm ...
33
votes
13
answers
148k
views
Get woocommerce carts total amount
I am trying to apply a discount to a carts total price, but I can only do it to the item base price and not the over all price. I Googled and came across this post in the
wordpress stackoverflow:
$...
33
votes
13
answers
101k
views
Create programmatically a WooCommerce product variation with new attribute values
I have created a variable product ("parent" product) in WooCommerce version 3+. From a WordPress plugin, I would like to programmatically create the product variations ("children" ...
33
votes
3
answers
39k
views
Override WooCommerce Frontend Javascript
Can someone guide me as to what is the proper method of overriding WooCommerce core Javascript files, specifically frontend files. I have not found any documentation on this and looking at the code, ...
32
votes
5
answers
59k
views
WooCommerce: trigger event after change of variation
We use Woocommerce to sell colorboxes.
Mostly the variable-product option is chosen.
We added a modal dialog with a color palette, where the customer can chose a color from.
This is next to the common ...
32
votes
5
answers
96k
views
woocommerce variations
I am creating a woocommerce theme and I have product variations i.e. size which is displayed on product details page but problem is that I want to get all variations in my custom php page by using ...
32
votes
3
answers
67k
views
How to check payment method on a WooCommerce order by id?
I want to make some changes if the chosen payment method is COD. On existing WC_Order i have used
($order->payment_method_title == 'Cash On Delivery' ? ... : ... );
to retrieve the title.
But i ...
32
votes
5
answers
68k
views
Override Plugin Function in WordPress
I have a Plugin installed on my WordPress site.
I'd like to override a function within the Plugin. Do I override this in my theme's functions.php and if so, how do I do this?
Here's the original ...
31
votes
4
answers
90k
views
Check if string contains any letter (Javascript/jquery)
How can i check if a string contains any letter in javascript?
Im currently using this to check if string contains any numbers:
jQuery(function($){
$('body').on('blur change', '#...
30
votes
6
answers
174k
views
How can I get the order ID in WooCommerce?
How do I retrieve the order ID in WooCommerce?
30
votes
2
answers
84k
views
Get Order items and WC_Order_Item_Product in WooCommerce 3
Reading up the changes in WooCommerce 3.0, it seems that is not possible to anymore properties from order items directly, so I would assume that the following code needs to be changed, since it is ...
30
votes
6
answers
131k
views
How to modify WooCommerce cart, checkout pages (main theme portion)
I have been researching and tweaking away at my custom Wordpress theme and overridden WooCommerce templates with now WooCommerce installed to rectify a bunch of small formatting issues that occur on ...
30
votes
8
answers
89k
views
How to clear a Woocommerce cart
I am wondering how you can clear the contents of your cart on page load using woocommerce.
I came accross how to add a clear cart button using by adding this in to functions.php
add_action( 'init', '...
29
votes
11
answers
46k
views
Show Out of stock products at the end in Woocommerce [closed]
Is it possible to show out of stock products at the end of a category or page in wordpress?
So the customer first see the products that are available and after that the products that are out of ...
29
votes
1
answer
72k
views
Woocommerce - Get SKU in product single page
I want go get the SKU in my product single pages in Woocommerce. I tried <?php get_sku(); ?> which is a featured function according to the Woocommerce docs (http://docs.woothemes.com/wc-apidocs/...
28
votes
3
answers
166k
views
Get the product name in Woocommerce
I want to be able to display a product title by using PHP to echo the product name by the product ID (this is to be displayed within a Page, not the product page itself). I am using Wordpress and I ...
28
votes
4
answers
103k
views
Woocommerce location of checkout template
I'm trying to edit the checkout page, but can't find the template. What's the location inside plugin, of the file that has checkout fields?