Automattic\WooCommerce\Blocks

Migration::wc_blocks_update_1120_rename_cart_template()public staticWC 1.0

Rename cart template to page-cart.

Method of the class: Migration{}

No Hooks.

Return

null. Nothing (null).

Usage

$result = Migration::wc_blocks_update_1120_rename_cart_template();

Migration::wc_blocks_update_1120_rename_cart_template() code WC 8.9.0

public static function wc_blocks_update_1120_rename_cart_template() {
	$template = get_block_template( BlockTemplateUtils::PLUGIN_SLUG . '//cart', '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-cart',
			)
		);
	}
}