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

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

Replace woocommerce_add_order_item_meta hook in Woocommerce 3.4

Updated Since Woocommerce version 3, woocommerce_checkout_create_order_line_item action hook now replace outdated woocommerce_add_order_item_meta hook in a much better way using the new introduced CRUD getters and setters methods: // Save custom data to order item meta data add_action( ‘woocommerce_checkout_create_order_line_item’, ‘tshirt_order_meta_handler’, 20, 4 ); function tshirt_order_meta_handler( $item, $cart_item_key, $values, $order ) { $custom_designer = WC()->session->get( $cart_item_key.’_designer’ ); … Read more

Add a custom checkbox in WooCommerce checkout which value shows in admin edit order

You can do it in 3 steps: Adding the custom checkbox field below the Payment Methods Saving the custom checkbox field when it’s checked in the order meta Displaying the custom checkbox field when it’s checked on the order edit page Here is that code: // Add custom checkout field: woocommerce_review_order_before_submit add_action( ‘woocommerce_review_order_before_submit’, ‘my_custom_checkout_field’ ); … Read more

Add a quantity field to Ajax add to cart button on WooCommerce shop page

Updated on 2021 For WooCommerce versions from 3.2 to 5+, Optimized jQuery code and Removed a quantity bug. Added quantity reset after add to cart. The following custom function is hooked in woocommerce_loop_add_to_cart_link filter hook and adds a quantity input field to each product on WooCommerce archives pages and other product loops. We use here … Read more

Create programmatically a product using CRUD methods in Woocommerce 3

You are not accessing the WC_Product_simple instance object from your custom Dropship Data Scraper plugin. The guilty can be mostly 2 things: You have not installed Woocommerce. The plugin Dropship Data Scraper is outdated and needs changes, to handle woocommerce. Try to include the global Woocommerce object and to enable Woocommerce support in your plugin. … Read more