Anton | настройка checkout
This commit is contained in:
@@ -228,6 +228,29 @@ function twentytwentyfour_test1_template( $template ) {
|
||||
}
|
||||
add_filter( 'template_include', 'twentytwentyfour_test1_template' );
|
||||
|
||||
/**
|
||||
* Use a standalone PHP template for the WooCommerce checkout page.
|
||||
*
|
||||
* @since Twenty Twenty-Four 1.0
|
||||
*
|
||||
* @param string $template Resolved template path.
|
||||
* @return string
|
||||
*/
|
||||
function twentytwentyfour_checkout_template( $template ) {
|
||||
if ( ! function_exists( 'is_checkout' ) || ! is_checkout() || is_order_received_page() ) {
|
||||
return $template;
|
||||
}
|
||||
|
||||
$custom_template = get_theme_file_path( 'page-checkout.php' );
|
||||
|
||||
if ( file_exists( $custom_template ) ) {
|
||||
return $custom_template;
|
||||
}
|
||||
|
||||
return $template;
|
||||
}
|
||||
add_filter( 'template_include', 'twentytwentyfour_checkout_template', 20 );
|
||||
|
||||
/**
|
||||
* Enqueue standalone landing assets for the page slug "test1".
|
||||
*
|
||||
@@ -235,17 +258,22 @@ add_filter( 'template_include', 'twentytwentyfour_test1_template' );
|
||||
* @return void
|
||||
*/
|
||||
function twentytwentyfour_test1_assets() {
|
||||
if ( ! is_page( 'test1' ) ) {
|
||||
$use_test1_assets = is_page( 'test1' ) || ( function_exists( 'is_checkout' ) && is_checkout() && ! is_order_received_page() );
|
||||
|
||||
if ( ! $use_test1_assets ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$css_file = ABSPATH . 'index3.css';
|
||||
$js_file = ABSPATH . 'index3.js';
|
||||
$checkout_css_file = get_theme_file_path( 'assets/css/test1-checkout.css' );
|
||||
|
||||
wp_dequeue_style( 'global-styles' );
|
||||
wp_dequeue_style( 'wp-block-library' );
|
||||
wp_dequeue_style( 'wp-block-library-theme' );
|
||||
wp_dequeue_style( 'classic-theme-styles' );
|
||||
if ( is_page( 'test1' ) ) {
|
||||
wp_dequeue_style( 'global-styles' );
|
||||
wp_dequeue_style( 'wp-block-library' );
|
||||
wp_dequeue_style( 'wp-block-library-theme' );
|
||||
wp_dequeue_style( 'classic-theme-styles' );
|
||||
}
|
||||
|
||||
wp_enqueue_style(
|
||||
'twentytwentyfour-test1-fonts',
|
||||
@@ -263,7 +291,7 @@ function twentytwentyfour_test1_assets() {
|
||||
);
|
||||
}
|
||||
|
||||
if ( file_exists( $js_file ) ) {
|
||||
if ( is_page( 'test1' ) && file_exists( $js_file ) ) {
|
||||
wp_enqueue_script(
|
||||
'twentytwentyfour-test1-script',
|
||||
home_url( '/index3.js' ),
|
||||
@@ -271,6 +299,26 @@ function twentytwentyfour_test1_assets() {
|
||||
(string) filemtime( $js_file ),
|
||||
true
|
||||
);
|
||||
|
||||
if ( class_exists( 'WooCommerce' ) ) {
|
||||
wp_localize_script(
|
||||
'twentytwentyfour-test1-script',
|
||||
'test1WooCommerce',
|
||||
array(
|
||||
'addToCartUrl' => WC_AJAX::get_endpoint( 'add_to_cart' ),
|
||||
'checkoutUrl' => wc_get_checkout_url(),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ( function_exists( 'is_checkout' ) && is_checkout() && ! is_order_received_page() && file_exists( $checkout_css_file ) ) {
|
||||
wp_enqueue_style(
|
||||
'twentytwentyfour-test1-checkout-style',
|
||||
get_theme_file_uri( 'assets/css/test1-checkout.css' ),
|
||||
array( 'twentytwentyfour-test1-style' ),
|
||||
(string) filemtime( $checkout_css_file )
|
||||
);
|
||||
}
|
||||
}
|
||||
add_action( 'wp_enqueue_scripts', 'twentytwentyfour_test1_assets', 100 );
|
||||
|
||||
Reference in New Issue
Block a user