public function meta_box($post) { $order = wc_get_order($post); $debug_page_uri = esc_url(add_query_arg(array('page' => 'wc-status', 'tab' => 'connect'), admin_url('admin.php'))); $store_options = $this->settings_store->get_store_options(); $root_view = 'wc-connect-create-shipping-label'; $admin_array = array('purchaseURL' => get_rest_url(null, '/wc/v1/connect/label/purchase'), 'addressNormalizationURL' => get_rest_url(null, '/wc/v1/connect/normalize-address'), 'getRatesURL' => get_rest_url(null, '/wc/v1/connect/shipping-rates'), 'labelStatusURL' => get_rest_url(null, '/wc/v1/connect/label/' . $order->id . '-%d'), 'labelRefundURL' => get_rest_url(null, '/wc/v1/connect/label/' . $order->id . '-%d/refund'), 'labelsPreviewURL' => get_rest_url(null, '/wc/v1/connect/labels/preview'), 'labelsPrintURL' => get_rest_url(null, '/wc/v1/connect/labels/print'), 'paperSize' => $this->get_paper_size(), 'nonce' => wp_create_nonce('wp_rest'), 'rootView' => $root_view); $labels_data = get_post_meta($order->id, 'wc_connect_labels', true); if ($labels_data) { $admin_array['labelsData'] = json_decode($labels_data, true, WOOCOMMERCE_CONNECT_MAX_JSON_DECODE_DEPTH); } else { $store_options['countriesData'] = $this->get_states_map(); $admin_array['formData'] = $this->get_form_data($order); } $admin_array['storeOptions'] = $store_options; wp_localize_script('wc_connect_admin', 'wcConnectData', $admin_array); wp_enqueue_script('wc_connect_admin'); wp_enqueue_style('wc_connect_admin'); ?> <div class="wc-connect-admin-container" id="<?php echo esc_attr($root_view); ?> "> <span class="form-troubles" style="opacity: 0"> <?php printf(__('Shipping labels not loading? Visit the <a href="%s">status page</a> for troubleshooting steps.', 'connectforwoocommerce'), $debug_page_uri); ?> </span> </div> <?php }
public function output_packages_screen() { $debug_page_uri = esc_url(add_query_arg(array('page' => 'wc-status', 'tab' => 'connect'), admin_url('admin.php'))); $store_options = $this->service_settings_store->get_store_options(); $root_view = 'wc-connect-packages'; $admin_array = array('storeOptions' => $store_options, 'formSchema' => $this->get_packages_form_schema(), 'formData' => $this->get_packages_form_data(), 'callbackURL' => get_rest_url(null, '/wc/v1/connect/packages'), 'nonce' => wp_create_nonce('wp_rest'), 'submitMethod' => 'POST', 'rootView' => $root_view); wp_localize_script('wc_connect_admin', 'wcConnectData', $admin_array); wp_enqueue_script('wc_connect_admin'); wp_enqueue_style('wc_connect_admin'); // hiding the save button because the react container has its own global $hide_save_button; $hide_save_button = true; ?> <div class="wc-connect-admin-container" id="<?php echo esc_attr($root_view); ?> "> <span class="form-troubles" style="opacity: 0"> <?php printf(__('Settings not loading? Visit the <a href="%s">status page</a> for troubleshooting steps.', 'connectforwoocommerce'), $debug_page_uri); ?> </span> </div> <?php }
/** * Localizes the bootstrap, enqueues the script and styles for the help page */ public function page() { $this->help_sections = array(); $this->add_fieldset('health', _x('Health', 'This section displays the overall health of Connect for WooCommerce and the things it depends on', 'connectforwoocommerce'), $this->get_health_items()); $this->add_fieldset('services', __('Services', 'connectforwoocommerce'), $this->get_services_items()); $this->add_fieldset('debug', __('Debug', 'connectforwoocommerce'), $this->get_debug_items()); $this->add_fieldset('support', __('Support', 'connectforwoocommerce'), $this->get_support_items()); $root_view = 'wc-connect-admin-help'; $admin_array = array('storeOptions' => $this->service_settings_store->get_store_options(), 'formSchema' => $this->get_form_schema(), 'formLayout' => $this->get_form_layout(), 'formData' => $this->get_form_data(), 'predefinedPackages' => array(), 'callbackURL' => get_rest_url(null, "/wc/v1/connect/self-help"), 'nonce' => wp_create_nonce('wp_rest'), 'rootView' => $root_view); wp_localize_script('wc_connect_admin', 'wcConnectData', $admin_array); wp_enqueue_script('wc_connect_admin'); wp_enqueue_style('wc_connect_admin'); ?> <h2> <?php _e('Connect for WooCommerce Status', 'woocommerce'); ?> </h2> <div class="wc-connect-admin-container" id="<?php echo esc_attr($root_view); ?> "></div> <?php }