Woocomnerce Limit Purchase value before proceed checkout

Put this code in your current theme function.php file. METHOD 1: add_action( ‘woocommerce_check_cart_items’, ‘spyr_set_weight_requirements’ ); function spyr_set_weight_requirements() { if( is_cart() || is_checkout() ) { global $woocommerce; $total = WC()->cart->total; if( $total < 15 ){ wc_add_notice( ‘<strong>MAXIMUM CART PRICE 15 FOR CHECKOUT</strong>’,’error’); } } } METHOD:2 function disable_checkout_button_no_shipping() { $total = WC()->cart->total; if( $total < 15 … Read more

Change Firstname & Lastname order in the order-processing e-mail templates

I figured out a workaround solution and it works, but not the most beautiful: // I made the original action passive // do_action( ‘woocommerce_email_customer_details’, $order, $sent_to_admin, $plain_text, $email ); // … create a new solution from scratch $text_align = is_rtl() ? ‘right’ : ‘left’; //to escape # from order id $order_id = trim(str_replace(‘#’, ”, $order->get_order_number())); … Read more

Sending Email upon registration

For account moderation (allow login only after email verification), there are lots of plugin, you can try Theme My Login, it has moderation option. For using your email address as sender, there are two ways, if you want to send VIA SMTP server you can use any SMTP plugin like Easy WP SMTP or any … Read more

Conditional action hook

Woocommerce adds the action hook at priority order 30. add_action(‘woocommerce_single_product_summary’,’woocommerce_template_single_add_to_cart’,30); So, You may have done remove_action(‘woocommerce_single_product_summary’,’woocommerce_template_single_add_to_cart’,30); to remove the action from the hook. To remove an action the priority must match the priority with with the function was originally added. Now you can do function add_cart_button(){ global $product; $id = $product->get_id(); if($id != 1345 ): … Read more

Change “Select Options” label in button to “Buy Now!” in store page

add_filter( ‘woocommerce_product_single_add_to_cart_text’, ‘wpse_woo_custom_cart_button_text’ ); add_filter( ‘woocommerce_product_add_to_cart_text’, ‘wpse_woo_custom_cart_button_text’ ); function wpse_woo_custom_cart_button_text() { global $product; $product_type = $product->get_type(); // To modify on a single product page if( $product_type == ‘variable-subscription’ || $product_type == ‘variable’ ){ if( is_single() ) return __( ‘Buy Now’, ‘my-textdomain’ ); else return __( ‘Choose options’, ‘my-textdomain’ ); } // To modify on the … Read more

Setting WooCommerce SKU programmatically [closed]

You should use save_post hook. Try the code below: function wpse_304031_save_post( $post_id, $post ) { // return if autosave if ( defined( ‘DOING_AUTOSAVE’ ) && DOING_AUTOSAVE ) { return; } $your_sku = ‘Custom SKU for ‘ . $post->post_title; if( $post->post_type == ‘product’ ) { if( empty( get_post_meta( $post_id, ‘_sku’, true ) ) ) { update_post_meta( … Read more