Is there a Woocommerce hook that fires when applying a coupon but before checking if it’s valid?

Its the woocommerce_get_shop_coupon_data filter, example code: add_filter ( ‘woocommerce_get_shop_coupon_data’, ‘mp_create_coupon’, 10, 2 ); function mp_create_coupon( $data, $code ) { // Check if the coupon has already been created in the database global $wpdb; $sql = $wpdb->prepare( “SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type=”shop_coupon” AND post_status=”publish” ORDER BY post_date DESC LIMIT 1;”, $code … Read more

Sort products without thumbnail in WooCommerce shop page

I would try to rename the custom function and add meta_query too! So it’d be like this: function my_shop_custom_products_query( $q ) { $q->set( ‘meta_key’, ‘_thumbnail_id’ ); $q->set(‘orderby’, ‘meta_value_num’); $q->set(‘order’, ‘DESC’); $q->set( ‘meta_query’, array( array( ‘key’ => ‘_thumbnail_id’, ‘compare’ => ‘>=’, ‘value’ => ‘0’ ))); } add_action( ‘woocommerce_product_query’, ‘my_shop_custom_products_query’ ); If for some reason it didn’t … Read more

How to handle a missing page.php?

The only required template in a WordPress theme is the index.php. And a comments.php if comments are supported. Following the template hierarchy, all other files, including page.php, will fall back to the index.php. When a theme doesn’t have a page.php, look at the index.php. There you will find the basic structure for its content. In … Read more

Get only one product category woocommerce

Before I begin, just one note, there is no property called $all in get_the_terms. Here are the available fields which you can use stdClass Object ( [term_id] => [name] => [slug] => [term_group] => [term_order] => [term_taxonomy_id] => [taxonomy] => Get only one product category woocommerce => [parent] => [count] => [object_id] => ) I’m … Read more