Answer the question
In order to leave comments, you need to log in
How to add custom post types to WooCommerce database?
Good day to all. A very long time ago I made a website-catalog ( https://goska.ru/ - the design is being processed, but the essence remains the same).
We have the ability to create custom types for the post in the admin panel.
That is, the administrator creates a new post, when creating it, he simply enters data, and then they are driven through groups of fields into the post template and displayed.
Now you need to create a shopping cart and pay through a third-party service. The question arose, is it possible to integrate this type of post into WooCommerce to simply add a price field for these posts and a purchase (add to cart) button, or is it necessary to import products with a bunch of fields and a new template for the product, but already in WooCommerce?
Thank you for your attention.
Answer the question
In order to leave comments, you need to log in
In the WP system, it is not possible to reassign the product type, but it was not necessary.
I have exported via WP All Export my custom field set for future products. Next, I opened this CSV export file in Google Sheets, since Excel breaks them, and for each field I need, which should be transferred, I set the title, in the form of meta: size -
After that, I created another type (or you can rename the old one) field groups for, already, products. With the same "directions". After that, I imported my file with meta fields into the product database: and at the import stage, my fields were automatically pulled up as meta data. When I finished the import, my custom fields for the "product" type were already filled with my meta-data and the product template pulled the data I needed from the fields with the_field(), which already contained new data from the import for the "product" type.
All query() and loop() in my project were working, because after removing my custom post type "projects", the type "product" became the default type "post" and everything began to work as before, only with the new _id and data for _price.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question