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.

Returns

null. Nothing (null).

Usage

$result = Migration::wc_blocks_update_1120_rename_cart_template();

Migration::wc_blocks_update_1120_rename_cart_template() code WC 9.8.4

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',
			)
		);
	}
}