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
* Initialization method.
[18] Fix | Delete
*/
[19] Fix | Delete
public function init() {
[20] Fix | Delete
parent::init();
[21] Fix | Delete
[22] Fix | Delete
add_action( 'template_redirect', array( $this, 'render_block_template' ) );
[23] Fix | Delete
}
[24] Fix | Delete
[25] Fix | Delete
/**
[26] Fix | Delete
* Returns the title of the template.
[27] Fix | Delete
*
[28] Fix | Delete
* @return string
[29] Fix | Delete
*/
[30] Fix | Delete
public function get_template_title() {
[31] Fix | Delete
return _x( 'Page: Checkout', 'Template name', 'woocommerce' );
[32] Fix | Delete
}
[33] Fix | Delete
[34] Fix | Delete
/**
[35] Fix | Delete
* Returns the description of the template.
[36] Fix | Delete
*
[37] Fix | Delete
* @return string
[38] Fix | Delete
*/
[39] Fix | Delete
public function get_template_description() {
[40] 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' );
[41] Fix | Delete
}
[42] Fix | Delete
[43] Fix | Delete
/**
[44] Fix | Delete
* Renders the default block template from Woo Blocks if no theme templates exist.
[45] Fix | Delete
*/
[46] Fix | Delete
public function render_block_template() {
[47] Fix | Delete
if (
[48] Fix | Delete
! is_embed() && is_checkout()
[49] Fix | Delete
) {
[50] Fix | Delete
add_filter( 'woocommerce_has_block_template', '__return_true', 10, 0 );
[51] Fix | Delete
}
[52] Fix | Delete
}
[53] Fix | Delete
[54] Fix | Delete
/**
[55] Fix | Delete
* Returns the page object assigned to this template/page.
[56] Fix | Delete
*
[57] Fix | Delete
* @return \WP_Post|null Post object or null.
[58] Fix | Delete
*/
[59] Fix | Delete
protected function get_placeholder_page() {
[60] Fix | Delete
$page_id = wc_get_page_id( 'checkout' );
[61] Fix | Delete
return $page_id ? get_post( $page_id ) : null;
[62] Fix | Delete
}
[63] Fix | Delete
[64] Fix | Delete
/**
[65] Fix | Delete
* True when viewing the checkout page or checkout endpoint.
[66] Fix | Delete
*
[67] Fix | Delete
* @return boolean
[68] Fix | Delete
*/
[69] Fix | Delete
protected function is_active_template() {
[70] Fix | Delete
global $post;
[71] Fix | Delete
$placeholder = $this->get_placeholder_page();
[72] Fix | Delete
return null !== $placeholder && $post instanceof \WP_Post && $placeholder->post_name === $post->post_name;
[73] Fix | Delete
}
[74] Fix | Delete
[75] Fix | Delete
/**
[76] Fix | Delete
* When the page should be displaying the template, add it to the hierarchy.
[77] Fix | Delete
*
[78] Fix | Delete
* This places the template name e.g. `cart`, at the beginning of the template hierarchy array. The hook priority
[79] Fix | Delete
* is 1 to ensure it runs first; other consumers e.g. extensions, could therefore inject their own template instead
[80] Fix | Delete
* of this one when using the default priority of 10.
[81] Fix | Delete
*
[82] Fix | Delete
* @param array $templates Templates that match the pages_template_hierarchy.
[83] Fix | Delete
*/
[84] Fix | Delete
public function page_template_hierarchy( $templates ) {
[85] Fix | Delete
if ( $this->is_active_template() ) {
[86] Fix | Delete
array_unshift( $templates, self::SLUG );
[87] Fix | Delete
array_unshift( $templates, 'checkout' );
[88] Fix | Delete
}
[89] Fix | Delete
return $templates;
[90] Fix | Delete
}
[91] Fix | Delete
}
[92] Fix | Delete
[93] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function