Where to copy woocommerce files to in my custom theme to avoid editing the core plugin?

To override WooCommerce (WC) templates, put your modified templates in custom_theme/woocommerce/template-category/template-name.php Example: To override the admin order notification, copy: wp-content/plugins/woocommerce/templates/emails/admin-new-order.php to wp-content/themes/yourtheme/woocommerce/emails/admin-new-order.php WC Documentation Reference

WooCommerce Admin order – Only run action if user is loaded

One way of doing this is check with the get_current_user() and check if return something, if yes, run the code. Like the example below: add_action( ‘woocommerce_admin_order_data_after_order_details’, ‘ccef_order_switch_to’, 99 ); /** * Add a switch to user link on the order details. * * @param object $order The WC Order that we’re working with. */ function … Read more

Is there any way to pro-grammatically create product categories and assign thumbnails in PHP and WooCommerce?

wp_insert_term() works fine for this sort of thing. You haven’t given any context, but here’s a quick example I made that, on every page load, adds a random WooCommerce product category(not duplicates though), and an associated random image, from a list of image id’s in MY media library(change $existing_image_ids to your own ids for this … Read more

Woocommerce before and after shop loop not works

In core WooCommerce, the pagination is added via the woocommerce_pagination() function hooked to woocommerce_after_shop_loop, and the sorting and result counts are output by the woocommerce_result_count() and woocommerce_catalog_ordering() functions. If you look at the source for these functions, you can see that they display according to the main $wp_query, which will not contain any products because … Read more

Using the WordPress and WooCommerce REST APIs in the same Node app

I thought I’d share my solution for anyone working on a similar problem. I ended up switching to node-wpapi and using REST Autodiscovery to enable use of the WooCommerce & WordPress APIs from a single library. This can be done like so: const wpapi = require(‘wpapi’) let wp = new wpapi({ endpoint: ‘http://your.wp.site/wp-json/’, username: ‘user’, … Read more