WordPress at Your Fingertips
function is not described

WC_Admin_Duplicate_Product::get_product_to_duplicate() private WC 1.0

Deprecated from version 3.0.0. It is no longer supported and can be removed in future releases. It is recommended to replace this function with the same one.

Get a product from the database to duplicate.

{} It's a method of the class: WC_Admin_Duplicate_Product{}

No Hooks.

Return

Object|true|false.

Usage

// private - for code of main (parent) class only
$result = $this->get_product_to_duplicate( $id );
$id(mixed) (required)
The ID of the product to duplicate.

Notes

  • See: duplicate_product

Changelog

Deprecated 3.0.0

Code of WC_Admin_Duplicate_Product::get_product_to_duplicate() WC 5.9.0

private function get_product_to_duplicate( $id ) {
	global $wpdb;

	$id = absint( $id );

	if ( ! $id ) {
		return false;
	}

	$post = $wpdb->get_row( $wpdb->prepare( "SELECT {$wpdb->posts}.* FROM {$wpdb->posts} WHERE ID = %d", $id ) );

	if ( isset( $post->post_type ) && 'revision' === $post->post_type ) {
		$id   = $post->post_parent;
		$post = $wpdb->get_row( $wpdb->prepare( "SELECT {$wpdb->posts}.* FROM {$wpdb->posts} WHERE ID = %d", $id ) );
	}

	return $post;
}