Okay
  Public Ticket #2664200
Importing sub accounts
Closed

Comments

  •  6
    Jonas started the conversation

    Hi, 

    I've just imported my mainaccounts and asigned them as customers.

    How can i import a bunch of subaccounts, and link them to the right mainaccounts? - I have a unique identifier on both main accounts and subaccounts. 

    Or how can i even assign a single user as a subaccount to a mainaccount? In the future i want to assign new users to companies as subaccounts. But i don't see any options for assigning subaccounts.

  •   WebWizards replied privately
  •  6
    Jonas replied

    awesome! Fantastic! 

    Regarding my question the other Day about specific pricing for companies. Would it work with around 1000 dynamic rules? And What is max?

    And Also i would like to ask for a oportunity that under a user’s account they Can see like “offers” But based on the products they have a dynamic rule on, for “specific pricing” ofc. Maybe an meta data that we Can put on the rule, like”show in my offers” . Ofcourse there should be like some sort of yes/No because we Also use other rules based on user role/enduser/reseller. 

    Cause Next step for us is to import All the Pricing rules for our customers. 

  •  6
    Jonas replied

    And is it possible that you could create a field in the menu list with customer, offers and such and link to the tool, and Call it “create subaccount”? Because the attaching of users Will be done by our sales people, that needs Everything to be as easy as possible. 


    i Really like your Add on, Its Perfect! Now we Can Also create sub accounts for main accounts without having to log in as Them.

  •  2,218
    WebWizards replied

    Hello Jonas,

    While we don't have any benchmarks, in my experience I think it should work fine with 1000 dynamic rules. All prices are cached so even if there's an initial few seconds load, after the first load everything should run very quickly.


    Regarding pricing, we will consider your suggestion. If you would like to show discounted prices, some themes have options like "Show all products that are on sale", and I think that would work with prices discounted through dynamic rules as well.


    Regarding adding an item to the menu "create subaccount": I can give you a code snippet that adds another item, but I have no way to make it go directly to that particular tool. The link would go to the entire Tools page, so I'm not sure how much that would help. Here's another idea, I wrote a code snippet to add a separate page. You can add this snippet to functions.php

    // Add "Link Subaccounts" submenu page
    add_submenu_page(
        'b2bking',
        esc_html__('Link Subaccounts','b2bking'), //page title
        esc_html__('Link Subaccounts','b2bking'), //menu title
        'manage_woocommerce', //capability,
        'b2bking_subaccounts', //menu slug
        'b2bking_subaccounts_page_content', //callback function
        25
    );
    function b2bking_subaccounts_page_content(){
        ?>
        <div id="b2bking_tools_setusersubaccounts">
            <div class="b2bking_user_settings_container_column_title_subaccounts">
                <i class="user plus icon b2bking_subaccountplusicon"></i>
                <?php esc_html_e('Set users as subaccounts of account:','b2bking'); ?>
            </div>
            <input class="b2bking_set_user_subaccounts_input" type="text" placeholder="<?php esc_html_e('Enter user ids, comma-separated (example: 12,15,19)','b2bking'); ?>" id="b2bking_set_user_subaccounts_first" style="width:50%">
            <input class="b2bking_set_user_subaccounts_input" type="text" placeholder="<?php esc_html_e('Enter parent account id (example: 23)','b2bking'); ?>" id="b2bking_set_user_subaccounts_second" style="width:50%">
            
                      <div id="b2bking_set_accounts_as_subaccounts" class="ui teal button">
                          <i class="user plus icon"></i> 
                          <?php esc_html_e('Set accounts as subaccounts of parent','b2bking');?-->
                      </div>
        </div>
        <!--?php
    }
    


    This is the result:

    1950106531.png


  •  6
    Jonas replied

    awesome Thanks. 

    Regarding the prices that Are on sale. I dont mean it like to show “on sale” But more like showing the products that a customer has a dynamic rule on, on a page in my account. 

    Example: customer A have 5 products with cheaper Price, because he buys Them often, and he should be able to see Them Quick under “my account”

  •  2,218
    WebWizards replied

    I got it now,

    We will consider implementing that in future updates.

    Thank you for the feedback,

  •  6
    Jonas replied

    Would be very cool. I think we will need it in a month or so.
    Regarding the plugin you sent me, how does it work when there is available updates for this?

  •  6
    Jonas replied

    Can you show me how to insert the code snippet? I prefer using a code snippet plugin. - I can't make it work


  •  2,218
    WebWizards replied

    Hi there,


    A code snippet plugin should work indeed and that is what I would recommend.


    I think what happened is that unfortunately the code editor here corrupted the snippet and if you just copy-pasted it, it wouldn't have worked.


    Please try these steps:

    1) See our guide here about adding a PHP snippet:

    https://woocommerce-b2b-plugin.com/docs/how-to-add-a-snippet-php-or-js/

    (you can also use another snippet plugin that you prefer of course)


    2) I am attaching the snippet as a .txt file to this message, so it doesn't get corrupted again. Please open that and copy-paste from there.


    Regarding the plugin I sent you previously with the subaccounts function - that will be part of the plugin from now on as I think it can be a useful functionality for many users.

    Kind Regards,

    Stefan

  •  6
    Jonas replied

    Hi, 
    The snippet worked at a time. But now i just get a 404 error when clicking on "link sub accounts"

  •  2,218
    WebWizards replied

    Hi,

    Please try the following:


    1)

    Replace the snippet with the attached one - I made a small change that may help


    2)

    I wonder if your issue could be a permalinks issue. Try to go to B2BKing->Settings->Other->Permalinks and enable "Force Permalinks Rewrite"

    Also try to go to WooCommerce->Settings->Advanced and simply click "Update " / "Save" - not changes have to be made. That usually refreshes the permalinks too.



  •  6
    Jonas replied

    The script still doesn't work. Redirects me to 404 page

  •   WebWizards replied privately
  •  2
    Andrea replied

    Hello, I have the same need of Jonas, could you please send me the reply you sent him in the first answer? Thank you

  •  2
    Mike Johnson replied

    Hello

    We have the same need to import sub accounts and link them to the right main accounts. Please can you post me the original reply to this thread that answers that question?

    We have a unique identifier on both main accounts and sub accounts. 

    We use WP All import for users. I'm guessing there are some meta fields we need to match up?

    Many thanks

    Mike


  •   Jonas replied privately
  •  2,218
    WebWizards replied

    Hi Mike,

    There is a tool that can help you connect accounts. This is found under B2BKing->Tools->Bulk Editor:

    4056198461.png


    Alternatively you can also use metadata as you described. You can find the metadata needed here under section 9 of this docs article:

    https://woocommerce-b2b-plugin.com/docs/multiple-buyers-per-account-subaccounts/#8-toc-title

    More specifically 3 keys are needed:

    Each subaccount needs the following 2 meta keys:

    "b2bking_account_type" must be set to "subaccount" - this tells the plugin this is a subaccount

    "b2bking_account_parent" must be set to the WordPress USER ID of the parent account (e.g. 123)

    Each parent account must have the following meta key:

    "b2bking_subaccounts_list" must contain a comma-separated list of child subaccount IDs (e.g. 123, 54, 333)


    And thanks for the help Jonas : ) 


    Kind regards,

    Stefan

  •  6
    Jonas replied

    Here you can see what i did:
    First i've imported the parrent users. Next step were to import the sub accounts with First name, Last name, Username, Email. Make sure that the username is a field you have in your import. 

    I don't think that the b2bking_subbacountlist is needed for import. 
    In the same import (WP All Import) i set up the fields like attached.

    To retrieve the parrent account ID you can paste this into the function editor:

    function returnparentID($tmpyourusernamesherefromfeed) {
        $the_user = get_user_by('login', $tmpyourusernamesherefromfeed);
        return $the_user_id = $the_user->ID;
    }


    Attached files:  484ec0140299b5428621887faa7a15fb.png