I’m working on extending the “Purchase Lists” (Indkøbslister) feature in B2BKing and need a bit of technical clarification about how and where these lists are stored.
Here’s what I’ve done so far:
I can see and manage my purchase lists perfectly under My Account → Purchase Lists (so the feature works).
However, when I inspect my WordPress setup, I don’t see a public CPT registered for them (for example, there’s no b2bking_purchase_list post type).
I’ve also checked user meta and found only b2bking_subaccounts_list and b2bking_user_payment_method_B2BKing_Purchase_Order_Gateway, neither of which seem to hold the list data or product references.
I’m trying to build a small front-end integration that lets the main account add products to existing purchase lists directly from the product page (for example, through a “Add to Purchase List” button).
Could you please confirm the following:
Where exactly are Purchase Lists stored? (CPT name, user meta key, or custom database table?)
If it’s a CPT, what’s the post type slug and which meta key contains the product IDs?
If it’s stored elsewhere (like a custom table), could you share its structure or the function I can use to access and modify those lists programmatically?
The purchase lists are stored as a custom post type with the slug `b2bking_list` (not b2bking_purchase_list). You'll find these posts in the `wp_posts` table.
Here's the structure:
1. Post Type: `b2bking_list`
2. List Owner: The `post_author` field contains the user ID who owns the list
3. Products & Quantities: Stored as post meta under the key `b2bking_purchase_list_details`
The `b2bking_purchase_list_details` meta value contains a string format like: `188:4|191:2|3806:4|4001:1|` where:
- First number in each pair = Product ID
- Second number = Quantity in the list
For adding products to lists directly from product pages, I've created a code snippet that does what you're looking for: https://pastecode.io/s/8t0txi46
Hi there,
I’m working on extending the “Purchase Lists” (Indkøbslister) feature in B2BKing and need a bit of technical clarification about how and where these lists are stored.
Here’s what I’ve done so far:
I can see and manage my purchase lists perfectly under My Account → Purchase Lists (so the feature works).
However, when I inspect my WordPress setup, I don’t see a public CPT registered for them (for example, there’s no b2bking_purchase_list post type).
I’ve also checked user meta and found only b2bking_subaccounts_list and b2bking_user_payment_method_B2BKing_Purchase_Order_Gateway, neither of which seem to hold the list data or product references.
I’m trying to build a small front-end integration that lets the main account add products to existing purchase lists directly from the product page (for example, through a “Add to Purchase List” button).
Could you please confirm the following:
Where exactly are Purchase Lists stored? (CPT name, user meta key, or custom database table?)
If it’s a CPT, what’s the post type slug and which meta key contains the product IDs?
If it’s stored elsewhere (like a custom table), could you share its structure or the function I can use to access and modify those lists programmatically?
Hi Michael,
Glad to assist,
The purchase lists are stored as a custom post type with the slug `b2bking_list` (not b2bking_purchase_list). You'll find these posts in the `wp_posts` table.
Here's the structure:
1. Post Type: `b2bking_list`
2. List Owner: The `post_author` field contains the user ID who owns the list
3. Products & Quantities: Stored as post meta under the key `b2bking_purchase_list_details`
The `b2bking_purchase_list_details` meta value contains a string format like: `188:4|191:2|3806:4|4001:1|` where:
- First number in each pair = Product ID
- Second number = Quantity in the list
For adding products to lists directly from product pages, I've created a code snippet that does what you're looking for: https://pastecode.io/s/8t0txi46
This snippet adds a "Add to Purchase List" area under each product like this: https://prnt.sc/OrB4zeNAL05c
Let me know if you need any clarification,
Kind regards,
Stefan
Once again you did it, Stefan!
If you keep this up you might risk not hearing from me again ;)
Haha, I appreciate that! No worries - we're here if you need anything.
Have a great week,
Kind regards,
Stefan