| @@ -141,8 +141,10 @@ | ||
| 141 | 141 | 'status' => false, |
| 142 | 142 | 'text' => __( 'Can\'t update the flow data', 'cartflows' ), |
| 143 | 143 | ); |
| 144 | 144 | |
| 145 | + $skipped_fields = array(); | |
| 146 | + | |
| 145 | 147 | if ( isset( $_POST['flow_id'] ) ) { |
| 146 | 148 | $flow_id = intval( $_POST['flow_id'] ); |
| 147 | 149 | |
| 148 | 150 | if ( empty( $flow_id ) ) { |
| @@ -160,10 +162,10 @@ | ||
| 160 | 162 | } |
| 161 | 163 | |
| 162 | 164 | $new_flow_slug = isset( $_POST['post_name'] ) ? sanitize_text_field( wp_unslash( $_POST['post_name'] ) ) : ''; |
| 163 | 165 | |
| 164 | - $post_meta = wcf()->options->get_flow_fields( $flow_id ); | |
| 165 | - MetaOps::save_meta_fields( $flow_id, $post_meta, 'cartflows_save_flow_meta_settings' ); | |
| 166 | + $post_meta = wcf()->options->get_flow_fields( $flow_id ); | |
| 167 | + $skipped_fields = MetaOps::save_meta_fields( $flow_id, $post_meta, 'cartflows_save_flow_meta_settings' ); | |
| 166 | 168 | |
| 167 | 169 | $instant_layout_style = isset( $_POST['instant-layout-style'] ) ? sanitize_text_field( wp_unslash( $_POST['instant-layout-style'] ) ) : null; |
| 168 | 170 | |
| 169 | 171 | if ( 'yes' === $instant_layout_style ) { |
| @@ -183,8 +185,15 @@ | ||
| 183 | 185 | |
| 184 | 186 | $response_data = array( |
| 185 | 187 | 'message' => __( 'Successfully saved the flow data!', 'cartflows' ), |
| 186 | 188 | ); |
| 189 | + | |
| 190 | + // Name anything the save dropped rather than reporting a clean save the user did not get. | |
| 191 | + if ( ! empty( $skipped_fields ) ) { | |
| 192 | + $response_data['skipped_fields'] = $skipped_fields; | |
| 193 | + $response_data['message'] = __( 'Saved, but the custom script fields were not updated because your account cannot edit scripts.', 'cartflows' ); | |
| 194 | + } | |
| 195 | + | |
| 187 | 196 | wp_send_json_success( $response_data ); |
| 188 | 197 | } |
| 189 | 198 | |
| 190 | 199 | /** |