I’m having to design an e-commerce site where users should be able to create a product from front-end.
In WordPress, the product will simply be a post with custom fields like Price, Condition,…….
Also, from front-end, the user should be able to upload pictures.
I just need some advice from you guys. What would be the best-practice for this. I’ve not come across any e-commerce plugin that allow front-end posting of product. So can you please advise me
2 Answers
I like mrwweb’s suggestion, but if you are trying to do it yourself / for free, you will have to do a few things:
1) Make a new template PHP file with the forms you will need to create a new product, create a new page and assign it the template you created
2) Create your custom post type or decide to use post meta instead for your extra fields
3) In your template, use PHP to process the form and do something like this to insert it as a post in the WordPress database:
$new_post = array(
'post_title' => $post_title,
'post_content' => $post_content,
'post_status' => $post_type,
'post_author' => $author_id,
'post_category' => $category,
);
$new_post_id = wp_insert_post($new_post);
add_post_meta($new_post_id, "product_type", "tshirt");
It’s a lot more work than just that code above of course, just a starting point if you were going to write the solution yourself.