]> _ Git - physioassist-de.git/commitdiff
Remove redundant WooCommerce references. Wait #5342 @0.25
authorStephen Cameron <stephen@cubedesigners.com>
Tue, 23 Aug 2022 11:35:43 +0000 (13:35 +0200)
committerStephen Cameron <stephen@cubedesigners.com>
Tue, 23 Aug 2022 11:35:43 +0000 (13:35 +0200)
wp-content/mu-plugins/physioassist/src/Init.php
wp-content/mu-plugins/physioassist/src/WooCommerce/Setup.php [deleted file]

index 7eec85bd591a2fadfcf7767bb58c9666a07866f8..37fadc17cc8f218da48d6cb2a474211495714baa 100644 (file)
@@ -15,7 +15,6 @@ final class Init { // Marked as final because this class should never be extende
         return [
             Common\Setup::class,
             Elementor\Setup::class,
-            WooCommerce\Setup::class,
             CookieNotice\Setup::class,
         ];
     }
diff --git a/wp-content/mu-plugins/physioassist/src/WooCommerce/Setup.php b/wp-content/mu-plugins/physioassist/src/WooCommerce/Setup.php
deleted file mode 100644 (file)
index 4f9715b..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-<?php
-
-namespace PhysioAssist\Woocommerce;
-
-use function App\template;
-
-class Setup {
-
-    /**
-     * Woocommerce overrides
-     */
-    public function register() {
-        // Customise Woocommerce via hooks once it has loaded
-        add_action('woocommerce_loaded', [$this, 'on_woocommerce_loaded']);
-    }
-
-    public function on_woocommerce_loaded() {
-
-        // Add WooCommerce mini-cart to the main nav (primary_navigation)
-        add_filter('wp_nav_menu_items', [$this, 'woocommerce_cart_menu'], 10, 2);
-
-        // Update mini-cart link count on AJAX updates
-        add_filter('woocommerce_add_to_cart_fragments', [$this, 'woocommerce_add_to_cart_fragment']);
-
-        // Remove content wrappers
-        remove_action('woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10);
-        remove_action('woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10);
-
-        // Remove product sorting dropdowns
-        // Ref: https://rudrastyh.com/woocommerce/remove-product-sorting-dropdown.html
-        remove_action('woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30);
-
-        // Remove product count
-        remove_action('woocommerce_before_shop_loop', 'woocommerce_result_count', 20);
-
-        // Replace add to cart button with icon
-        //add_filter('woocommerce_loop_add_to_cart_link', [$this, 'add_to_cart_button'], 10, 3);
-
-        // Change number of columns on shop page
-        add_filter('loop_shop_columns', function() { return 3; }, 999);
-
-        // Replace remove cart item "x" with custom icon
-        add_filter('woocommerce_cart_item_remove_link', [$this, 'cart_remove_link'], 10, 2);
-
-        // Remove product single page meta (Category)
-        remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40);
-
-        // Remove the H2 heading "Description" above the product description (it already has a tab heading)
-        // This could also return a different heading text if desired
-        // Ref: https://rudrastyh.com/woocommerce/rename-product-tabs-and-heading.html#change-description-heading
-        add_filter('woocommerce_product_description_heading', '__return_false');
-
-        // Also disable the headings in custom tabs
-        add_filter('yikes_woocommerce_custom_repeatable_product_tabs_heading', '__return_false');
-
-        // Add Newsletter subscription checkbox to checkout
-        add_action('woocommerce_review_order_before_submit', [$this, 'newsletter_checkbox']);
-        // Save Newsletter checkbox
-        add_action('woocommerce_checkout_update_order_meta', [$this, 'newsletter_checkbox_process']);
-    }
-
-    public function woocommerce_cart_menu($menu, $args) {
-
-        // The shop is only available on the French version of the site so we need to check this
-        $isFrench = apply_filters('wpml_current_language', NULL) === 'fr';
-
-        // Only continue if woocommerce mini cart is available and we're on the primary_navigation menu
-        if (!function_exists('woocommerce_mini_cart')
-            //|| WC()->cart->cart_contents_count < 1
-            || !$isFrench
-            || $args->theme_location !== 'primary_navigation') {
-            return $menu;
-        }
-
-        $menu .= template('woocommerce/mini-cart');
-
-        return $menu;
-    }
-
-    public function woocommerce_add_to_cart_fragment($fragments) {
-        // Re-run and populate updated cart link template
-        $fragments['a.menu-cart-link'] = template('woocommerce/mini-cart-link');
-
-        return $fragments;
-    }
-
-    public function add_to_cart_button($html, $product, $args) {
-        if ($product->is_purchasable() && !$product->is_sold_individually() && $product->is_in_stock() && 'variable' != $product->get_type() && 'bundle' != $product->get_type()) {
-
-            return sprintf(
-                '<a href="%s" data-quantity="%s" class="%s" %s>%s</a>',
-                esc_url( $product->add_to_cart_url() ),
-                esc_attr( isset( $args['quantity'] ) ? $args['quantity'] : 1 ),
-                //esc_attr( isset( $args['class'] ) ? $args['class'] : 'button' ),
-                'add_to_cart_button ajax_add_to_cart', // WooCommerce CSS is a mess so just add these for the JS to hook
-                isset( $args['attributes'] ) ? wc_implode_html_attributes( $args['attributes'] ) : '',
-                \BladeSvgSage\svg_image('icons/cart-add')->toHtml()
-            );
-
-            //return '<button>'. \BladeSvgSage\svg_image('icons/cart')->toHtml() .'</button><pre>'. print_r($args, true) .'</pre>';
-        }
-
-        return $html;
-    }
-
-
-    public function cart_remove_link($html, $cart_item_key) {
-
-        // Instead of trying to recreate the full HTML link with all the attributes, it's easier
-        // to replace the part we don't want: the &times; with the SVG icon
-        $icon = \BladeSvgSage\svg_image('icons/poubelle')->toHtml();
-
-        return str_replace('&times;', $icon, $html);
-
-    }
-
-    public function newsletter_checkbox() {
-        woocommerce_form_field('newsletter_subscribe', array(
-            'type' => 'checkbox',
-            'class' => [],
-            'label' => __('Je souhaite recevoir la newsletter et les offres de PhysioAssist'),
-            'required' => false,
-            'default' => 1, // Pre-check the checkbox
-        ), WC()->checkout->get_value('newsletter_subscribe'));
-    }
-
-    public function newsletter_checkbox_process($order_ID) {
-
-        $newsletter = (isset($_POST['newsletter_subscribe']) && $_POST['newsletter_subscribe'] == 1) ? __('Oui') : __('Non');
-
-        update_post_meta($order_ID, 'Newsletter', $newsletter);
-
-        // ToDo: send an e-mail notifying when there is a new subscriber
-        if ($newsletter === __('Oui')) {
-            // ADDRESS: $_POST['billing_email']
-        }
-
-    }
-
-}