Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/woocomme.../src/Blocks/Template...
File: CheckoutTemplate.php
<?php
[0] Fix | Delete
namespace Automattic\WooCommerce\Blocks\Templates;
[1] Fix | Delete
[2] Fix | Delete
/**
[3] Fix | Delete
* CheckoutTemplate class.
[4] Fix | Delete
*
[5] Fix | Delete
* @internal
[6] Fix | Delete
*/
[7] Fix | Delete
class CheckoutTemplate extends AbstractPageTemplate {
[8] Fix | Delete
[9] Fix | Delete
/**
[10] Fix | Delete
* The slug of the template.
[11] Fix | Delete
*
[12] Fix | Delete
* @var string
[13] Fix | Delete
*/
[14] Fix | Delete
const SLUG = 'page-checkout';
[15] Fix | Delete
[16] Fix | Delete
/**
[17] Fix | Delete
* Returns the title of the template.
[18] Fix | Delete
*
[19] Fix | Delete
* @return string
[20] Fix | Delete
*/
[21] Fix | Delete
public function get_template_title() {
[22] Fix | Delete
return _x( 'Page: Checkout', 'Template name', 'woocommerce' );
[23] Fix | Delete
}
[24] Fix | Delete
[25] Fix | Delete
/**
[26] Fix | Delete
* Returns the description of the template.
[27] Fix | Delete
*
[28] Fix | Delete
* @return string
[29] Fix | Delete
*/
[30] Fix | Delete
public function get_template_description() {
[31] Fix | Delete
return __( 'The Checkout template guides users through the final steps of the purchase process. It enables users to enter shipping and billing information, select a payment method, and review order details.', 'woocommerce' );
[32] Fix | Delete
}
[33] Fix | Delete
[34] Fix | Delete
/**
[35] Fix | Delete
* Returns the page object assigned to this template/page.
[36] Fix | Delete
*
[37] Fix | Delete
* @return \WP_Post|null Post object or null.
[38] Fix | Delete
*/
[39] Fix | Delete
protected function get_placeholder_page() {
[40] Fix | Delete
$page_id = wc_get_page_id( 'checkout' );
[41] Fix | Delete
return $page_id ? get_post( $page_id ) : null;
[42] Fix | Delete
}
[43] Fix | Delete
[44] Fix | Delete
/**
[45] Fix | Delete
* True when viewing the checkout page or checkout endpoint.
[46] Fix | Delete
*
[47] Fix | Delete
* @return boolean
[48] Fix | Delete
*/
[49] Fix | Delete
protected function is_active_template() {
[50] Fix | Delete
global $post;
[51] Fix | Delete
$placeholder = $this->get_placeholder_page();
[52] Fix | Delete
return null !== $placeholder && $post instanceof \WP_Post && $placeholder->post_name === $post->post_name;
[53] Fix | Delete
}
[54] Fix | Delete
[55] Fix | Delete
/**
[56] Fix | Delete
* When the page should be displaying the template, add it to the hierarchy.
[57] Fix | Delete
*
[58] Fix | Delete
* This places the template name e.g. `cart`, at the beginning of the template hierarchy array. The hook priority
[59] Fix | Delete
* is 1 to ensure it runs first; other consumers e.g. extensions, could therefore inject their own template instead
[60] Fix | Delete
* of this one when using the default priority of 10.
[61] Fix | Delete
*
[62] Fix | Delete
* @param array $templates Templates that match the pages_template_hierarchy.
[63] Fix | Delete
*/
[64] Fix | Delete
public function page_template_hierarchy( $templates ) {
[65] Fix | Delete
if ( $this->is_active_template() ) {
[66] Fix | Delete
array_unshift( $templates, self::SLUG );
[67] Fix | Delete
array_unshift( $templates, 'checkout' );
[68] Fix | Delete
}
[69] Fix | Delete
return $templates;
[70] Fix | Delete
}
[71] Fix | Delete
}
[72] Fix | Delete
[73] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function