Okay
  Public Ticket #3209174
Sub Account - Order from same address
Closed

Comments

  •  8
    Nic started the conversation

    Hello, these are questions for buyers on my website, so people that would be buying products from my website.


    If a customer (customer 1) creates multiple sub accounts (customer a, b and c) can a second customer (customer 2) also utilize those subaccount for their buying. so can bot customer 1 and 2 have the same subaccount a, b and c purchase on their behalf?


    also, when customers a, b and c are purchasing, can they have the address of customer 1 be their default address for ordering?


    also, does customer 1 receive an email of the order when customer a, b or c makes a purchase?

  •  1,904
    WebWizards replied

    Hello Nic,

    Thank you for purchasing our plugin!


    Regarding your questions:

    If a customer (customer 1) creates multiple sub accounts (customer a, b and c) can a second customer (customer 2) also utilize those subaccount for their buying. so can bot customer 1 and 2 have the same subaccount a, b and c purchase on their behalf?

    It is not possible for 2 main accounts to share subaccounts between them. That is because an account is considered basically the main account for a company, and subaccounts are considered employees, or perhaps specific branches or offices in that company. 


    also, when customers a, b and c are purchasing, can they have the address of customer 1 be their default address for ordering?

    Yes, by default that is how it works. The subaccounts (a, b, c) will start out with the parent account's (customer 1) addresses.


    also, does customer 1 receive an email of the order when customer a, b or c makes a purchase?

    The parent account  (customer 1) does not receive those emails normally. They can get those emails IF they enable 'order approval' for the subaccount ( https://woocommerce-b2b-plugin.com/docs/company-order-approval/ ). Through the order approval feature, the parent account can require that they are notified and first approve the order before it goes through.

    The parent account can also view all subaccount orders by going to My Account -> Orders.

    If you'd like, we can also provide a code snippet to make the parent account receive emails for all subaccount orders (Regardless of whether order approval is required).


    Kind regards,

    Stefan


  •  8
    Nic replied

    Okay, thank you for all that information. I might have found a workaround using all 3 B2B plugins for what I need to do with the accounts connecting to one another. But regarding the code snippets, that would be awesome to get that chunk of code. I am building out a reasonably dynamic website, so anything that comes straight from the plugin developers would make my life a lot easier when going through and customizing.


    I was also wondering, in regards to the B2B SalesKing, for the Agent accounts, is there a way to remove the "manage orders" button from the view, while still keeping the actual "orders" tab available for them? I am looking at having orders showcased for them, I just don't want them to be able to have any access to the WP-Admin dashboard in any form.

  •  1,904
    WebWizards replied

    To remove the "Manage Order" buttons, please add this PHP code snippet to your site:

    add_filter('salesking_show_actions_my_orders_page','__return_false');
    add_filter('salesking_show_actions_my_earnings_page','__return_false');
    


    And to also forward the "your order has been received" email to the parent account whenever a subaccount places an order, please use:

    add_filter( 'woocommerce_email_recipient_customer_processing_order', 'filter_customer_received_order_email_recipient_subaccount', 10, 2 );
    function filter_customer_received_order_email_recipient_subaccount( $recipient, $order ){
        $customer_id = $order->get_customer_id();
        $account_type = get_user_meta($customer_id,'b2bking_account_type', true);
        if ($account_type === 'subaccount'){
            // add parent account to recipient list
            $parent_account = get_user_meta($customer_id, 'b2bking_account_parent', true);
            $parent_user = get_user_by('id', $parent_account);
            $parent_email = $parent_user->user_email;
            $recipient .= ', '.$parent_email;
        }
        return $recipient;
    }

    It seems to be working in my tests,


    Let me know if you have any issues with those or if I can help with anything,

  •  8
    Nic replied

    Hello, I know this is closed now, but for the code you gave me to remove the "Manage Orders" button, is there a way that I can have that enabled for specific user accounts? like if I have a user with access as "Sub-Admin" they would have access to still manage orders, but nobody else?

  •  1,904
    WebWizards replied

    Hi Nic,

    Sure, we can modify that snippet to apply to specific users only.


    My question is, what exactly is a 'sub-admin' in your configuration? Is it a WP ROLE? If so, what is the slug of the role?

    Basically I need to know how I can check in the code to see if the user is a 'sub-admin' or not.


    Kind regards,

    Stefan

  •  8
    Nic replied

    I was able to write some code for this to have the specific users have the function apply to them, so I should be all good on this now