• Hi,
    following one of your suggestion used in the forum, I added a custom snipped to my child theme for changing automatically the visibility of a product when it has been archived (a sort of custom action).

    Specifically:

    add_action( 'wcfm_after_product_archived', function( $product_id ) {
    	$product = wc_get_product(	$product_id );
    	$product->set_catalog_visibility( 'hidden' );
    	$product->save();
    });

    That is perfect!

    The issue is that it’s obviously not working during the bulk edit of the products (but only when you archived a product using the specific button in the back-end gui). It’s quite hard to do that one by one if you have 1M products to be archived for example ??

    Moreover, there is another case that is so much important:
    If we configured when a vendor is disabled (for no membership renewal) all products will be archived, these products are still visible in the woocommerce list (visibility is not hidden but catalog & search).

    I know that we can do it manually but a vendor can disable itself on its own, it’s very hard to intervene always manually.

    Could you please provide a solution for this? Is there any kind of custom action on vendor disabled and/or product bulk edit?

    Thanks a lot.

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author WC Lovers

    (@wclovers)

    wcfm_after_product_archived – this action only trigger when products mark as “archive”, not for bulk edit.

    do_action( 'wcfm_product_bulk_edit_save', $product, $wcfm_bulk_edit_form_data );

    WCFM has this hook for bulk edit.

    Thread Starter Box and Paper srl

    (@boxandpaper)

    Hi,

    thanks a lot for the reply.

    Could you please help me to find the right code? I tried that one but it’s not working. I think this method is called for each product of the bulk edit. So, in case the product is archived during the bulk edit, I’d like to limit the visibility to hidden.

    add_action( 'wcfm_product_bulk_edit_save', function ( $product, $wcfm_bulk_edit_form_data) {
    	if ( ! empty( $wcfm_bulk_edit_form_data['_product_status'] ) && $wcfm_bulk_edit_form_data['_product_status'] == 'archived' ) {
    	$product->set_catalog_visibility( 'hidden' );
    	$product->save();
    	}
    });

    Moreover, I’d like to understand if the same method is called when a store is archived (and it sets all his products to archived as well).

    Thanks a lot!

    Thread Starter Box and Paper srl

    (@boxandpaper)

    Hi,

    Any update on this?

    Please, it is important for us to guarantee an high-level of scalability for our customers…

    Thanks a lot.

    Plugin Author WC Lovers

    (@wclovers)

    Could you please help me to find the right code?

    – This code is perfect.

    I’d like to understand if the same method is called when a store is archived

    – WCFM by default does not have any store archive option. Have you created this custom?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Custom action on product buik edit (status -> archived)’ is closed to new replies.