@@ -213,7 +213,6 @@ protected function get_product_data( $product, $context = 'view' ) {
213213 'onsale ' => $ product ->is_on_sale (),
214214 'price ' => $ product ->get_price (),
215215 'price_html ' => $ product ->get_price_html (),
216- 'prices ' => $ this ->get_prices ( $ product ),
217216 'images ' => ( new ProductImages () )->images_to_array ( $ product ),
218217 'average_rating ' => $ product ->get_average_rating (),
219218 'review_count ' => $ product ->get_review_count (),
@@ -244,91 +243,6 @@ protected function get_add_to_cart_url( $product ) {
244243 return $ url ;
245244 }
246245
247- /**
248- * Get an array of pricing data.
249- *
250- * @param \WC_Product|\WC_Product_Variation $product Product instance.
251- * @return array
252- */
253- protected function get_prices ( $ product ) {
254- $ tax_display_mode = get_option ( 'woocommerce_tax_display_shop ' );
255- $ position = get_option ( 'woocommerce_currency_pos ' );
256- $ symbol = html_entity_decode ( get_woocommerce_currency_symbol () );
257- $ prefix = '' ;
258- $ suffix = '' ;
259-
260- // No break so symbol is added.
261- switch ( $ position ) {
262- case 'left_space ' :
263- $ prefix = $ symbol . ' ' ;
264- break ;
265- case 'left ' :
266- $ prefix = $ symbol ;
267- break ;
268- case 'right_space ' :
269- $ suffix = ' ' . $ symbol ;
270- break ;
271- case 'right ' :
272- $ suffix = $ symbol ;
273- break ;
274- }
275-
276- $ prices = [
277- 'currency_code ' => get_woocommerce_currency (),
278- 'decimal_separator ' => wc_get_price_decimal_separator (),
279- 'thousand_separator ' => wc_get_price_thousand_separator (),
280- 'decimals ' => wc_get_price_decimals (),
281- 'price_prefix ' => $ prefix ,
282- 'price_suffix ' => $ suffix ,
283- ];
284-
285- $ prices ['price ' ] = 'incl ' === $ tax_display_mode ? wc_get_price_including_tax ( $ product ) : wc_get_price_excluding_tax ( $ product );
286- $ prices ['regular_price ' ] = 'incl ' === $ tax_display_mode ? wc_get_price_including_tax ( $ product , [ 'price ' => $ product ->get_regular_price () ] ) : wc_get_price_excluding_tax ( $ product , [ 'price ' => $ product ->get_regular_price () ] );
287- $ prices ['sale_price ' ] = 'incl ' === $ tax_display_mode ? wc_get_price_including_tax ( $ product , [ 'price ' => $ product ->get_sale_price () ] ) : wc_get_price_excluding_tax ( $ product , [ 'price ' => $ product ->get_sale_price () ] );
288- $ prices ['price_range ' ] = $ this ->get_price_range ( $ product );
289-
290- return $ prices ;
291- }
292-
293- /**
294- * Get price range from certain product types.
295- *
296- * @param \WC_Product|\WC_Product_Variation $product Product instance.
297- * @return arary|null
298- */
299- protected function get_price_range ( $ product ) {
300- if ( $ product ->is_type ( 'variable ' ) ) {
301- $ prices = $ product ->get_variation_prices ( true );
302-
303- if ( min ( $ prices ['price ' ] ) !== max ( $ prices ['price ' ] ) ) {
304- return [
305- 'min_amount ' => min ( $ prices ['price ' ] ),
306- 'max_amount ' => max ( $ prices ['price ' ] ),
307- ];
308- }
309- }
310-
311- if ( $ product ->is_type ( 'grouped ' ) ) {
312- $ tax_display_mode = get_option ( 'woocommerce_tax_display_shop ' );
313- $ children = array_filter ( array_map ( 'wc_get_product ' , $ product ->get_children () ), 'wc_products_array_filter_visible_grouped ' );
314-
315- foreach ( $ children as $ child ) {
316- if ( '' !== $ child ->get_price () ) {
317- $ child_prices [] = 'incl ' === $ tax_display_mode ? wc_get_price_including_tax ( $ child ) : wc_get_price_excluding_tax ( $ child );
318- }
319- }
320-
321- if ( ! empty ( $ child_prices ) ) {
322- return [
323- 'min_amount ' => min ( $ child_prices ),
324- 'max_amount ' => max ( $ child_prices ),
325- ];
326- }
327- }
328-
329- return null ;
330- }
331-
332246 /**
333247 * Update the collection params.
334248 *
@@ -429,94 +343,6 @@ public function get_item_schema() {
429343 'context ' => array ( 'view ' , 'edit ' ),
430344 'readonly ' => true ,
431345 ),
432- 'prices ' => array (
433- 'description ' => __ ( 'Price data. ' , 'woo-gutenberg-products-block ' ),
434- 'type ' => 'object ' ,
435- 'context ' => array ( 'view ' , 'edit ' ),
436- 'readonly ' => true ,
437- 'items ' => array (
438- 'type ' => 'object ' ,
439- 'properties ' => array (
440- 'currency_code ' => array (
441- 'description ' => __ ( 'Currency code. ' , 'woo-gutenberg-products-block ' ),
442- 'type ' => 'string ' ,
443- 'context ' => array ( 'view ' , 'edit ' ),
444- 'readonly ' => true ,
445- ),
446- 'decimal_separator ' => array (
447- 'description ' => __ ( 'Decimal separator. ' , 'woo-gutenberg-products-block ' ),
448- 'type ' => 'string ' ,
449- 'context ' => array ( 'view ' , 'edit ' ),
450- 'readonly ' => true ,
451- ),
452- 'thousand_separator ' => array (
453- 'description ' => __ ( 'Thousand separator. ' , 'woo-gutenberg-products-block ' ),
454- 'type ' => 'string ' ,
455- 'context ' => array ( 'view ' , 'edit ' ),
456- 'readonly ' => true ,
457- ),
458- 'decimals ' => array (
459- 'description ' => __ ( 'Number of decimal places. ' , 'woo-gutenberg-products-block ' ),
460- 'type ' => 'string ' ,
461- 'context ' => array ( 'view ' , 'edit ' ),
462- 'readonly ' => true ,
463- ),
464- 'price_prefix ' => array (
465- 'description ' => __ ( 'Price prefix, e.g. currency. ' , 'woo-gutenberg-products-block ' ),
466- 'type ' => 'string ' ,
467- 'context ' => array ( 'view ' , 'edit ' ),
468- 'readonly ' => true ,
469- ),
470- 'price_suffix ' => array (
471- 'description ' => __ ( 'Price prefix, e.g. currency. ' , 'woo-gutenberg-products-block ' ),
472- 'type ' => 'string ' ,
473- 'context ' => array ( 'view ' , 'edit ' ),
474- 'readonly ' => true ,
475- ),
476- 'price ' => array (
477- 'description ' => __ ( 'Current product price. ' , 'woo-gutenberg-products-block ' ),
478- 'type ' => 'string ' ,
479- 'context ' => array ( 'view ' , 'edit ' ),
480- 'readonly ' => true ,
481- ),
482- 'regular_price ' => array (
483- 'description ' => __ ( 'Regular product price ' , 'woo-gutenberg-products-block ' ),
484- 'type ' => 'string ' ,
485- 'context ' => array ( 'view ' , 'edit ' ),
486- 'readonly ' => true ,
487- ),
488- 'sale_price ' => array (
489- 'description ' => __ ( 'Sale product price, if applicable. ' , 'woo-gutenberg-products-block ' ),
490- 'type ' => 'string ' ,
491- 'context ' => array ( 'view ' , 'edit ' ),
492- 'readonly ' => true ,
493- ),
494- 'price_range ' => array (
495- 'description ' => __ ( 'Price range, if applicable. ' , 'woo-gutenberg-products-block ' ),
496- 'type ' => 'object ' ,
497- 'context ' => array ( 'view ' , 'edit ' ),
498- 'readonly ' => true ,
499- 'items ' => array (
500- 'type ' => 'object ' ,
501- 'properties ' => array (
502- 'min_amount ' => array (
503- 'description ' => __ ( 'Price amount. ' , 'woo-gutenberg-products-block ' ),
504- 'type ' => 'string ' ,
505- 'context ' => array ( 'view ' , 'edit ' ),
506- 'readonly ' => true ,
507- ),
508- 'max_amount ' => array (
509- 'description ' => __ ( 'Price amount. ' , 'woo-gutenberg-products-block ' ),
510- 'type ' => 'string ' ,
511- 'context ' => array ( 'view ' , 'edit ' ),
512- 'readonly ' => true ,
513- ),
514- ),
515- ),
516- ),
517- ),
518- ),
519- ),
520346 'price_html ' => array (
521347 'description ' => __ ( 'Price formatted in HTML. ' , 'woo-gutenberg-products-block ' ),
522348 'type ' => 'string ' ,
0 commit comments