Okay
  Public Ticket #3622007
integration - need info about database field
Closed

Comments

  •  1
    are skurdal started the conversation

    Hello! I want to use an integration to feed my woocommerce with customer prices. This will be fixed prices. 

    I suppose I must create customer group equal to customers in B2B-king to make this work, sinmce each customer will have their own prices.

    Then; I need to know the name (table and fields) to feed the database with customer specific prices. 


    So, can you provide me with this? 

    Tablename / Fieldname to create customer group

    Tablename / Fieldname to create customer price (price related to customer group)

  •  1,892
    WebWizards replied

    Hello Are,

    Thank you for getting in touch with us,


    Generally we would not recommend creating a unique group for each individual customer (unless you have a smaller number of customers, lower than < 50).


    Instead, you can use a different approach:

    (A) For each product you can set these product meta keys:

    b2bking_regular_price_user_1234

    b2bking_sale_price_user_1234

    where 1234 is the user ID

    The value of the keys is the price.


    For example if you want to set the regular price for a product to $500 for user John (ID 345), you would set

    b2bking_regular_price_user_345 = 500 for that product.


    This is part of a price lists feature we are currently developing. This does not have a UI yet (only works via the database), as the UI is next to be developed.


    (B) Another option is to create fixed price dynamic rule for each product and user. Such rules can be created in bulk via REST API: https://woocommerce-b2b-plugin.com/docs/import-or-setup-dynamic-rules-programatically/


    Let me know if you have any questions,


    Also I am not sure if your question is pre-sales or if you are already using the plugin. If you are, kindly please share your license key with us as we need to add that to our database for support,


    Kind regards,

    Stefan

  •  1
    are skurdal replied

    Thank you for quick respons !

     

    I have an old licence, but will renew now, since this customer will expand their operation.

     

    I did not quite understand how to insert this into the database? b2bking_regular_price_user_345 = 500

    Must I create new fields to make it work?

     

    And; is there any possibility to use other field to identify the customer? We use a integration to create the customers, and if possible we don’t want to search and get ID for each time a customer price changes. We could create a new field at the customer in B2B king called “customer number” if that’s possible to use when inserting the price.

     

  •  1
    are skurdal replied

    BTW: This is my license:

    2de2669f-df32-445d-975d-bf16a784d8ce

  •  1,892
    WebWizards replied

    Hi Are,

    Thanks for getting back to me,


    I did not quite understand how to insert this into the database? b2bking_regular_price_user_345 = 500

    In this case, 'b2bking_regular_price_user_345' is a product meta key in the wp_postmeta table. There are a few different ways you could use to insert this into the database.

    -> When editing the product, you can manually enter that using the "custom fields" area:

    7542095906.png


    -> You could do it via PHP, using the function:

    update_post_meta($product_id, 'b2bking_regular_price_user_345', 500);

    -> You could also modify the database directly (e.g. via SQL):

    2098885648.png

    (1234 here is the ID of the product).

    -> It could also be done via REST API, setting a metadata for a product (WooCommerce API) or a post (WP API).


    Generally, yes, you would create a new field / product meta key, as it probably doesn't already exist. In PHP, the function update_post_meta is perfect because it creates it if it doesn't exist, or updates it if it already exists.


    And; is there any possibility to use other field to identify the customer? We use a integration to create the customers, and if possible we don’t want to search and get ID for each time a customer price changes. We could create a new field at the customer in B2B king called “customer number” if that’s possible to use when inserting the price.

    I suppose we could make a change to it to also allow replacing the customer ID with the customer username. Would that work for you? I think we could make a change to the code to make them equivalent.

  •  1
    are skurdal replied

    Hello - Is it possible to get you to help us with this? I can write a description on how it should work, and you can do the magic with code? I will of course pay for all the work, since this is custom code for us. 

  •  1,892
    WebWizards replied

    Hi Are,

    We are not able to do any paid custom work I'm afraid - it's just a time issue for us and we are focusing exclusively on the plugins themselves.

    However, feel free to send us more details about how you need this to work. If it is not too complex, we can try to send you the code for that as part of support, or at least try to point you in the right direction.

    I can also do what I mentioned previously (to add support for usernames instead of user IDs) and send you that version if it would help.


  •  1
    are skurdal replied

    Hello :-)

    Yes, we would like to get support for Username instead of UserID

    We use an integration for both new customers and products. I need to get support for creating the metakey like ´b2bking_regular_price_user_345' for all items - all customers.

    And same thing when new items; add the same metakey for all customers that are B2B to the new items. 

    This customer will open for B2C customers later, so this cannot stop serving both B2B and B2C.

    If this can be done by REST API to Woocommerce, its also something we can use. 

  •  1
    are skurdal replied

    Any news here ? 

  •   WebWizards replied privately
  •  1
    are skurdal replied

    Thank you so much for this!


    I tried both with username and user ID:



    370062526b2bking_regular_price_user_are111
    370072526b2bking_regular_price_user_34999

    Is this correct use of the metakey? None of them works for me - "are" is username, "34" is his user ID 


    https://app.screencast.com/c7TCiwKIBoVeK


    What am I doing wrong? 


  •  1,892
    WebWizards replied

    Can you confirm that you have already installed the B2BKing Pro 5010 version?

    From your screenshot I cannot tell what the issue is.

    I took a quick video showing how this should work: https://www.loom.com/share/c711b7df332f46dbb6842ed6e597cf89?sid=99926ec2-749c-4413-a6e3-e6e88bd53bfe


    Please also make sure that you have not disabled "group & tiered pricing" in B2BKing -> Settings -> Other -> Components. This feature is part of "group pricing".



  •  1
    are skurdal replied

    Thank you - Now we got it working !

    :-)