[API] Allow edit the comment status in products endpoint using the reviews_allowed param
This commit is contained in:
parent
ffbafbf652
commit
bdf88d2323
|
@ -664,6 +664,8 @@ class WC_API_Products extends WC_API_Resource {
|
|||
* @return bool
|
||||
*/
|
||||
protected function save_product_meta( $id, $data ) {
|
||||
global $wpdb;
|
||||
|
||||
// Product Type
|
||||
$product_type = null;
|
||||
if ( isset( $data['type'] ) ) {
|
||||
|
@ -1103,6 +1105,13 @@ class WC_API_Products extends WC_API_Resource {
|
|||
}
|
||||
}
|
||||
|
||||
// Reviews allowed
|
||||
if ( isset( $data['reviews_allowed'] ) ) {
|
||||
$reviews_allowed = ( true === $data['reviews_allowed'] ) ? 'open' : 'closed';
|
||||
|
||||
$wpdb->update( $wpdb->posts, array( 'comment_status' => $reviews_allowed ), array( 'ID' => $id ) );
|
||||
}
|
||||
|
||||
// Do action for product type
|
||||
do_action( 'woocommerce_api_process_product_meta_' . $product_type, $id, $data );
|
||||
|
||||
|
|
Loading…
Reference in New Issue