Search results don’t show products
You have in your query WHERE p.post_type IN (‘post’, ‘page’), that is why it shows only the posts and pages. Add post type product to query: WHERE p.post_type IN (‘post’, ‘page’, ‘product’)
You have in your query WHERE p.post_type IN (‘post’, ‘page’), that is why it shows only the posts and pages. Add post type product to query: WHERE p.post_type IN (‘post’, ‘page’, ‘product’)
If ‘type’ => ‘select’ works for you then to solve state selection, you can try woocommerce_states and woocommerce_countries_allowed_country_states filter to list states only for the user’s country. Reference : https://wordpress.stackexchange.com/a/320548/163113
Please try to understand the code. What happened there. update_settings function update all the form settings value in the WordPress options table. So if you search in options table you will find that the settings value are stored in the options table in DB. So now its very easy to retrieve the value of options … Read more
I’m not sure which WooCommerce version you’re using, but in the latest version (3.3.5), WC_Product_Attribute doesn’t have a set_taxonomy() method. So I changed that to: $attribute_object->set_id( 1 ); // set the taxonomy ID Secondly, here you should pass an array of term IDs and not a string: (in this example, 123 is the ID of … Read more
add_filter(‘woocommerce_admin_reports’,’custom_tab’); function custom_tab($reports) { $reports[‘custom_tab’]= array( ‘title’=>__(‘Custom Reports’,’woocommerce’), ‘description’=> ‘WooCommerce Orders Listing Here…’, ‘hide_title’=> true, ‘callback’=>array(‘wc_admin_orders_customers’, ‘display_orders_list_cusotomers’) ); return $reports; }
You can add a filter via the theme’s functions.php file (I’d recommend you use a child-theme for customizations, but that’s outside the scope of this question) The following will limit the tag-cloud in the wp-admin backend to the first 5. function tryme($tag_data){ $short_tag_data = array_slice($tag_data, 0, 5, true); return $short_tag_data; } add_filter( ‘wp_generate_tag_cloud_data’, ‘tryme’ ); … Read more
Answering my own question. For plugin developers, the directive is to use current_user_can() in your code as usual in the REST endpoints, as Core does. WordPress 5.4 does not support authenticated requests originated from outside WordPress to the REST API yet. But your clients can use plugins such as Basic Auth, OAuth2 or JWT to … Read more
The code for changing the default image is provided by WooCommerce in this link but for your requirement we have to customize the code as follows /* * goes in theme functions.php or a custom plugin. Replace the image filename/path with your own 🙂 * **/ add_action(‘init’, ‘custom_fix_thumbnail’); function custom_fix_thumbnail() { add_filter(‘woocommerce_placeholder_img_src’, ‘custom_woocommerce_placeholder_img_src’); function custom_woocommerce_placeholder_img_src($src) … Read more
The default relation for a meta query is AND, so when you have two conditions they will be treated as such: $meta_query[] = array( ‘key’ => ‘_stock’, ‘value’ => ‘0.000000’, ‘compare’ => ‘NOT IN’ ); $meta_query[] = array( ‘key’ => ‘_backorders’, ‘value’ => ‘no’, ‘compare’ => ‘!=’ ); Get all products with a _stock meta … Read more
The answer when the question is about hooks is always either: timing, priority, or both. Consider the following code: add_action( ‘shutdown’, ‘wpse_258451_shutdown’ ); function wpse_258451_shutdown() { add_action( ‘init’, ‘wpse_258451_init’ ); } function wpse_258451_init() { wp_die( ‘I will never be called.’ ); } It should be obvious that the function wpse_258451_init() will never be called. This … Read more