Template_Compatibility::override_page_template( string $template, string $type, array $templates )

Summary

If a theme has a page template that assumes WooCommerce functions will be available (e.g., a page-cart.php), remove that template from the hierarchy.


Parameters

$template

(string) (Required)

$type

(string) (Required)

$templates

(array) (Required)


Return

(string)


Source

File: src/BigCommerce/Compatibility/Template_Compatibility.php

	public function override_page_template( $template, $type, $templates ) {
		while ( ! empty( $templates ) && ! empty( $template ) ) {
			$template_contents = file_get_contents( $template );
			// covers wc_get_template(), wc_get_template_part(), and wc_get_template_html()
			if ( strpos( $template_contents, 'wc_get_template' ) === false ) {
				break;
			}
			array_shift( $templates );
			$template = locate_template( $templates );
		}

		return $template;
	}

User Contributed Notes

You must log in before being able to contribute a note or feedback.