Display list of categories that contain products with a specific tag

There’s probably a few ways to do this. The key will be cutting down on the number of loops you need to make it more efficient. I think this will work: $query = new WP_Query( array( ‘post_type’ => ‘product’, ‘posts_per_page’ => ‘-1’, // unlimited posts ‘tax_query’ => array( array( ‘taxonomy’ => ‘product_tag’, ‘field’ => ‘slug’, … Read more

Add user data to table when user is created?

Looks to me you should be seeking a woocommerce purchase completion hook. This would be when you could add that a donation has been made and at what amount, then you could grab any user information, amounted donated and other info you need and save it to your donor table. use this: add_action(‘woocommerce_order_status_completed’, ‘save_to_donors’,10,1); instead … Read more

Problem with cURL and rest API

The curl_init function accepts an url and what you are passing there looks like a command line call. Please check this link for an example of passing username and password through php curl functionality. Basically you have to use just http://localhost/wp-json/wc/v1/products in curl_init and set username using curl_setopt function with CURLOPT_USERPWD parameter. Example: $ch = … Read more

how to use different page design for different category

For overriding default templates please check this. If you want different/custom category template for specific category then you may create a php file which has naming structure like taxonomy-product_cat-{slug}.php. For example, to create custom category template for clothing category, you will need to create taxonomy-product_cat-clothing.php where clothing is slug of the category. Place this file … Read more

Setting up Different Layouts for Each Product Category and Subcategory [closed]

Woocommerce follows WordPress’s native template hierarchy system. To create a template file to be used for a specific category, use this file naming scheme: taxonomy-{taxonomy}-{term}.php So, for Woocomerce categories, this will be: taxonomy-product_cat-{category_name}.php You can create one of those files for each category that you want to have a different appearance from the default category. … Read more

How plugins_loaded works?

Use your class definition in a separate file, say in /your-plugin-dir/classes/my-gateway.php like usual: <?php class my_gateway extends WC_Payment_Gateways { //code } ?> Then use this CODE to include the file on plugins_loaded action from your main plugin file: add_action(‘plugins_loaded’, ‘WC_test_gateway_plugin’); function WC_test_gateway_plugin() { require_once plugin_dir_path( __FILE__ ) . ‘classes/my-gateway.php’; // instantiate your class here or … Read more