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

enqueue hover function

You can add your JS to a file in your child theme /js/example.js, then enqueue it like this: //add_action( ‘wp_enqueue_scripts’, ‘wpdocs_theme_name_scripts’ ); function wpdocs_theme_name_scripts() { wp_enqueue_script( ‘script-name’, get_stylesheet_directory_uri() . ‘/js/example.js’, [], ‘1.0.0’, true ); } Alternatively, you can add the styles inline using this: add_action( ‘wp_enqueue_scripts’, ‘wpse_home_game’, 20 ); function wpse_home_game() { wp_register_script( ‘home-game’, false … Read more

How to change title attribute returned by comments_popup_link()?

If you look into the function comments_popup_link() you will see the following code at the end: $title = the_title_attribute( array(‘echo’ => 0 ) ); echo apply_filters( ‘comments_popup_link_attributes’, ” ); echo ‘ title=”‘ . esc_attr( sprintf( __(‘Comment on %s’), $title ) ) . ‘”>’; comments_number( $zero, $one, $more ); echo ‘</a>’; // last line Note the … Read more