Moving Quantity after product description

Easiest way to make it done is by playing with hook priorities. On content-single-product.php is this comment: /** * Hook: woocommerce_single_product_summary. * * @hooked woocommerce_template_single_title – 5 * @hooked woocommerce_template_single_rating – 10 * @hooked woocommerce_template_single_price – 10 * @hooked woocommerce_template_single_excerpt – 20 * @hooked woocommerce_template_single_add_to_cart – 30 * @hooked woocommerce_template_single_meta – 40 * @hooked woocommerce_template_single_sharing … Read more

Getting all woocommerce products from REST API call in plugin

I was close to the answer here, but held back by being unfamiliar with how global WordPress can be, and how that can be used to extend plugins. All I needed to do was wrap the plugin logic in a check for the presence of Woocommerce: if ( in_array( ‘woocommerce/woocommerce.php’, apply_filters( ‘active_plugins’, get_option( ‘active_plugins’ ) … Read more

Check if any available product has specific attribute

Here is the code that solved the problem: $woo_args = array( ‘status’ => ‘publish’, ‘limit’ => 1, ‘stock_status’ => ‘instock’, ‘brand’ => 99 ); $products = wc_get_products($woo_args); if (count($products) == 0){ //No product with the custom attribute id=99 } add_filter(‘woocommerce_product_data_store_cpt_get_products_query’, ‘my_handle_custom_query_var’, 10, 2); function my_handle_custom_query_var($query, $query_vars) { if (!empty($query_vars[‘brand’])){ $query[‘tax_query’][] = array( ‘taxonomy’ => ‘pa_brand’, … Read more

WooCommerce REST API AJAX Auth – 401 response

First off, the WooCommerce REST API documentation is available here and you should check it out. Secondly, the examples below are using the /wc/v3/products/categories (“List all product categories“) endpoint. And here’s a proper way to authenticate your request using OAuth — it always works when authenticating over HTTPS and it is the only accepted option … Read more