Warning: This method has been deprecated. Use duplicate_product() instead.

Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness. Use duplicate_product instead.

WC_Admin_Duplicate_Product::get_product_to_duplicate( mixed $id )

Get a product from the database to duplicate.


Description Description

See also See also


Top ↑

Parameters Parameters

$id

(Required) The ID of the product to duplicate.


Top ↑

Return Return

(object|bool)


Top ↑

Source Source

File: includes/admin/class-wc-admin-duplicate-product.php

	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;
	}

Top ↑

Changelog Changelog

Changelog
Version Description
3.0.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.