Okay
  Public Ticket #4503144
Display of individual prices B2B
Open

Comments

  •  3
    Mykola started the conversation

    Hello!

    Question on the functioning of the plugin. I don't understand how you can organize price display rules for B2B customers. In my store, an item has several price types: regular price, sale price, as well as "Small Wholesale", "Large Wholesale" and "VIP".
    "Regular price" and "sale price" values are clearly written into standard woocommerce fields and displayed to retail customers. Price values for B2B customers - "Small Wholesale", "Large Wholesale" and "VIP" can be recorded if you create the corresponding groups. But my customers have different prices for different products and may not belong to the same group.

    For example: The Smartphone item has a "VIP" price of $30 for Mr. Smith, and the Blender item has a "Small Wholesale" price of $25 for Mr. Smith. The plugin does not allow you to add Mr. Smith to two groups at the same time - "VIP" and "Small Wholesale".

    I tried individual prices using meta keys for a product: b2bking_regular_price_user_USERNAME, but there is a problem here. Because of the large number of items, prices are imported rather than added manually. But with individual prices, with b2bking_regular_price_user_USERNAME, the import file becomes too large. I have more than 20000 products and more than 1500 b2b customers, the import file turns out to be about 5-7 Gigabytes. I'm using the "wp all import" plugin for importing, but it can't handle these sizes. Too many values need to be written to custom fields.

    Can you tell me how I can optimally organize individual pricing for customers? Perhaps there are some settings or functions that I haven't noticed. 

  •  2,565
    WebWizards replied

    Hi Mykola,

    Thanks for reaching out,

    We're actually working on a new 'price lists' feature over the next few months that should help better address scenarios like yours, though it's not quite ready yet.

    For now, I think the best approach would be to use group prices as much as possible, and only apply individual meta keys like `b2bking_regular_price_user_USERNAME` when a specific price differs from the group price. This could reduce your import file size.

     

    I'm curious about the logic behind your pricing - surely there must be some patterns or rules rather than all prices being completely unique? Understanding this better would help us find the right solution.

    Regarding your example about Mr. Smith needing both "VIP" pricing for smartphones and "Small Wholesale" pricing for blenders - even if you could add him to both groups, you'd still need to specify which group price applies to which product for each customer, which I think doesn't really solve the core issue.

     

    Could you help me understand what your ideal solution would look like? How would you envision this working in the simplest way possible? We're open to developing a custom price assignment snippet or script tailored to your specific needs if that would help.

     

    Kind regards,
    Stefan

  •   Mykola replied privately
  •  2,565
    WebWizards replied

    Hi Mykola,

    Thanks for explaining this, that's very helpful.

    I've created a solution that should work similarly to what you described. Please add this PHP code snippet to your site (functions.php or any code snippets plugin):

    https://pastecode.io/s/j473qxn0

    This adds a price lists area to each customer user profile: https://prnt.sc/K4NezCl50cbl

    You can now use it to assign a specific price group for a category, or for a specific product ID (such as 1234). Please test this out and let me know how it works for you.

    If you want to set this programmatically, you can use this PHP function:

    $user_id = 123;
    $price_lists = array(
    'products' => array(
    array('product_id' => 456, 'group_id' => 10),
    array('product_id' => 789, 'group_id' => 10)
    ),
    'categories' => array(
    array('category_id' => 5, 'group_id' => 10)
    )
    );

    update_user_meta($user_id, '_custom_price_lists', $price_lists);

    I believe you can make WP All Import apply this directly during import using their inline PHP feature: https://www.wpallimport.com/documentation/inline-php/

    If that doesn't work out, we can look at it further and adjust the code or make it support a simpler meta structure.

     

    Let me know how this works for you so far!

    Kind regards,
    Stefan

  •  3
    Mykola replied

    Hi, Stefan!

    Thanks for the suggested solution! I tried the solution, it adds the right prices perfectly. But this solution doesn't work with dynamic rules((
    I checked hiding price and cost on request, prices are still displayed.

    I think that if you refine this code, you will get a great solution for the main functionality of the plugin.

    I haven't figured out how to import prices with this option yet, I'll keep looking and trying.

  •  3
    Mykola replied

    Hi, Stefan!

    I seem to be mistaken, dynamic rules seem to work with your code.

    I had to reinstall wp, theme and plugins, re-configure everything. And when I re-added the code and enabled the rules, everything worked. Maybe an old cache or some other bug was preventing it before.

    Now everything seems to be working fine, I haven't found any problems. I will test further and deal with import.

    Thanks for your help!

  •  2,565
    WebWizards replied

    Hi Mykola,

    Thanks for the update,

    Regarding dynamic rules, in principle it should work. The code I shared is equivalent to the plugin's group prices.

    So for example if you have these prices + a 50% discount dynamic rule, the 2 should stack and both should work.

     

    If you're not able to make that work with import, let me know and I think we can add support for a more direct user meta structure, such as for each user setting a meta key like `product_1234` = (group_id) or `category_123` = (group_id) - it would mean you'd need to set each category/group pair as a separate meta. If that would work better for your import process, I can make that change.

     

    Kind regards,
    Stefan

  •  3
    Mykola replied

    Hi, Stefan!

    You said you could add a more direct structure, if possible, still let's give it a try.
    I will be very grateful to you!

  •  2,565
    WebWizards replied

    Hi Mykola,

    Great! Please try this updated code snippet: https://pastecode.io/s/zjgrews4

    Instead of importing a complex array, you can now import individual user meta fields directly. Each product or category assignment is stored as a separate meta key:

    Format:
    • Product assignments: _cspg_product_{PRODUCT_ID} = {GROUP_ID}
    • Category assignments: _cspg_category_{CATEGORY_ID} = {GROUP_ID}

    Example:
    _cspg_product_456 = 10
    _cspg_product_789 = 12

    WP All Import Setup:
    Import to Users (not posts), and map each meta key to the corresponding field.

    Let me know how it goes,

    Kind regards,
    Stefan