set_product_ids() public method

Set the product IDs this coupon can be used with.
Since: 2.7.0
public set_product_ids ( array $product_ids )
$product_ids array
 /**
  * Update post meta fields.
  *
  * @param WP_Post $post
  * @param WP_REST_Request $request
  * @return bool|WP_Error
  */
 protected function update_post_meta_fields($post, $request)
 {
     $coupon = new WC_Coupon($post->post_title);
     if (isset($request['amount'])) {
         $coupon->set_amount($request['amount']);
     }
     if (isset($request['individual_use'])) {
         $coupon->set_individual_use($request['individual_use']);
     }
     if (isset($request['product_ids'])) {
         $coupon->set_product_ids($request['product_ids']);
     }
     if (isset($request['exclude_product_ids'])) {
         $coupon->set_excluded_product_ids($request['exclude_product_ids']);
     }
     if (isset($request['usage_limit'])) {
         $coupon->set_usage_limit($request['usage_limit']);
     }
     if (isset($request['usage_limit_per_user'])) {
         $coupon->set_usage_limit_per_user($request['usage_limit_per_user']);
     }
     if (isset($request['limit_usage_to_x_items'])) {
         $coupon->set_limit_usage_to_x_items($request['limit_usage_to_x_items']);
     }
     if (isset($request['usage_count'])) {
         $coupon->set_usage_count($request['usage_count']);
     }
     if (isset($request['expiry_date'])) {
         $coupon->set_expiry_date($request['expiry_date']);
     }
     if (isset($request['free_shipping'])) {
         $coupon->set_free_shipping($request['free_shipping']);
     }
     if (isset($request['product_categories'])) {
         $coupon->set_product_categories($request['product_categories']);
     }
     if (isset($request['excluded_product_categories'])) {
         $coupon->set_excluded_product_categories($request['excluded_product_categories']);
     }
     if (isset($request['exclude_sale_items'])) {
         $coupon->set_exclude_sale_items($request['exclude_sale_items']);
     }
     if (isset($request['minimum_amount'])) {
         $coupon->set_minimum_amount($request['minimum_amount']);
     }
     if (isset($request['maximum_amount'])) {
         $coupon->set_maximum_amount($request['maximum_amount']);
     }
     if (isset($request['email_restrictions'])) {
         $coupon->set_email_restrictions($request['email_restrictions']);
     }
     $coupon->save();
     return true;
 }