Automattic\WooCommerce\Blocks

Migration::wc_blocks_update_1120_rename_checkout_template()public staticWC 1.0

Rename checkout template to page-checkout.

Method of the class: Migration{}

No Hooks.

Return

null. Nothing (null).

Usage

$result = Migration::wc_blocks_update_1120_rename_checkout_template();

Migration::wc_blocks_update_1120_rename_checkout_template() code WC 9.4.2

public static function wc_blocks_update_1120_rename_checkout_template() {
	$template = get_block_template( BlockTemplateUtils::PLUGIN_SLUG . '//checkout', 'wp_template' );

	if ( $template && ! empty( $template->wp_id ) ) {
		if ( ! defined( 'WP_POST_REVISIONS' ) ) {
			// This prevents a fatal error when ran outside of admin context.
			define( 'WP_POST_REVISIONS', false );
		}
		wp_update_post(
			array(
				'ID'        => $template->wp_id,
				'post_name' => 'page-checkout',
			)
		);
	}
}