WC_Admin_Setup_Wizard::shipping_method_selection_form
Deprecated since 4.6.0. It is no longer supported and may be removed in future releases. It is recommended to replace this function with the same one.
Render the available shipping methods for a given country code.
Method of the class: WC_Admin_Setup_Wizard{}
No Hooks.
Returns
null. Nothing (null).
Usage
// protected - for code of main (parent) or child class $result = $this->shipping_method_selection_form( $country_code, $currency_code, $input_prefix );
- $country_code(string) (required)
- Country code.
- $currency_code(string) (required)
- Currency code.
- $input_prefix(string) (required)
- Input prefix.
Changelog
| Deprecated since | 4.6.0 |
WC_Admin_Setup_Wizard::shipping_method_selection_form() WC Admin Setup Wizard::shipping method selection form code WC 10.8.1
<?php
protected function shipping_method_selection_form( $country_code, $currency_code, $input_prefix ) {
_deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
$selected = 'flat_rate';
$shipping_methods = $this->get_wizard_shipping_methods( $country_code, $currency_code );
?>
<div class="wc-wizard-shipping-method-select">
<div class="wc-wizard-shipping-method-dropdown">
<select
id="<?php echo esc_attr( "{$input_prefix}[method]" ); ?>"
name="<?php echo esc_attr( "{$input_prefix}[method]" ); ?>"
class="method wc-enhanced-select"
data-plugins="<?php echo wc_esc_json( wp_json_encode( $this->get_wcs_requisite_plugins() ) ); ?>"
>
<?php foreach ( $shipping_methods as $method_id => $method ) : ?>
<option value="<?php echo esc_attr( $method_id ); ?>" <?php selected( $selected, $method_id ); ?>><?php echo esc_html( $method['name'] ); ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="shipping-method-descriptions">
<?php foreach ( $shipping_methods as $method_id => $method ) : ?>
<p class="shipping-method-description <?php echo esc_attr( $method_id ); ?> <?php echo $method_id !== $selected ? 'hide' : ''; ?>">
<?php echo esc_html( $method['description'] ); ?>
</p>
<?php endforeach; ?>
</div>
</div>
<div class="shipping-method-settings">
<?php foreach ( $shipping_methods as $method_id => $method ) : ?>
<?php
if ( empty( $method['settings'] ) ) {
continue;
}
?>
<div class="shipping-method-setting <?php echo esc_attr( $method_id ); ?> <?php echo $method_id !== $selected ? 'hide' : ''; ?>">
<?php foreach ( $method['settings'] as $setting_id => $setting ) : ?>
<?php $method_setting_id = "{$input_prefix}[{$method_id}][{$setting_id}]"; ?>
<input
type="<?php echo esc_attr( $setting['type'] ); ?>"
placeholder="<?php echo esc_attr( $setting['default_value'] ); ?>"
id="<?php echo esc_attr( $method_setting_id ); ?>"
name="<?php echo esc_attr( $method_setting_id ); ?>"
class="<?php echo esc_attr( $setting['required'] ? 'shipping-method-required-field' : '' ); ?>"
<?php echo ( $method_id === $selected && $setting['required'] ) ? 'required' : ''; ?>
/>
<p class="description">
<?php echo esc_html( $setting['description'] ); ?>
</p>
<?php endforeach; ?>
</div>
<?php endforeach; ?>
</div>
<?php
}