Home Forums WC Vendors Pro Support duplicate on publish by user

NOTICE: We've Moved to a Ticket System for Support

As of August 31, 2017 (12am EST) our support forums will be retired (read-only), and we will be moving to a support ticket system.  This will allow us to better organize and answer support requests, and provide a more personalized experience as we assist our customers.

For the time being, we will leave our forums open for reading and learning while we work on creating a more robust Knowledge Base for everyone to use.

If you are a WC Vendors Pro customer please open a support ticket here. 

If you are a WC Vendors user please open a support ticket on the Wordpress.org forums.

The information on this forum is outdated and in most instances no longer relevant. Please be sure to check our documentation for the most up to date information.

https://docs.wcvendors.com/

Thank you to all of our customers!

 

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #63337
    Martin
    Participant

    First, thanks to the support team. You already helped me a lot through the Knowledge Base. I’m on Woocommerce 2.6.14 and Wc vendor 1.3.9 (not latest version I know but I doubt my problem comes from this from reading what’s new in 1.4.0.)
    I’m not asking you to solve my problem or do the work for me but more to guide me in the right path to follow.
    Let me explain.
    The problem start with WPML that require a duplicate of the post to show the product on the user selected language.
    I had to duplicate all posts on publish. I used some code I found here that goes like:
    function my_duplicate_on_publish( $post_id ) {
    global $post;
    if ( defined( ‘DOING_AUTOSAVE’ ) && DOING_AUTOSAVE ) {
    return $post_id;
    }
    if ( isset( $post->post_type ) && $post->post_type == ‘revision’ ) {
    return $post_id;
    }
    remove_action( ‘save_post’, ‘my_duplicate_on_publish’ );
    $is_translated = apply_filters( ‘wpml_element_has_translations’, ”, $post_id, $post->post_type );
    if ( !$is_translated ) {
    do_action( ‘wpml_admin_make_post_duplicates’, $post_id );
    }
    }
    add_action( ‘save_post’, ‘my_duplicate_on_publish’ );

    Fine! It helped. Once the admin acknowledge the post and publish it the translated version is created and I can see my product in my 2 different languages. Everything is great!
    But this caused some other problems. Some I solved and some I’d need guidance to overcome.
    My biggest worry is that I need some user to have to right to publish themselves without verification.
    Hence, I trusted them in Store general options.

    Problem 1.
    The only problem is that these users do not register in the previous function when they save the post at first. No duplicate is made until the user goes and edit the product (then a duplicate is created but has no photo this time).
    So!
    What would be my best option?
    1. Try and find what is missing in the function to duplicate on publish by a trusted user
    2. Add a publish button so they must publish it themselves after creation?

    Problem 2.
    Products duplicate are listed twice in the Dashboard. I think I can solve this problem myself but if you have a hint on the best place to edit to remove products that are translations it would be appreciated.

    Thanks a lot,
    Mathieu Wilson

    #63435
    Martin
    Participant

    I investigated a little bit more this morning. I think it has to do with trying
    to make a duplicate of a post still in revision.

    https://codex.wordpress.org/Revisions says:
    Revisions are stored as children of their associated post (the same thing we do for attachments).

    I’ll simply do this in 2 separate operation.
    User post, then publish by a custom button added to product page.

    If you have any better suggestion I’m listening.
    Thanks

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘WC Vendors Pro Support’ is closed to new topics and replies.