правки checkout cart
This commit is contained in:
@@ -228,52 +228,6 @@ 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 );
|
||||
|
||||
/**
|
||||
* Use a standalone PHP template for the WooCommerce cart page.
|
||||
*
|
||||
* @since Twenty Twenty-Four 1.0
|
||||
*
|
||||
* @param string $template Resolved template path.
|
||||
* @return string
|
||||
*/
|
||||
function twentytwentyfour_cart_template( $template ) {
|
||||
if ( ! function_exists( 'is_cart' ) || ! is_cart() ) {
|
||||
return $template;
|
||||
}
|
||||
|
||||
$custom_template = get_theme_file_path( 'page-cart.php' );
|
||||
|
||||
if ( file_exists( $custom_template ) ) {
|
||||
return $custom_template;
|
||||
}
|
||||
|
||||
return $template;
|
||||
}
|
||||
add_filter( 'template_include', 'twentytwentyfour_cart_template', 20 );
|
||||
|
||||
/**
|
||||
* Enqueue standalone landing assets for the page slug "test1".
|
||||
*
|
||||
@@ -281,9 +235,7 @@ add_filter( 'template_include', 'twentytwentyfour_cart_template', 20 );
|
||||
* @return void
|
||||
*/
|
||||
function twentytwentyfour_test1_assets() {
|
||||
$use_test1_assets = is_page( 'test1' )
|
||||
|| ( function_exists( 'is_checkout' ) && is_checkout() && ! is_order_received_page() )
|
||||
|| ( function_exists( 'is_cart' ) && is_cart() );
|
||||
$use_test1_assets = is_page( 'test1' );
|
||||
|
||||
if ( ! $use_test1_assets ) {
|
||||
return;
|
||||
@@ -291,8 +243,6 @@ function twentytwentyfour_test1_assets() {
|
||||
|
||||
$css_file = ABSPATH . 'index3.css';
|
||||
$js_file = ABSPATH . 'index3.js';
|
||||
$checkout_css_file = get_theme_file_path( 'assets/css/test1-checkout.css' );
|
||||
$checkout_js_file = get_theme_file_path( 'assets/js/test1-checkout.js' );
|
||||
|
||||
if ( is_page( 'test1' ) ) {
|
||||
wp_dequeue_style( 'global-styles' );
|
||||
@@ -339,33 +289,6 @@ function twentytwentyfour_test1_assets() {
|
||||
}
|
||||
}
|
||||
|
||||
if ( ( ( function_exists( 'is_checkout' ) && is_checkout() && ! is_order_received_page() ) || ( function_exists( 'is_cart' ) && is_cart() ) ) && 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 )
|
||||
);
|
||||
}
|
||||
|
||||
if ( ( ( function_exists( 'is_checkout' ) && is_checkout() && ! is_order_received_page() ) || ( function_exists( 'is_cart' ) && is_cart() ) ) && file_exists( $checkout_js_file ) ) {
|
||||
wp_enqueue_script(
|
||||
'twentytwentyfour-test1-checkout-script',
|
||||
get_theme_file_uri( 'assets/js/test1-checkout.js' ),
|
||||
array(),
|
||||
(string) filemtime( $checkout_js_file ),
|
||||
true
|
||||
);
|
||||
|
||||
wp_localize_script(
|
||||
'twentytwentyfour-test1-checkout-script',
|
||||
'test1CheckoutData',
|
||||
array(
|
||||
'freeShippingThreshold' => twentytwentyfour_water_delivery_free_shipping_threshold(),
|
||||
'catalogUrl' => home_url( '/test1/#catalog' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
add_action( 'wp_enqueue_scripts', 'twentytwentyfour_test1_assets', 100 );
|
||||
|
||||
@@ -548,7 +471,6 @@ function twentytwentyfour_water_delivery_checkout_fields( $fields ) {
|
||||
|
||||
return $fields;
|
||||
}
|
||||
add_filter( 'woocommerce_checkout_fields', 'twentytwentyfour_water_delivery_checkout_fields' );
|
||||
|
||||
/**
|
||||
* Store bottle exchange choice in session during checkout refresh.
|
||||
@@ -563,7 +485,6 @@ function twentytwentyfour_water_delivery_update_order_review( $posted_data ) {
|
||||
WC()->session->set( 'tw_bottle_exchange', sanitize_text_field( wp_unslash( $data['tw_bottle_exchange'] ) ) );
|
||||
}
|
||||
}
|
||||
add_action( 'woocommerce_checkout_update_order_review', 'twentytwentyfour_water_delivery_update_order_review' );
|
||||
|
||||
/**
|
||||
* Add deposit fee if there is no bottle exchange.
|
||||
@@ -586,7 +507,6 @@ function twentytwentyfour_water_delivery_add_fees( $cart ) {
|
||||
$cart->add_fee( __( 'Залог за тару', 'twentytwentyfour' ), twentytwentyfour_water_delivery_deposit_fee(), false );
|
||||
}
|
||||
}
|
||||
add_action( 'woocommerce_cart_calculate_fees', 'twentytwentyfour_water_delivery_add_fees' );
|
||||
|
||||
/**
|
||||
* Validate custom checkout data.
|
||||
@@ -604,7 +524,6 @@ function twentytwentyfour_water_delivery_validate_checkout() {
|
||||
wc_add_notice( __( 'Укажите корректный телефон для подтверждения заказа.', 'twentytwentyfour' ), 'error' );
|
||||
}
|
||||
}
|
||||
add_action( 'woocommerce_checkout_process', 'twentytwentyfour_water_delivery_validate_checkout' );
|
||||
|
||||
/**
|
||||
* Save custom checkout fields to order meta.
|
||||
@@ -628,7 +547,6 @@ function twentytwentyfour_water_delivery_save_checkout_meta( $order_id ) {
|
||||
}
|
||||
}
|
||||
}
|
||||
add_action( 'woocommerce_checkout_update_order_meta', 'twentytwentyfour_water_delivery_save_checkout_meta' );
|
||||
|
||||
/**
|
||||
* Add cart helper panel before the cart table.
|
||||
@@ -665,7 +583,6 @@ function twentytwentyfour_water_delivery_before_cart() {
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
add_action( 'woocommerce_before_cart', 'twentytwentyfour_water_delivery_before_cart', 5 );
|
||||
|
||||
/**
|
||||
* Rename default cross-sells heading for water delivery cart.
|
||||
@@ -676,9 +593,7 @@ add_action( 'woocommerce_before_cart', 'twentytwentyfour_water_delivery_before_c
|
||||
function twentytwentyfour_water_delivery_cross_sells_heading( $heading ) {
|
||||
return __( 'Добавьте к заказу помпы, стаканы и оборудование', 'twentytwentyfour' );
|
||||
}
|
||||
add_filter( 'woocommerce_product_cross_sells_products_heading', 'twentytwentyfour_water_delivery_cross_sells_heading' );
|
||||
|
||||
add_filter( 'woocommerce_cart_totals_order_total_html', 'twentytwentyfour_water_delivery_cart_totals_order_total_html' );
|
||||
|
||||
/**
|
||||
* Preserve Woo total html while allowing custom wrapper styling.
|
||||
@@ -707,7 +622,6 @@ function twentytwentyfour_water_delivery_before_cart_totals() {
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
add_action( 'woocommerce_before_cart_totals', 'twentytwentyfour_water_delivery_before_cart_totals', 5 );
|
||||
|
||||
/**
|
||||
* Add SEO content after the cart.
|
||||
@@ -722,7 +636,6 @@ function twentytwentyfour_water_delivery_after_cart() {
|
||||
</section>
|
||||
<?php
|
||||
}
|
||||
add_action( 'woocommerce_after_cart', 'twentytwentyfour_water_delivery_after_cart', 15 );
|
||||
|
||||
/**
|
||||
* Add order CTA hints before submit button.
|
||||
@@ -741,7 +654,6 @@ function twentytwentyfour_water_delivery_before_submit() {
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
add_action( 'woocommerce_review_order_before_submit', 'twentytwentyfour_water_delivery_before_submit', 5 );
|
||||
|
||||
/**
|
||||
* Customize the empty cart message.
|
||||
@@ -751,7 +663,6 @@ add_action( 'woocommerce_review_order_before_submit', 'twentytwentyfour_water_de
|
||||
function twentytwentyfour_water_delivery_empty_cart_message() {
|
||||
return __( 'Корзина пока пуста. Перейдите в каталог и выберите воду 19 литров, питьевую воду или дополнительные товары для доставки по Севастополю.', 'twentytwentyfour' );
|
||||
}
|
||||
add_filter( 'wc_empty_cart_message', 'twentytwentyfour_water_delivery_empty_cart_message' );
|
||||
|
||||
/**
|
||||
* Add custom CTA below empty cart message.
|
||||
@@ -766,7 +677,6 @@ function twentytwentyfour_water_delivery_empty_cart_cta() {
|
||||
<div class="water-empty-cart-cta"><a class="button" href="<?php echo esc_url( home_url( '/test1/#catalog' ) ); ?>"><?php esc_html_e( 'Перейти в каталог', 'twentytwentyfour' ); ?></a></div>
|
||||
<?php
|
||||
}
|
||||
add_action( 'woocommerce_cart_is_empty', 'twentytwentyfour_water_delivery_empty_cart_cta', 20 );
|
||||
|
||||
/**
|
||||
* Customize page title for cart and checkout if no SEO plugin is active.
|
||||
@@ -789,7 +699,6 @@ function twentytwentyfour_water_delivery_document_title( $title ) {
|
||||
|
||||
return $title;
|
||||
}
|
||||
add_filter( 'pre_get_document_title', 'twentytwentyfour_water_delivery_document_title' );
|
||||
|
||||
/**
|
||||
* Add fallback meta description and schema for cart/checkout.
|
||||
@@ -847,4 +756,3 @@ function twentytwentyfour_water_delivery_meta_and_schema() {
|
||||
<script type="application/ld+json"><?php echo wp_json_encode( $schema, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES ); ?></script>
|
||||
<?php
|
||||
}
|
||||
add_action( 'wp_head', 'twentytwentyfour_water_delivery_meta_and_schema', 5 );
|
||||
|
||||
Reference in New Issue
Block a user