archive.php
2 years ago
base-content.php
2 years ago
base.php
3 years ago
cart.php
2 years ago
checkout.php
2 years ago
shop.php
4 years ago
single.php
2 years ago
cart.php
52 lines
| 1 | <?php |
| 2 | |
| 3 | namespace ShopEngine\Core\Page_Templates\Hooks; |
| 4 | |
| 5 | defined('ABSPATH') || exit; |
| 6 | |
| 7 | use ShopEngine\Core\Builders\Templates; |
| 8 | use ShopEngine\Utils\Shipping_Calculation; |
| 9 | |
| 10 | class Cart extends Base { |
| 11 | |
| 12 | protected $page_type = 'cart'; |
| 13 | protected $template_part = 'content-cart.php'; |
| 14 | |
| 15 | public function init() : void { |
| 16 | |
| 17 | add_action('woocommerce_shipping_init', function () { |
| 18 | \ShopEngine\Widgets\Widget_Helper::instance()->wc_template_filter(); |
| 19 | }); |
| 20 | |
| 21 | add_action('template_redirect', function () { |
| 22 | Shipping_Calculation::output(); |
| 23 | }); |
| 24 | |
| 25 | // add_action('wp_loaded', [$this, 'delayed_hook_conflicts'], 9999); |
| 26 | $this->delayed_hook_conflicts(); |
| 27 | |
| 28 | do_action( 'woocommerce_check_cart_items' ); |
| 29 | } |
| 30 | |
| 31 | public function delayed_hook_conflicts() { |
| 32 | |
| 33 | $themeName = get_template(); |
| 34 | |
| 35 | if ( $themeName == 'porto' ) { |
| 36 | remove_action( 'woocommerce_after_cart', 'woocommerce_cross_sell_display', 20 ); |
| 37 | } |
| 38 | |
| 39 | // revert this hook for cart page and editor mode |
| 40 | if ( $themeName == 'flatsome' || $themeName == 'hestia' ) { |
| 41 | add_action( 'woocommerce_cart_collaterals', 'woocommerce_cross_sell_display' ); |
| 42 | remove_action( 'woocommerce_after_cart', 'woocommerce_cross_sell_display' ); |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | protected function template_include_pre_condition(): bool { |
| 47 | //phpcs:ignore WordPress.Security.NonceVerification.Recommended -- It's a fronted user part, not possible to verify nonce here |
| 48 | return (is_cart() || (isset($_REQUEST['wc-ajax']) && $_REQUEST['wc-ajax'] == 'update_shipping_method')); |
| 49 | } |
| 50 | |
| 51 | } |
| 52 |