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', '...
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 = ...
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.
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 ...
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 ...
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, ...
4
votes
2answers
10k views

WP_Query: Exclude hidden products from WooCommerce product list

I hope this is not too specific to WooCommerce. I have a nifty shortcode that displays a list of all my products with SKUs. However, it also includes products that I have published but have set the ...
2
votes
1answer
577 views

Fatal Error when installing woocommerce despite upgrading

I want to install woocommerce on my website and have selected a new theme to do so. I even upgraded from an old server to a new one running the latest version of php. However, I still get the same ...
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 ...
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 ...
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, ...
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 ...
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 ...
3
votes
4answers
28k views

Changing Woocommerce Product Description [closed]

I've been changing the way that the Single product page looks. I've moved a few things about by hooking into Woocommerce and also editing the css. Out of the box the single product page shows the ...
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 ...
4
votes
1answer
19k views

Woocommerce get category image full size

i'm trying to get the full size image of my category products. $prod_categories = get_terms( 'product_cat', array( 'orderby' => 'name', 'order' => 'ASC', '...
3
votes
1answer
17k views

Create product category and keyword search form in woocommerce? [closed]

i want to build category and keyword based search form. so i got this following form <form role="search" method="get" id="searchform_special" action="<?php echo esc_url( home_url( '/' ) ); ?&...
3
votes
1answer
24k views

How to modify navigation menu of the “My Account” page in WooCommerce

I want to modify the WooCommerce "My Account" left side navigation menu. For that, I have made changes in the woocommerce/templates/myaccount/navigation.php. The problems with this approach are: I ...
1
vote
2answers
3k views

Hide a menu-item and its submenus and display a 'Log in' link if the user is logged out

