@@ -85,14 +85,6 @@ public function get_data_from_order( int $order_id ): array {
85
85
};
86
86
$ items_to_send = array_map ( $ process_item , $ order_items );
87
87
88
- if ( count ( $ items_to_send ) > 200 ) {
89
- // If more than 200 items are present, bundle the last ones in a single item.
90
- $ items_to_send = array_merge (
91
- array_slice ( $ items_to_send , 0 , 199 ),
92
- [ $ this ->bundle_level3_data_from_items ( array_slice ( $ items_to_send , 200 ) ) ]
93
- );
94
- }
95
-
96
88
$ level3_data = [
97
89
'merchant_reference ' => (string ) $ order ->get_id (), // An alphanumeric string of up to characters in length. This unique value is assigned by the merchant to identify the order. Also known as an “Order ID”.
98
90
'customer_reference ' => (string ) $ order ->get_id (),
@@ -112,6 +104,29 @@ public function get_data_from_order( int $order_id ): array {
112
104
$ level3_data ['shipping_from_zip ' ] = $ store_postcode ;
113
105
}
114
106
107
+ /**
108
+ * Filters the Level 3 data based on order.
109
+ *
110
+ * Example usage: Enables updating the discount based on the products in the order,
111
+ * if any of the products are gift cards.
112
+ *
113
+ * @since 8.0.0
114
+ *
115
+ * @param array $level3_data Precalculated Level 3 data based on order.
116
+ * @param WC_Order $order The order object.
117
+ */
118
+ $ level3_data = apply_filters ( 'wcpay_payment_request_level3_data ' , $ level3_data , $ order );
119
+
120
+ if ( count ( $ level3_data ['line_items ' ] ) > 200 ) {
121
+ // If more than 200 items are present, bundle the last ones in a single item.
122
+ $ items_to_send = array_merge (
123
+ array_slice ( $ level3_data ['line_items ' ], 0 , 199 ),
124
+ [ $ this ->bundle_level3_data_from_items ( array_slice ( $ level3_data ['line_items ' ], 199 ) ) ]
125
+ );
126
+
127
+ $ level3_data ['line_items ' ] = $ items_to_send ;
128
+ }
129
+
115
130
return $ level3_data ;
116
131
}
117
132
0 commit comments