WC_Admin_Duplicate_Product::get_product_to_duplicate()
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.
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 since | 3.0.0 |
WC_Admin_Duplicate_Product::get_product_to_duplicate() WC Admin Duplicate Product::get product to duplicate code WC 9.7.1
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; }