Change WooCommerce Button Text

User
change woocomerce button name
Assistant
To change the WooCommerce button name (e.g., "Add to Cart," "Place Order"), you can use the following methods depending on your requirement:

### **1. Change "Add to Cart" Text**
Add this to your theme’s `functions.php` file:

function custom_add_to_cart_text() {
    return __('Buy Now', 'woocommerce'); // Change "Buy Now" to your preferred text
}
add_filter('woocommerce_product_single_add_to_cart_text', 'custom_add_to_cart_text'); // Single product page
add_filter('woocommerce_product_add_to_cart_text', 'custom_add_to_cart_text'); // Shop page

### **2. Change "Place Order" Button Text**
If you want to change the "Place Order" button on the checkout page, use this:

function custom_order_button_text($button_text) {
    return __('Complete Purchase', 'woocommerce'); // Change text as needed
}
add_filter('woocommerce_order_button_text', 'custom_order_button_text');

### **3. Change Button Name for Specific Product**
If you want to change the button text for a specific product:

function custom_product_add_to_cart_text($text, $product) {
    if ($product->get_id() == 123) { // Replace 123 with your product ID
        return __('Buy Now', 'woocommerce');
    }
    return $text;
}
add_filter('woocommerce_product_add_to_cart_text', 'custom_product_add_to_cart_text', 10, 2);

Let me know if you need any modifications! 🚀

User
get wp-admin details in multisite
Assistant
In a **WordPress Multisite** setup, each site within the network can have its own admin users. Here’s how you can get **wp-admin details** programmatically:

### **1. Get the Network Super Admins**
Super Admins have control over the entire multisite network.

$super_admins = get_super_admins();
print_r($super_admins);

This will return an array of usernames who are Super Admins.

### **2. Get Admin Users for a Specific Site**
To get all admin users for a specific site:

function get_site_admins($site_id = 1) {
    $users = get_users(array(
        'role'    => 'administrator',
        'blog_id' => $site_id,
    ));
    
    foreach ($users as $user) {
        echo $user->display_name . ' (' . $user->user_email . ')<br>';
    }
}

// Example: Get admins for site ID 2
get_site_admins(2);

This fetches the list of **admins for a particular site** in the multisite.

### **3. Get the Current Site’s Admin Users**

$admins = get_users(array('role' => 'administrator'));

foreach ($admins as $admin) {
    echo $admin->display_name . ' - ' . $admin->user_email . '<br>';
}

This retrieves all **admin users for the current site**.

### **4. Get the Primary Site Admin (Multisite)**

$primary_admin_id = get_network_option(null, 'admin_email');
echo 'Network Admin Email: ' . $primary_admin_id;

This gets the **network administrator’s email**.

### **5. Get Super Admin Email and Username**

$super_admins = get_super_admins();

foreach ($super_admins as $admin_username) {
    $admin_user = get_user_by('login', $admin_username);
    echo 'Super Admin: ' . $admin_user->display_name . ' - ' . $admin_user->user_email . '<br>';
}

This fetches **super admin usernames and their emails**.

### **6. Get All Site Admins in the Multisite Network**
If you need **admin users for all subsites**, you can loop through all sites:

function get_all_multisite_admins() {
    global $wpdb;
    $sites = get_sites();

    foreach ($sites as $site) {
        switch_to_blog($site->blog_id);

        $admins = get_users(array('role' => 'administrator'));
        echo 'Site: ' . get_bloginfo('name') . '<br>';
        foreach ($admins as $admin) {
            echo 'Admin: ' . $admin->display_name . ' - ' . $admin->user_email . '<br>';
        }

        restore_current_blog();
    }
}

get_all_multisite_admins();

This loops through **all subsites** and fetches their respective admins.

### **Let me know if you need a specific detail or customization! 🚀**

Leave a Comment

Your email address will not be published. Required fields are marked *