Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/woocomme.../src/Blocks/Domain/Services
File: functions.php
<?php
[0] Fix | Delete
[1] Fix | Delete
use Automattic\WooCommerce\Blocks\Package;
[2] Fix | Delete
use Automattic\WooCommerce\Blocks\Domain\Services\CheckoutFields;
[3] Fix | Delete
[4] Fix | Delete
if ( ! function_exists( 'woocommerce_register_additional_checkout_field' ) ) {
[5] Fix | Delete
/**
[6] Fix | Delete
* Register a checkout field.
[7] Fix | Delete
*
[8] Fix | Delete
* @param array $options Field arguments. See CheckoutFields::register_checkout_field() for details.
[9] Fix | Delete
* @throws \Exception If field registration fails.
[10] Fix | Delete
*/
[11] Fix | Delete
function woocommerce_register_additional_checkout_field( $options ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore,PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore
[12] Fix | Delete
[13] Fix | Delete
// Check if `woocommerce_blocks_loaded` ran. If not then the CheckoutFields class will not be available yet.
[14] Fix | Delete
// In that case, re-hook `woocommerce_blocks_loaded` and try running this again.
[15] Fix | Delete
$woocommerce_blocks_loaded_ran = did_action( 'woocommerce_blocks_loaded' );
[16] Fix | Delete
if ( ! $woocommerce_blocks_loaded_ran ) {
[17] Fix | Delete
add_action(
[18] Fix | Delete
'woocommerce_blocks_loaded',
[19] Fix | Delete
function () use ( $options ) {
[20] Fix | Delete
woocommerce_register_additional_checkout_field( $options );
[21] Fix | Delete
}
[22] Fix | Delete
);
[23] Fix | Delete
return;
[24] Fix | Delete
}
[25] Fix | Delete
$checkout_fields = Package::container()->get( CheckoutFields::class );
[26] Fix | Delete
$result = $checkout_fields->register_checkout_field( $options );
[27] Fix | Delete
if ( is_wp_error( $result ) ) {
[28] Fix | Delete
throw new \Exception( esc_attr( $result->get_error_message() ) );
[29] Fix | Delete
}
[30] Fix | Delete
}
[31] Fix | Delete
}
[32] Fix | Delete
[33] Fix | Delete
if ( ! function_exists( '__experimental_woocommerce_blocks_register_checkout_field' ) ) {
[34] Fix | Delete
[35] Fix | Delete
/**
[36] Fix | Delete
* Register a checkout field.
[37] Fix | Delete
*
[38] Fix | Delete
* @param array $options Field arguments. See CheckoutFields::register_checkout_field() for details.
[39] Fix | Delete
* @throws \Exception If field registration fails.
[40] Fix | Delete
* @deprecated 5.6.0 Use woocommerce_register_additional_checkout_field() instead.
[41] Fix | Delete
*/
[42] Fix | Delete
function __experimental_woocommerce_blocks_register_checkout_field( $options ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore,PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore
[43] Fix | Delete
wc_deprecated_function( __FUNCTION__, '8.9.0', 'woocommerce_register_additional_checkout_field' );
[44] Fix | Delete
woocommerce_register_additional_checkout_field( $options );
[45] Fix | Delete
}
[46] Fix | Delete
}
[47] Fix | Delete
[48] Fix | Delete
if ( ! function_exists( '__internal_woocommerce_blocks_deregister_checkout_field' ) ) {
[49] Fix | Delete
/**
[50] Fix | Delete
* Deregister a checkout field.
[51] Fix | Delete
*
[52] Fix | Delete
* @param string $field_id Field ID.
[53] Fix | Delete
* @throws \Exception If field deregistration fails.
[54] Fix | Delete
* @internal
[55] Fix | Delete
*/
[56] Fix | Delete
function __internal_woocommerce_blocks_deregister_checkout_field( $field_id ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore,PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore
[57] Fix | Delete
$checkout_fields = Package::container()->get( CheckoutFields::class );
[58] Fix | Delete
$result = $checkout_fields->deregister_checkout_field( $field_id );
[59] Fix | Delete
if ( is_wp_error( $result ) ) {
[60] Fix | Delete
throw new \Exception( esc_attr( $result->get_error_message() ) );
[61] Fix | Delete
}
[62] Fix | Delete
}
[63] Fix | Delete
}
[64] Fix | Delete
[65] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function