archive.php
7 months ago
base-content.php
2 years ago
base.php
1 year ago
cart.php
7 months ago
checkout.php
7 months ago
shop.php
4 years ago
single.php
7 months ago
cart.php
93 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 | // Dequeue Facebook Pixel script if active |
| 31 | add_action('wp_enqueue_scripts', function () { |
| 32 | if(is_plugin_active('pixelyoursite/facebook-pixel-master.php')) { |
| 33 | |
| 34 | wp_dequeue_script('pys'); |
| 35 | } |
| 36 | |
| 37 | $themeName = get_template(); |
| 38 | if ($themeName == 'phlox-pro') { |
| 39 | |
| 40 | wp_dequeue_style('auxin-elementor-base'); |
| 41 | } |
| 42 | |
| 43 | }, 20); |
| 44 | } |
| 45 | |
| 46 | public function delayed_hook_conflicts() { |
| 47 | |
| 48 | $themeName = get_template(); |
| 49 | |
| 50 | if ( $themeName == 'porto' ) { |
| 51 | remove_action( 'woocommerce_after_cart', 'woocommerce_cross_sell_display', 20 ); |
| 52 | } |
| 53 | |
| 54 | |
| 55 | if( $themeName == 'woostify' ) { |
| 56 | remove_action( 'woocommerce_after_cart', 'woocommerce_cross_sell_display' ); |
| 57 | remove_filter( 'woocommerce_cross_sells_columns', 'woostify_cross_sell_display_columns' ); |
| 58 | } |
| 59 | |
| 60 | // revert this hook for cart page and editor mode |
| 61 | if ( $themeName == 'flatsome' || $themeName == 'hestia' ) { |
| 62 | add_action( 'woocommerce_cart_collaterals', 'woocommerce_cross_sell_display' ); |
| 63 | remove_action( 'woocommerce_after_cart', 'woocommerce_cross_sell_display' ); |
| 64 | } |
| 65 | |
| 66 | if ( is_plugin_active( 'auxin-shop/auxin-shop.php' ) ) { |
| 67 | |
| 68 | remove_filter('wc_get_template', 'auxshp_get_wc_template', 11, 2); |
| 69 | |
| 70 | // Remove Auxin Shop template loader filter |
| 71 | global $wp_filter; |
| 72 | if (isset($wp_filter['woocommerce_locate_template'])) { |
| 73 | foreach ($wp_filter['woocommerce_locate_template']->callbacks as $priority => $callbacks) { |
| 74 | foreach ($callbacks as $key => $callback) { |
| 75 | if (is_array($callback['function']) && |
| 76 | is_object($callback['function'][0]) && |
| 77 | get_class($callback['function'][0]) === 'AUXSHP_Template_Loader' && |
| 78 | $callback['function'][1] === 'load_templates') { |
| 79 | unset($wp_filter['woocommerce_locate_template']->callbacks[$priority][$key]); |
| 80 | } |
| 81 | } |
| 82 | } |
| 83 | } |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | protected function template_include_pre_condition(): bool { |
| 88 | //phpcs:ignore WordPress.Security.NonceVerification.Recommended -- It's a fronted user part, not possible to verify nonce here |
| 89 | return (is_cart() || (isset($_REQUEST['wc-ajax']) && $_REQUEST['wc-ajax'] == 'update_shipping_method')); |
| 90 | } |
| 91 | |
| 92 | } |
| 93 |