Category: Woocommerce Hooks

  • Woocommerce + Dokan + Baselinker Connectivity Working Demo

    Woocommerce + Dokan + Baselinker Connectivity Working Demo

    Hello guys how are you? Welcome back to my blog. Today in this blog post, I am going to show you, Woocommerce + Dokan + Baselinker Connectivity Working Demo.

    Guys like you know very well that WordPress + Woocommerce = Millions of ecommerce websites.

    WordPress + Woocommerce + Dokan = Millions of ecommerce with multivendor websites

    WordPress + Woocommerce + Dokan + Baselinker = BaseLinker Connect integration enables data exchange between any number of BaseLinker users. It allows you to transfer orders and shipments.

    Now guys here are the few steps of connectivity:

    1. Guys very first we need to generate the REST API: Woocommerce -> Settings -> Advanced -> REST API:

     

    Creating rest api in woocommerce
    Creating rest api in woocommerce

    2. Now guys go to https://baselinker.com/ create account then follow below steps:

    baselinker app connectivity
    Baselinker application connection with woocommerce

    3. Now guys click on Add Integration button then you will see below screen:

    Baselinkner woocommerce connectivity
    Baselinkner woocommerce connectivity

    4. Now guys click on Woocommerce tab then you will see below screen:

    Baselinker Woocommerce connection 2
    Baselinker Woocommerce connection 2
    Baselinker woocommerce connection
    Add Keys here from woocommerce, see part 1 screenshot 3

    5. Now guys after adding the details in above form then click on save button and you will see below screenshot:

    Intergration
    Integration API’s
    Products importing
    Products importing
    Products importing part 2
    Products importing part 2

    Now guys after select the store name and little other things do the import and after refresh you will see woocommerce products into this baselinker application.

    Guys if you will have any kind of query then feel free to comment below.

    Jassa

    Thanks

  • Woocommerce Ajax Update Mini Cart

    Woocommerce Ajax Update Mini Cart

    Hello guys welcome back to my blog. Today in this blog post, I am going to tell you, Woocommerce Ajax Update Mini Cart.

    Guys here are the working demos videos:

    Live Demo

    Guys here is the post for Woocommerce Remove Product from Mini Cart with Ajax:

    Live Demo

    Now we are done friends. If you have any kind of query or suggestion or any requirement then feel free to comment below. There are lots of WordPress hooks and filters and I will share into my future posts and we should use them rather then do custom code in theme core files or in plugins files.

    Jassa

    Thanks

  • WooCommerce – Add custom button next to pay button on checkout page and set new order status on-hold

    WooCommerce – Add custom button next to pay button on checkout page and set new order status on-hold

    Hello guys how are you? Welcome back to my channel. Today in this post I am going to show you WooCommerce – Add custom button next to pay button on checkout page and set new order status on-hold.

    Guys I have used both latest versions WordPress 6.3 and WooCommerce 8.1.

    Live Demo

    Guys if you are new in WordPress or in WooCommerce then please check the below links for some good tutorials:

    1. WooCommerce Hooks
    2. WordPress Tricks
    3. WordPress Hooks
    WooCommerce - Add custom button next to pay button on checkout page and set new order status on-hold
    WooCommerce – Add custom button next to pay button on checkout page and set new order status on-hold
    woocommerce order page
    woocommerce order page

    Guys here is the working code snippet and please use it carefully:

    1. Guys here is the code snippet for set order status when user will click on on hold(custom button) and you need to add your theme’s functions.php file:

    add_action( 'init', 'register_on_hold_order_status' );
    
     function add_awaiting_hold_to_order_statuses( $order_statuses ) {
      $new_order_statuses = array();
      foreach ( $order_statuses as $key => $status ) {
        $new_order_statuses[ $key ] = $status;
        if ( 'wc-processing' === $key ) {
          $new_order_statuses['wc-on-hold'] = 'On Hold';
        }
      }
      return $new_order_statuses;
     }

    2. Guys here is the code snippet for update order status and you also need to add this code into your theme’s funcutons.php file:

    add_filter( 'wc_order_statuses', 'add_awaiting_hold_to_order_statuses' );
     function   therich_change_order_status( $order_id ) {  
      if ( ! $order_id ) {return;}            
      $order = wc_get_order( $order_id );
      if( 'processing'== $order->get_status() ) {
        $order->update_status( 'wc-on-hold' );
      }
    }
    add_action('woocommerce_thankyou','therich_change_order_status');

    This is it guys and if you will have any kind of query, suggestion or requirement then feel free to comment below.

    Jassa

    Developer’s King

    Thanks

  • Dokan Multi Vendor Add Multiple Commission Types Example

    Dokan Multi Vendor Add Multiple Commission Types Example

    Hello guys how are you? Welcome back to my channel. Today in this post I am going to show you Dokan Multi Vendor Add Multiple Commission Types Example.

    Guys I have used both latest versions WordPress 6.3 and WooCommerce 8.1.

    Live Demo

    Guys if you are new in WordPress or in WooCommerce then please check the below links for some good tutorials:

    1. WooCommerce Hooks
    2. WordPress Tricks
    3. WordPress Hooks
    Dokan Multi Vendor Add Multiple Commission Types Example
    Dokan Multi Vendor Add Multiple Commission Types Example

    Guys here is the working code snippet and please use it carefully:

    1. Guys here is the code snippet checks for various tabs in woocomerce product page in admin panel and you need to add your theme’s functions.php file:

    add_action('woocommerce_product_options_advanced ', function() {
      woocommerce_wp_text_input([
            	'id' => '_admin_commission_2',
              'label' => __('Admin Commission 2', 'txtdomain'),
      ]);
    });

    2. Guys here are more hooks:

    • woocommerce_product_options_general_product_data (“General”)
    • woocommerce_product_options_shipping (“Shipping”)
    • woocommerce_product_options_related (“Linked Products”)
    • woocommerce_product_options_attributes (“Attributes”)
    • woocommerce_product_options_advanced (“Advanced”)
    • woocommerce_product_options_inventory_product_data (“Inventory”)

    This is it guys and if you will have any kind of query, suggestion or requirement then feel free to comment below.

    Jassa

    Developer’s King

    Thanks

  • WooCommerce Hook to Schedule the TIME of a Product Sale

    WooCommerce Hook to Schedule the TIME of a Product Sale

    Hello guys how are you? Welcome back to my channel. Today in this post I am going to show you WooCommerce Hook to Schedule the TIME of a Product Sale.

    Guys I have used both latest versions WordPress 6.3 and WooCommerce 8.1.

    Live Demo

    Guys if you are new in WordPress or in WooCommerce then please check the below links for some good tutorials:

    1. WooCommerce Hooks
    2. WordPress Tricks
    3. WordPress Hooks
    WooCommerce Hook to Schedule the TIME of a Product Sale
    WooCommerce Hook to Schedule the TIME of a Product Sale

    Guys here is the working code snippet and please use it carefully:

    1. Guys here is the code snippet and you need to add your theme’s functions.php file:

    add_action('wp_head','add_foo');
    function add_foo(){
      if (is_shop()){
               //add your time of sale
      }
    }

    This is it guys and if you will have any kind of query, suggestion or requirement then feel free to comment below.

    Jassa

    Developer’s King

    Thanks

  • How to Customize or Add Content to WooCommerce Order Emails?

    How to Customize or Add Content to WooCommerce Order Emails?

    Hello guys how are you? Welcome back to my channel. Today in this post I am going to show you How to Customize or Add Content to WooCommerce Order Emails?

    Guys I have used both latest versions WordPress 6.3 and WooCommerce 8.1.

    Live Demo

    Guys if you are new in WordPress or in WooCommerce then please check the below links for some good tutorials:

    1. WooCommerce Hooks
    2. WordPress Tricks
    3. WordPress Hooks
    How to Customize or Add Content to WooCommerce Order Emails?
    How to Customize or Add Content to WooCommerce Order Emails?

    Guys here is the working code snippet and please use it carefully:

    1. Guys here is the code snippet and you need to add your theme’s functions.php file:

    add_action( 'woocommerce_email_before_order_table', 'trich_add_content_specific_email', 20, 4 );
      
    function trich_add_content_specific_email( $order, $sent_to_admin, $plain_text, $email ) {
       if ( $email->id == 'customer_processing_order' ) {
          echo '<h2 class="email-upsell-title">Get 20% off</h2><p class="email-upsell-p">Thank you for making this purchase! Come back and use the code "<strong>Back4More</strong>" to receive a 20% discount on your next purchase! Click here to continue shopping.</p>';
       }
    }

    2. Using the same snippet above, you can call different types of emails by changing the email ID:

    if ( $email->id == 'cancelled_order' ) {}
    if ( $email->id == 'customer_completed_order' ) {}
    if ( $email->id == 'customer_invoice' ) {}
    if ( $email->id == 'customer_new_account' ) {}
    if ( $email->id == 'customer_note' ) {}
    if ( $email->id == 'customer_on_hold_order' ) {}
    if ( $email->id == 'customer_refunded_order' ) {}
    if ( $email->id == 'customer_reset_password' ) {}
    if ( $email->id == 'failed_order' ) {}
    if ( $email->id == 'new_order' ) {}

    3. Here is the hook for new customer account email:

    add_action( 'woocommerce_email_before_order_table', 'trich_add_content_specific_email', 20, 4 );
       
    function trich_add_content_specific_email( $order, $sent_to_admin, $plain_text, $email ) {
       if ( $email->id == 'customer_new_account' ) {
          echo 'Add your content.';
       }
    }

    This is it guys and if you will have any kind of query, suggestion or requirement then feel free to comment below.

    Jassa

    Developer’s King

    Thanks

  • How to Move coupon form before subtotal in WooCommerce checkout?

    How to Move coupon form before subtotal in WooCommerce checkout?

    Hello guys how are you? Welcome back to my channel. Today in this post I am going to show you How to Move coupon form before subtotal in WooCommerce checkout?

    Guys I have used both latest versions WordPress 6.3 and WooCommerce 8.1.

    Live Demo

    Guys if you are new in WordPress or in WooCommerce then please check the below links for some good tutorials:

    1. WooCommerce Hooks
    2. WordPress Tricks
    3. WordPress Hooks
    How to Move coupon form before subtotal in WooCommerce checkout?
    How to Move coupon form before subtotal in WooCommerce checkout?

    Guys here is the working code snippet and please use it carefully:

    1. Guys here is the code snippet and you need to add your theme’s functions.php file:

    remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 );
    add_action( 'woocommerce_review_order_after_cart_contents', 'woocommerce_checkout_coupon_form_custom' );
    function woocommerce_checkout_coupon_form_custom() {
        echo '<tr class="coupon-form"><td colspan="2">';
        
        wc_get_template(
            'checkout/form-coupon.php',
            array(
                'checkout' => WC()->checkout(),
            )
        );
        echo '</tr></td>';
    }
    • WooCommerce move coupon field checkout

    This is it guys and if you will have any kind of query, suggestion or requirement then feel free to comment below.

    Jassa

    Developer’s King

    Thanks

  • How to Change order of billing fields on checkout page Woocommerce?

    How to Change order of billing fields on checkout page Woocommerce?

    Hello guys how are you? Welcome back to my channel. Today in this post I am going to show you How to Change order of billing fields on checkout page Woocommerce?

    Guys I have used both latest versions WordPress 6.3 and WooCommerce 8.1.

    Live Demo

    Guys if you are new in WordPress or in WooCommerce then please check the below links for some good tutorials:

    1. WooCommerce Hooks
    2. WordPress Tricks
    3. WordPress Hooks
    How to Change order of billing fields on checkout page Woocommerce?
    How to Change order of billing fields on checkout page Woocommerce?

    Guys here is the working code snippet and please use it carefully:

    1. Guys here is the code snippet and you need to add your theme’s functions.php file:

    function custom_override_checkout_fields( $fields ) {
    
      // Do things with your fields like setting the
      // priority, label, required, etc.
      // or removing them
    
      // Example: Set the priorities straight
      // Probably not meant for this since priority is something
      // totally different than order.
      $fields['billing']['billing_first_name']['priority'] = 0;
      $fields['billing']['billing_last_name']['priority'] = 5;
      $fields['billing']['billing_email']['priority'] = 10;
      $fields['billing']['billing_phone']['priority'] = 15;
      $fields['billing']['billing_country']['priority'] = 20;
      $fields['billing']['billing_state']['priority'] = 25;
      $fields['billing']['billing_address_1']['priority'] = 30;
      $fields['billing']['billing_address_2']['priority'] = 35;
      $fields['billing']['billing_postcode']['priority'] = 40;
      $fields['billing']['billing_city']['priority'] = 45;
    
      // Sort the fields based on their 'priority'
      usort($fields['billing'], function($a, $b) {
        return $a['priority'] <=> $b['priority'];
      });
    
      // Send the fields to the function that receives the fields data
      return $fields;
    }
    • Reorder Woocommerce checkout fields
    • Change order of billing fields on checkout page woocommerce
    • Change order of billing fields on checkout page woo

    This is it guys and if you will have any kind of query, suggestion or requirement then feel free to comment below.

    Jassa

    Developer’s King

    Thanks

  • Avoid vendors to purchase their own product in WooCommerce

    Avoid vendors to purchase their own product in WooCommerce

    Hello guys how are you? Welcome back to my channel. Today in this post I am going to show you Avoid vendors to purchase their own product in WooCommerce.

    Guys I have used both latest versions WordPress 6.3 and WooCommerce 8.1.

    Live Demo

    Guys if you are new in WordPress or in WooCommerce then please check the below links for some good tutorials:

    1. WooCommerce Hooks
    2. WordPress Tricks
    3. WordPress Hooks
    Avoid vendors to purchase their own product in WooCommerce
    Avoid vendors to purchase their own product in WooCommerce

    Guys here is the working code snippet and please use it carefully:

    1. Guys here is the code snippet and you need to add your theme’s functions.php file:

    guys also I will make it with ajax and share that as well

    add_filter('woocommerce_is_purchasable', 'filter_woocommerce_is_purchasable', 10, 2 );
    function filter_woocommerce_is_purchasable( $purchasable, $product ) {
        $seller_id = get_post_field('post_author', $product->get_id());
    
        if( get_current_user_id() == $seller_id ) {
            $purchasable = false;
        }
    
        return $purchasable;
    }

    This is it guys and if you will have any kind of query, suggestion or requirement then feel free to comment below.

    Jassa

    Developer’s King

    Thanks

  • How to customize WooCommerce thank you page?

    How to customize WooCommerce thank you page?

    Hello guys how are you? Welcome back to my channel. Today in this post I am going to tell you How to customize WooCommerce thank you page?

    Guys I have used both latest versions WordPress 6.3 and WooCommerce 8.1.

    Live Demo

    Guys if you are new in WordPress or in WooCommerce then please check the below links for some good tutorials:

    1. WooCommerce Hooks
    2. WordPress Tricks
    3. WordPress Hooks
    How to customize WooCommerce thank you page?
    How to customize WooCommerce thank you page?

    Guys here is the working code snippet and please use it carefully:

    1. Guys here is the code snippet and you need to add your theme’s functions.php file:

    guys also I will make it with ajax and share that as well

    add_action( 'woocommerce_thankyou', 'wp_rich_woocommerce_thankyou_action', 10, 1 );
    
    /**
     * Function for `woocommerce_thankyou` action-hook.
     * 
     * @param  $order_id 
     *
     * @return void
     */
    function wp_rich_woocommerce_thankyou_action( $order_id ){
    
      // action...
            echo "Write your action here";
      
    
    }

    This is it guys and if you will have any kind of query, suggestion or requirement then feel free to comment below.

    Jassa

    Developer’s King

    Thanks