Merge pull request #12488 from woocommerce/save-coupon-wp-error
When saving coupons, return wp_error if necessary
This commit is contained in:
commit
a8f6fd88f4
|
@ -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 ) {
|
||||
|
|
Loading…
Reference in New Issue