Merge pull request #12488 from woocommerce/save-coupon-wp-error

When saving coupons, return wp_error if necessary
This commit is contained in:
Mike Jolley 2016-12-01 16:21:23 +00:00 committed by GitHub
commit a8f6fd88f4
1 changed files with 5 additions and 0 deletions

View File

@ -350,6 +350,11 @@ class WC_REST_Coupons_Controller extends WC_REST_Posts_Controller {
public function save_coupon( $request ) {
try {
$coupon = $this->prepare_item_for_database( $request );
if ( is_wp_error( $coupon ) ) {
return $coupon;
}
$coupon->save();
return $coupon->get_id();
} catch ( WC_Data_Exception $e ) {