Longshot question
Quote from dka on March 16, 2019, 4:55 pmIs there any way to feed newly created WooCommerce products into posts within a topic such as “new products”?
Is there any way to feed newly created WooCommerce products into posts within a topic such as “new products”?
Quote from Asgaros on March 17, 2019, 4:50 amHello @dka
This should be possible but requires a bit of coding-experience and knowledge about the WooCommerce API.
public function createProductTopic($new_status, $old_status, $post) { if ($post->post_type == 'WCPOSTTYPENAME' && $new_status == 'publish' && $old_status != 'publish') { $forumID = FORUMID; $post_title = apply_filters('asgarosforum_filter_automatic_product_title', $post->post_title, $post); $post_content = apply_filters('asgarosforum_filter_automatic_product_content', $post->post_content, $post); if ($this->content->forum_exists($forumID)) { $this->content->insert_topic($forumID, $post_title, $post_content, $post->post_author); } } }What you have to figure out here is:
- the post-type name of a product
- the forum-id in which the products should be included in
- the logic which creates title and text for the product by using the two filters I added
The function can then get called via the following hook:
add_action('transition_post_status', array($this, 'createProductTopic'), 10, 3);
Hello @dka
This should be possible but requires a bit of coding-experience and knowledge about the WooCommerce API.
public function createProductTopic($new_status, $old_status, $post) { if ($post->post_type == 'WCPOSTTYPENAME' && $new_status == 'publish' && $old_status != 'publish') { $forumID = FORUMID; $post_title = apply_filters('asgarosforum_filter_automatic_product_title', $post->post_title, $post); $post_content = apply_filters('asgarosforum_filter_automatic_product_content', $post->post_content, $post); if ($this->content->forum_exists($forumID)) { $this->content->insert_topic($forumID, $post_title, $post_content, $post->post_author); } } }
What you have to figure out here is:
- the post-type name of a product
- the forum-id in which the products should be included in
- the logic which creates title and text for the product by using the two filters I added
The function can then get called via the following hook:
add_action('transition_post_status', array($this, 'createProductTopic'), 10, 3);
Quote from Asgaros on March 18, 2019, 3:57 am@dka The code and its modifications can all get added to the end of your themes functions.php file.
@dka The code and its modifications can all get added to the end of your themes functions.php file.