WooCommerce – send custom email on custom order status change

The hook you need is: woocommerce_order_status_changed add_action(“woocommerce_order_status_changed”, “my_awesome_publication_notification”); function my_awesome_publication_notification($order_id, $checkout=null) { global $woocommerce; $order = new WC_Order( $order_id ); if($order->status === ‘completed’ ) { // Create a mailer $mailer = $woocommerce->mailer(); $message_body = __( ‘Hello world!!!’ ); $message = $mailer->wrap_message( // Message head and message body. sprintf( __( ‘Order %s received’ ), $order->get_order_number() ), … Read more

How to add custom HTML to wp_nav_menu?

The way WordPress goes through the menu pages to display the items, is using a walker object. In this case the specific class for this object is called Walker_Nav_Menu. You can find it in wp-includes\nav-menu-template.php. The Walker_Nav_Menu is a pretty simple class. You are able to see, how the links and the menu structure are … Read more

WordPress session management

It’s a very bad idea to modify WP Core files for the ability to use sessions. The best way I’ve found is to call the session_start() from init action hook. function kana_init_session() { session_start(); } add_action(‘init’, ‘kana_init_session’, 1); You can place it in functions.php file of your theme. Detailed article can be found here: http://www.kanasolution.com/2011/01/session-variable-in-wordpress/

How to add class to link in wp_nav_menu?

Taking a hint from this answer which I found was the most concise about adding classes to the list items of the menus, I used nav_menu_link_attributes filter which does work well for adding classes. In your functions.php, add: function add_menu_link_class( $atts, $item, $args ) { if (property_exists($args, ‘link_class’)) { $atts[‘class’] = $args->link_class; } return $atts; … Read more

Woocommerce add to cart button redirect to checkout

In WooCommerce 3.6 or later you can use woocommerce_add_to_cart_redirect (props @roman) add_filter (‘woocommerce_add_to_cart_redirect’, function( $url, $adding_to_cart ) { return wc_get_checkout_url(); }, 10, 2 ); Original answer: you can use a filter in functions.php: add_filter (‘add_to_cart_redirect’, ‘redirect_to_checkout’); function redirect_to_checkout() { global $woocommerce; $checkout_url = $woocommerce->cart->get_checkout_url(); return $checkout_url; } it doesn’t seem to work with ajax, but … Read more

How to Load Ajax in WordPress

As per your request I have put this in an answer for you. As Hieu Nguyen suggested in his answer, you can use the ajaxurl javascript variable to reference the admin-ajax.php file. However this variable is not declared on the frontend. It is simple to declare this on the front end, by putting the following … Read more

Hook AJAX in WordPress

First of all you need to add hooks in proper way // For the users that are not logged in add_action( ‘wp_ajax_nopriv_addItemAJAX’, ‘addItemAJAX_callback’ ); // For the users that are logged in: add_action( ‘wp_ajax_addItemAJAX’, ‘addItemAJAX_callback’ ); // ajax handler function addItemAJAX_callback() { // code goes here // since $debugArray is an array, so die(json_encode($debugArray)); // … Read more