I need, somehow, to enable that when you logout, that 'My Account' item is getting hidden from the navbar, and instead it displays a 'Log in' link. The item 'My Account' also have submenus with the ...
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['...
3
votes
1answer
786 views

Reflect nested categories in appearance > menus

Anyone know why my categories stop being nested in the product categories widget within appearance > menus? They begin nested, but stop after Age 4 to 6. I have a set of woocommerce product ...
3
votes
3answers
13k views

how to use wc_create_order with subscription product

I want to create a new order programatically. This code works well with simple product, $product = get_product($product_id); $order = wc_create_order(); $order->add_product( $product ,...
3
votes
1answer
10k views

What is the code to get the download link for a product in WooCommerce?

I'm trying to add the direct download link of a product to a button, but I'm stuck. What I tried is this <a href="<?php echo $product->downloadable_files; ?>">Download</a> And ...
2
votes
3answers
7k views

Save Custom Fields for Variations Product

Currently I am using WooCommerce for WordPress and trying to add custom fields for Variations Product. After did some researches, I found some code and tried to modify it. This is my full code : ...
1
vote
1answer
7k views

Permalinks for WooCommerce Categories and Subcategories

Setup Desired permalink structure (only these structures exist for products) Product 1: /shop/category/subcategory/product1/ Product 2: /shop/category/product2/ Woocommerce Product View Settings ...
0
votes
1answer
266 views

How to maintain wordpress site blogs in production and staging?

I work as a website admin in my company. We are selling digital products using WooCommerce. We wanted to have staging and production in order to avoid any site down. So in staging we use to create ...
0
votes
1answer
1k views

Add Dropdown menu using “add_filter => wp_nav_menu_items”

My project: Wordpress, Woocommerce, Bootstrap 4, bs4navwalker My problem: Custom dropdown item added by WP filter. I have one navbar, 3 differents menus inside (using bs4navwalker), a badge for the ...
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 ...
4
votes
0answers
4k views

single-product.php template not working for single products [closed]

single-product.php template not working for my Woo commerce single products and instead it is using single.php file of my theme. I do not have woocommerce.php file in my theme but still single-product....
4
votes
1answer
20k views

get product attributes for current product and store it in a variable

Been trying to figure out how I can get the product attributes of the current product and store it in a variable and put it in a class. I've managed to get the product attributes, unfortunately it ...
2
votes
2answers
7k views

WooCommerce showing star rating review instead of text review string

On my WooCommerce site I am trying to output the star rating for a product that is reviewed. Instead, it outputs this: Rated 3.38 out of 5 based on 8 customer ratings What am I missing with the ...
1
vote
1answer
284 views

How to get rid of the hover zoom in WooCommerce single products

I'm trying to get rid of the function where users can hover over the main product image and zoom into the product. I tried using this code, which has been confirmed by others to work, but nothing ...
1
vote
3answers
12k views

Use get_term_children to get the sub category of a parent category for the current post

In my WooCommerce theme I've created a root category: 'Brands' then for each product I've added it's brand as a sub category to the 'Brands' parent category. On the product page I want to display the ...
1
vote
1answer
1k views

How to Acheive the custom woocommerce category template

currently My archive-product.php shows like this. https://khaleejdev.com/kds/newtornetto/product-category/multilingual-digital-marketing/ Inside this there are 15 products and 3 subcategories (each ...
1
vote
1answer
3k views

Show recent products first but “sold out last” in query

I am using WooCommerce and would would like to show the "out of stock" products last in the query on the archive page. How can I do that? Currently we are making the newest product show first with ...
1
vote
1answer
2k views

How does WooCommerce display a custom comment_type in Comment Admin?

There have been many threads and topics over the past few years about how to create a custom comment type. For the most part it's my understanding that it's possible (because WooCommerce does it) but ...
1
vote
1answer
347 views

How do I edit pre_get_post for the category the user is currently in?

I've got a Woocommerce site that uses categories and products within those categories but how do I get my search form to only display results of products within the category the user currently is in. ...
0
votes
1answer
155 views

Extend Woocommerce rest api routes fails

While I'm trying to extend Woocommerce Rest-API routes with a custom one I face the following problem. I have the following class which tries to hook inside Woocommerce API class API_LOADER { ...
0
votes
3answers
8k views

How to automatically apply woocommerce product title to all product images alt tags?

Adding alt tag information to every product photo is a lot of work. We always just copy and paste our product title into the image alt tags. I figured since all the information is there; there must ...
0
votes
1answer
928 views

Did I do it right? Deleting images after deleting product. Woocommerce

I create, update and delete products using Woocommerce RestAPI, specifically this method: $woocommerce->post('products/batch', $data); After this method connected images remain in the server and ...
0
votes
1answer
446 views

How to add Woocomrce cart page shipping calculator to my country state list

Im beginner for the word press , I don't know if the issue is because of the . The problem is that the "calculate shipping" option on my cart page doesn't allow users to select my country / state ...
-1
votes
1answer
3k views

WooCommerce - Customer Order History Pagination

I'm trying to implement pagination into WC's customer order history that can be seen on the "My Account" page using woo_pagination(). https://docs.woothemes.com/document/woo_pagination/ The template ...
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 ...
3
votes
0answers
22k views

How to get Woocommerce Variation ID? [closed]

I am trying to create some additional functionality on my Woocommerce backend where I add a custom field to the variations section of backend of Woocommerce. However I cannot for the life of me ...
3
votes
1answer
5k views

What's the difference between WC() and $woocommerce

I want to unset some WooCommerce session variables because on page load the hooks I'm using haven't fired which leaves previous session data populating the checkout shipping table. Within any ...
3
votes
1answer
15k views

how to override woocommerce specific loop or archive-product.php [closed]

so far while my woocommerce theme loop through all products in shop page i'm trying to customise and add few bootstrap classes to style it in a prober way since default styles generated causes layout ...
2
votes
2answers
108 views

Query multiple post type and categories

I have a div and inside I wish display by random a post from category-a or a product from category-b. I'm looking for a query to do that. I tried this: <?php $args = array( '...
2
votes
1answer
333 views

WooCommerce - Flat rate shipping based on X quantity steps?

We need to run WooCommerce flat rate shipping rate based on every X items in the cart, for example: 1-5 Items: Delivery = £5 6-10 Items: Delivery = £10 11-15 Items: Delivery = £15 and so on… It's ...