Automattic\WooCommerce\Internal\Admin

ShippingLabelBanner::add_print_shipping_label_script()publicWC 1.0

Adds JS to order page to render shipping banner.

Метод класса: ShippingLabelBanner{}

No Hooks.

Return

null. Nothing.

Usage

$ShippingLabelBanner = new ShippingLabelBanner();
$ShippingLabelBanner->add_print_shipping_label_script( $hook );
$hook(string) (required)
current page hook.

Code of ShippingLabelBanner::add_print_shipping_label_script() WC 7.1.0

public function add_print_shipping_label_script( $hook ) {
	$rtl = is_rtl() ? '.rtl' : '';
	wp_enqueue_style(
		'print-shipping-label-banner-style',
		WCAdminAssets::get_url( "print-shipping-label-banner/style{$rtl}", 'css' ),
		array( 'wp-components' ),
		WCAdminAssets::get_file_version( 'css' )
	);

	WCAdminAssets::register_script( 'wp-admin-scripts', 'print-shipping-label-banner', true );

	$payload = array(
		'nonce'                 => wp_create_nonce( 'wp_rest' ),
		'baseURL'               => get_rest_url(),
		'wcs_server_connection' => true,
	);

	wp_localize_script( 'print-shipping-label-banner', 'wcConnectData', $payload );
}