@@ -342,19 +342,24 @@ function wgpb_print_script_settings() {
342342 $ code = get_woocommerce_currency ();
343343
344344 // Settings and variables can be passed here for access in the app.
345+ // Will need `wcAdminAssetUrl` if the ImageAsset component is used.
346+ // Will need `dataEndpoints.countries` if Search component is used with 'country' type.
347+ // Will need `orderStatuses` if the OrderStatus component is used.
348+ // Deliberately excluding: `embedBreadcrumbs`, `trackingEnabled`.
345349 $ settings = array (
346- 'adminUrl ' => admin_url (),
347- 'wcAssetUrl ' => plugins_url ( 'assets/ ' , WC_PLUGIN_FILE ),
348- 'siteLocale ' => esc_attr ( get_bloginfo ( 'language ' ) ),
349- 'currency ' => array (
350+ 'adminUrl ' => admin_url (),
351+ 'wcAssetUrl ' => plugins_url ( 'assets/ ' , WC_PLUGIN_FILE ),
352+ 'siteLocale ' => esc_attr ( get_bloginfo ( 'language ' ) ),
353+ 'currency ' => array (
350354 'code ' => $ code ,
351355 'precision ' => wc_get_price_decimals (),
352356 'symbol ' => get_woocommerce_currency_symbol ( $ code ),
357+ 'position ' => get_option ( 'woocommerce_currency_pos ' ),
353358 ),
354- 'date ' => array (
355- ' dow ' => get_option ( 'start_of_week ' , 0 ),
356- ),
357- 'l10n ' => array (
359+ 'stockStatuses ' => wc_get_product_stock_status_options (),
360+ ' siteTitle ' => get_bloginfo ( 'name ' ),
361+ ' dataEndpoints ' => array ( ),
362+ 'l10n ' => array (
358363 'userLocale ' => get_user_locale (),
359364 'weekdaysShort ' => array_values ( $ wp_locale ->weekday_abbrev ),
360365 ),
@@ -371,7 +376,8 @@ function wgpb_print_script_settings() {
371376 );
372377 ?>
373378 <script type="text/javascript">
374- var wcSettings = <?php echo wp_json_encode ( $ settings ); ?> ;
379+ <?php // Use the wcSettings from wc-admin if already present. ?>
380+ var wcSettings = wcSettings || <?php echo wp_json_encode ( $ settings ); ?> ;
375381 var wc_product_block_data = <?php echo wp_json_encode ( $ block_settings ); ?> ;
376382 </script>
377383 <?php
0 commit comments