We’re rewarding the question askers & reputations are being recalculated! Read more.

Questions tagged [woocommerce]

OFF TOPIC. Questions *specific* for this e-commerce plugin have their own forum at https://wordpress.org/support/plugin/woocommerce.

Filter by
Sorted by
Tagged with
32
votes
2answers
88k views

Woocommerce - Add a product to cart programmatically via JS or PHP [closed]

I am using the Woocommerce plugin to facilitate a small e-commerce part of a site and need to add products to its cart via some call or function rather than using its own 'add-to-cart' buttons. By ...
29
votes
1answer
74k views

How to add product in woocommerce with php code [closed]

I want to add products with PHP code like below: $post_information = array( 'post_title' => 'new item shop', 'post_content' => 'this is new item shop', 'post_type' => 'post', '...
23
votes
1answer
50k views

( Woocommerce) How to get the user belonging to an order? [closed]

I am making a function which needs to be called after an order is completed within WooCommerce. For this I'm using the *'woocommerce_order_status_completed'* hook. I want to check if the order has a ...
20
votes
4answers
46k views

How do I delete all UNUSED images from my uploads directory?

I am trying to clean out my uploads folders as they are now starting to take up too much room on my server. I have tried to use plugins to achieve this end such as DNUI and Cleanup Images but these ...
19
votes
8answers
60k views

Display featured products through custom loop in woocommerce on template page

I would like to display 6 featured products from my woocommerce store on my home-page.php template. After some researched I found that the right way to do this was through a custom loop,( I do not ...
17
votes
3answers
48k views

Hide prices and checkout functionality in woocommerce

I know this question might be too broad, but I'm looking for a bit of direction. My client has a woocommerce store with 30-40 products. For whatever reason they do not want to sell online anymore, ...
16
votes
1answer
56k views

WooCommerce: change display order of product short description and price [closed]

re: https://modestmix.com/shop/benefit-teas/go-the-fuck-to-sleep/ I'd like to move the price "$4.99–$24.99" below the product short description "Seriously. Drink a cup of this..." Any ideas how to ...
15
votes
2answers
28k views

Woocommerce Add Variation Product to Cart from custom link [closed]

I am trying to add a variation product to my cart directly through a link. I am setting the variation_id with the query string. As far as I can tell I am sending the data the exact same way as the ...
14
votes
4answers
83k views

Get the product list of a given Category ID

I couldn't find the right way to get the list of all products for a given category ID (not category name). The code I am using to get the categories list is the following, it works fine: $args = ...
13
votes
3answers
163k views

How to Display Product specific to a category with WooCommerce Plugin? [closed]

I'm using plugin Woocommerce to do shop online. I have many categories for example shoes, clothes and so on. How can I display the products of specific category? I see such product loops of on the ...
13
votes
1answer
71k views

Display All Products by Category with WooCommerce

With WooCommerce, I want to display all the categories in a store as headings, with all of their products listed below in an unordered list. Is this possible to do? I've seen a few things that'll let ...
13
votes
2answers
73k views

WooCommerce: How to edit the get_price_html

I am trying to edit the price value for a single product. In single-product/price.php there is a template call to $product->get_price_html. How can I edit that function/method to change the way ...
12
votes
2answers
29k views

Make WooCommerce pages accessible for logged in users only

I have a website using WordPress, and an e-commerce using WooCommerce. I would like my shop (and all its pages) to be seen by logged in users only. Via the User Access Manager plugin, I have denied ...
12
votes
1answer
26k views

Product categories don't appear as option to build menu

I am trying to add my product categories as top level categories in the navigation bar on my site. Under the "categories" option in appearance > menus, the only thing that appears under categories ...
11
votes
3answers
41k views

How do I get WooCommerce to automatically recreate pages? [closed]

I had to uninstall WooCommerce plugin (I deleted the tables it created as well) and now I reinstalled the plugin and I doesn't automatically recreate the WooCommerce Pages. Am I stuck having to ...
11
votes
2answers
55k views

How to display custom field in woocommerce orders in admin panel?

currently i add a custom billing field in woocommerce by function custom_override_checkout_fields( $fields ) { $fields['billing']['billing_phone_new'] = array( 'label' => __('...
10
votes
2answers
15k views

How to trigger WooCommerce order complete email?

I want to be able to trigger the WooCommerce order complete email at a different stage in the WooCommerce checkout process. So I've disabled WooCommerce order complete email from the backend and am ...
9
votes
4answers
66k views

How to correctly add Javascript in functions.php

I would like to remove some ugly looking arrows that are standard on cart buttons in WooCommerce. To achieve this, I found a tip of adding the following code, which should remove the arrows when the ...
8
votes
4answers
14k views

How to check if a plugin (WooCommerce) is active?

I am trying to modify the head and foot of my WooCommerce pages. I have an if statement that is supposed to target the shop and cart of WooCommerce, but it isn't. If I modify the PHP after the if ...
8
votes
1answer
42k views

How do you access the Product Short Description in a WooCommerce email template? [closed]

I would like to output the Product Short Description beneath the product name inside the order items table inside WooCommerce emails. I think I know where to place code inside the email template file, ...
8
votes
2answers
31k views

Woocommerce hook after creating order? [closed]

I am looking for a hook which will be triggered after someone submit checkout form and order placed ( no matter he made the payment or not ) . I tried woocommerce_new_order But it's not working.
7
votes
4answers
36k views

get woocommerce My account page link

I am trying to send an email to customer after purchased products and when customer click on the the link provided the email for rating the product it should redirect to customer's account/My account ...
7
votes
2answers
12k views

How to create a custom order status in woocommerce!

I've tried the below code to create custom status. add_action( 'init', function() { $term = get_term_by( 'name', 'shipped', 'shop_order_status' ); if ( ! $term ) { wp_insert_term( '...
7
votes
2answers
3k views

What is the different between an attachment in wp_posts and an attachment in wp_postmeta?

After the Woocommerce dummy products are imported, I notice that in the database, there are different records in different tables but point to THE SAME photo attachment. The question is why? What are ...
7
votes
1answer
37k views

Get woocommerce product price by id [closed]

i make one shortcode for get product title, image and price. i am getting all title, link and image properly but not getting price. but problem is add_shortcode('product_data','...
7
votes
1answer
27k views

Retrieve Product category 'NAME' by product category ID - WooCommerce?

Can I retrieve woocommerce product category name by ID? Not thumbnail, not the URL, not the Sub-categories, just raw Category name.
7
votes
1answer
39k views

How to get Woocommerce order product info

I am trying to get all woocommerce orders and find info about the products in each order. I have seen many examples on here and elsewhere on the web and they all seem to say to do the same thing but ...
7
votes
1answer
11k views

How to add a new endpoint in woocommerce

Im using woocommerce for a website and where the client sells software. One of the options I have to add is request a license button on my account page. I already have the function that does this in ...
7
votes
1answer
941 views

Wordpress Multisite: Adding actions to only one site

I have Wordpress Multisite installed with WooCommerce network activated. I want to add an action to a hook in ONE of the sites that has WooCommerce installed, instead of all of them. For example, I ...
7
votes
1answer
23k views

WooCommerce - How to Add a Custom Field to Cart Items and Cart Totals [closed]

I am using WooCommerce plugin and have the following query: Within the single product page, I have a product where based on certain selections by the buyer, a shipping cost value is calculated, which ...
6
votes
2answers
54k views

How to get current product category ID in product archive page

If I am on a product archive page then how can I get current product category ID in product archive page. I am using this but no result: global $wp_query; $category_name = $wp_query->query_vars['...
6
votes
1answer
17k views

WooCommerce Variable Product Price not showing on single product page

I made custom attribute for variation other than size or colour, but when i apply as variation to this attribute its not showing on single page.
6
votes
3answers
4k views

How to remove action hook done in a plugin from functions.php in my theme?

Somewhere in the plugin class there is this hook : add_action( 'woocommerce_some_hook', array( $this, 'some_function') ); it adds something I don't want there. In my functions.php in my theme, I ...
6
votes
1answer
27k views

Check IF is a “single product page” and Check the “role” for a Redirect

After much research on the net, I have not found a solution that works. Do you know how can I do that on woocommerce : I try that for the moment : function cm_redirect_users_by_role() { $...
6
votes
1answer
60k views

Woocommerce registration page [closed]

So...I just found out that the shortcodes for the login and registration pages are now removed from Woocommerce.... I know the forms are inside "My account" page, but I need a link in the menu to ...
6
votes
1answer
12k views

Can I use Woocommerce to take orders but not handle payment? [closed]

I would like to create an ecommerce website. In this website the customer will browse the product catalog, add the desired products to his cart, maybe create an account, and during the checkout phase,...
6
votes
2answers
3k views

Creating Multiple wp_localize_script for Shortcode?

I have a shortcode that displays recent WooCommerce products in a carousel, however i would like the end user to be able to use the shortcode multiple times on the same page, currently when this ...
6
votes
0answers
4k views

WP/WooCommerce REST API cart/checkout/order [closed]

Since the WordPress Rest API is getting merged into core and WooCommerce extended their API as well I stared to wonder how it would be possible to build an entire eCommerce website with it. When you ...
5
votes
3answers
23k views

How to check if woocommerce is activated in theme

I'm creating a theme with woocommerce which has the following: <ul> <li> <?php if ( is_user_logged_in() ) { ?> <a href="<?php echo ...
5
votes
4answers
6k views

Order by rating not works in wp_query

I need to sort my products by rating in a wp_query loop: this is my code: switch($ordering){ case 'default': $meta_key = ''; $order = 'asc'; $orderby = 'menu_order title';...
5
votes
3answers
67k views

How to get WooCommerce Product Category Link by ID?

WooCommerce's product categories are a custom taxonomy called product_cat. In a function I'm writing, I'm using get_categories with the taxonomy parameter set to product_cat. Everything works fine and ...
5
votes
1answer
6k views

Woocommerce add extra field to variation product

I'm following this tutorial on how to add an extra field to my variation products. I just need to add an extra text field. The admin part works fine - the field is showing and saving/updating, ...
5
votes
2answers
26k views

Display single product attribute value on Shop page (Woocommerce)

I am trying to display a single attribute ('size') value on shop page. I used the following code to show all values, tried to adapt to to show a single attribute, but with no success... Can you ...
5
votes
3answers
7k views

Edit tag cloud widget number

By default, the WordPress tag cloud widget has a set amount of 45 tags to display. This can be seen in the wp-includes/category-template.php file. By default, the WooCommerce plugin which I have ...
5
votes
2answers
30k views

How to show product SKU on product page

I'm making a website and it seems that product sku is hidden from product page. I have found how to add it to the catalog (shop) page but I need it to show inside the product page. So far, by ...
5
votes
2answers
16k views

WooCommerce return 404 on category pages

I am trying to set up WooCommerce permalinks to get something like: example.com/shop/ => Shop page listing products example.com/shop/category-name/ => Category page listing products from a category ...
5
votes
3answers
23k views

Display Category Thumbnail and links in Woo commerce

I would like to display my categories with a thumbnail in woocommerce. I am able to list the child terms as a link but i would like to add additional content. I have added the code below in which I ...
5
votes
2answers
8k views

Woocommerce show cross sells on singe product page [closed]

I am trying to show cross sells on a single product page rather than in the cart: So far I've tried the following code: <?php do_action( 'woocommerce_after_single_product_summary_data_tabs' ); ?&...
5
votes
1answer
1k views

How to add date range in woocommerce with code

I am using Woocommerce and Woocommerce bookings plugins and I would like to add Date Range with time throught a custom code. I want to add : Date from => to Time from => to Bookable : Yes I know ...
5
votes
1answer
8k views

How to change or add Woocommerce thank you page URL key content?

I have searched enough and I did not find an answer for this question but this may be a simple one. In analytics, I want to set up goals for purchase and we have only 5 products, so each product ...