PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.10.24
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.10.24
1.10.24 1.10.23 1.10.22 1.10.21 1.10.20 1.10.19 1.10.18 1.10.17 1.10.16 1.10.15 1.10.13 1.10.14 1.10.12 1.10.11 1.10.10 1.10.9 1.10.8 untagged-3d9b7ccddc54df87c672 1.10.7 1.10.6 1.10.5 1.10.3 1.10.4 1.10.2 1.10.1 All 168 releases
← All changes | includes/API/V1/Orders_Controller.php +19 -2 1.10.19 → 1.10.24 View file →
@@ -1136,11 +1136,29 @@
1136 1136 if ( ! isset( $request['coupon_lines'] ) || ! \is_array( $request['coupon_lines'] ) ) {
1137 1137 return false;
1138 1138 }
1139 1139
1140 + // Drop the POS's deletion markers (`{ id, code: null }`, the shape wc/v3 honours
1141 + // for every other line collection) before the comparison: the remaining codes
1142 + // then differ from the stored set and the parent's remove-and-reapply removes
1143 + // the coupon. Forwarded as-is, the marker is a codeless line and wc/v3 400s.
1144 + // Only an existing order can carry a synced coupon line: on a create (order
1145 + // not yet saved) every line is forwarded as posted so wc/v3 still rejects it.
1146 + $coupon_lines = $request['coupon_lines'];
1147 + if ( $order->get_id() > 0 ) {
1148 + $coupon_lines = array_values(
1149 + array_filter(
1150 + $coupon_lines,
1151 + static function ( $line ) {
1152 + return ! Order_Write_Payload::is_coupon_deletion_marker( $line );
1153 + }
1154 + )
1155 + );
1156 + }
1157 +
1140 1158 // Extract coupon codes from the request.
1141 1159 $requested_codes = array();
1142 - foreach ( $request['coupon_lines'] as $item ) {
1160 + foreach ( $coupon_lines as $item ) {
1143 1161 $code = $item['code'] ?? '';
1144 1162 if ( '' !== $code ) {
1145 1163 $requested_codes[] = wc_strtolower( wc_format_coupon_code( wc_clean( $code ) ) );
1146 1164 }
@@ -1163,9 +1181,8 @@
1163 1181 return false;
1164 1182 }
1165 1183
1166 1184 // Codes have changed — strip IDs and let the parent handle remove-and-reapply.
1167 - $coupon_lines = $request['coupon_lines'];
1168 1185 foreach ( $coupon_lines as &$coupon_line ) {
1169 1186 unset( $coupon_line['id'] );
1170 1187 }
1171 1188 $request->set_param( 'coupon_lines', $coupon_lines );