WordPress action hook

woocommerce_product_duplicate_before_save

Defined by WooCommerce and fired by 5 plugins in total, running on 7M+ sites between them.

“This action can be used to modify the object further before it is created - it will be passed by reference.”

How to use woocommerce_product_duplicate_before_save

It's an action: your callback runs at that point and receives 2 arguments. Nothing needs to be returned. Add this to your theme's functions.php or a small custom plugin:

functions.php
add_action( 'woocommerce_product_duplicate_before_save', function( $duplicate, $product ) {
	// Your code runs here.
}, 10, 2 );

Argument names come from WooCommerce's source. Other plugins may pass different values: check the call in the plugin you're targeting below.

5 plugins that fire woocommerce_product_duplicate_before_save

Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.

  1. WooCommerce icon WooCommerce7+ million installs do_action( 'woocommerce_product_duplicate_before_save', $duplicate, $product ) includes/admin/class-wc-admin-duplicate-product.php:187
  2. Bulky icon Bulky10,000+ installs do_action( 'woocommerce_product_duplicate_before_save', $duplicate, $product ) admin/ajax.php:682
  3. WPMelon Advanced Bulk Edit for WooCommerce icon WPMelon Advanced Bulk Edit for WooCommerce300+ installs do_action( 'woocommerce_product_duplicate_before_save', $duplicate, $source ) includes/Services/Operations_Service.php:250
  4. Salevo Boost Sales for WooCommerce icon Salevo Boost Sales for WooCommerce200+ installs do_action( 'woocommerce_product_duplicate_before_save', $duplicate, $prda ) admin/zcrosssell.php:210
  5. Food Products for WooCommerce icon Food Products for WooCommerceFewer than 10 installs do_action( 'woocommerce_product_duplicate_before_save', $oCopy, $oChild ) inc/product-types/class--product-types.php:720

Need a customisation built on this hook?

Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.