public function duplicate_product_action()
{
if (empty($_REQUEST['post'])) {
wp_die(__('No product to duplicate has been supplied!', 'woocommerce'));
}
// Get the original page
$id = isset($_REQUEST['post']) ? absint($_REQUEST['post']) : '';
check_admin_referer('woocommerce-duplicate-product_' . $id);
$post = $this->get_product_to_duplicate($id);
// Copy the page and insert it
if (!empty($post)) {
$new_id = $this->duplicate_product($post);
// If you have written a plugin which uses non-WP database tables to save
// information about a page you can hook this action to dupe that data.
do_action('woocommerce_duplicate_product', $new_id, $post);
// Redirect to the edit screen for the new draft page
wp_redirect(admin_url('post.php?action=edit&post=' . $new_id));
exit;
} else {
/* translators: %s: product id */
wp_die(sprintf(__('Product creation failed, could not find original product: %s', 'woocommerce'), $id));
}
}