public static function instance() { if (is_null(self::$_instance)) { self::$_instance = new self(); } return self::$_instance; }
/** * Init WooCommerceGermanized when WordPress initializes. */ public function init() { // Before init action do_action('before_woocommerce_germanized_init'); add_filter('woocommerce_locate_template', array($this, 'filter_templates'), PHP_INT_MAX, 3); if (version_compare(WC()->version, '2.3', '<')) { add_filter('woocommerce_gzd_default_plugin_template', array($this, 'filter_templates_old_version'), 0, 2); } else { add_filter('woocommerce_gzd_important_templates', array($this, 'set_critical_templates_2_3')); if (get_option('woocommerce_gzd_display_checkout_fallback') == 'yes') { add_filter('woocommerce_gzd_template_name', array($this, 'set_review_order_fallback')); } } add_filter('woocommerce_get_settings_pages', array($this, 'add_settings')); add_filter('woocommerce_enqueue_styles', array($this, 'add_styles')); add_action('wp_enqueue_scripts', array($this, 'add_scripts')); add_action('wp_enqueue_scripts', array($this, 'add_inline_styles')); add_action('wp_print_scripts', array($this, 'localize_scripts'), 5); add_filter('woocommerce_email_classes', array($this, 'add_emails')); add_filter('woocommerce_locate_core_template', array($this, 'email_templates'), 0, 3); add_action('woocommerce_email_order_meta', array($this, 'email_small_business_notice'), 1); // Add better tax display to order totals add_filter('woocommerce_get_order_item_totals', array($this, 'order_item_totals'), 0, 2); // Unsure wether this could lead to future problems - tax classes with same name wont be merged anylonger //add_filter( 'woocommerce_rate_code', array( $this, 'prevent_tax_name_merge' ), PHP_INT_MAX, 2 ); // Adjust virtual Product Price and tax class add_filter('woocommerce_get_price_including_tax', array($this, 'set_virtual_product_price'), PHP_INT_MAX, 3); // Fallback gzd_product injection if not using wc_get_product add_filter('get_post_metadata', array($this, 'inject_gzd_product'), 0, 4); // Hide cart estimated text if chosen add_action('woocommerce_cart_totals_after_order_total', array($this, 'hide_cart_estimated_text')); add_action('woocommerce_after_cart_totals', array($this, 'remove_cart_tax_zero_filter')); // Add better WooCommerce shipping taxation add_filter('woocommerce_package_rates', array($this, 'replace_shipping_rate_class'), 0, 2); // Send order notice directly after new order is being added - use these filters because order status has to be updated already add_filter('woocommerce_payment_successful_result', array($this, 'send_order_confirmation_mails'), 0, 2); add_filter('woocommerce_checkout_no_payment_needed_redirect', array($this, 'send_order_confirmation_mails'), 0, 2); // Check for customer activation add_action('template_redirect', array($this, 'customer_account_activation_check')); add_action('woocommerce_gzd_customer_cleanup', array(WC_GZD_Admin_Customer::instance(), 'account_cleanup')); // Remove cart subtotal filter add_action('template_redirect', array($this, 'remove_cart_unit_price_filter')); add_action('woocommerce_email', array($this, 'remove_order_hooks'), 0, 1); $this->units = new WC_GZD_Units(); $this->trusted_shops = new WC_GZD_Trusted_Shops(); $this->ekomi = new WC_GZD_Ekomi(); $this->emails = new WC_GZD_Emails(); // Init action do_action('woocommerce_germanized_init'); }
/** * Init WooCommerceGermanized when WordPress initializes. */ public function init() { // Before init action do_action('before_woocommerce_germanized_init'); add_filter('woocommerce_locate_template', array($this, 'filter_templates'), PHP_INT_MAX, 3); if (version_compare(get_option('woocommerce_version'), '2.3', '<')) { add_filter('woocommerce_gzd_default_plugin_template', array($this, 'filter_templates_old_version'), 0, 2); } else { add_filter('woocommerce_gzd_important_templates', array($this, 'set_critical_templates_2_3')); if (get_option('woocommerce_gzd_display_checkout_fallback') == 'yes') { add_filter('woocommerce_germanized_filter_template', array($this, 'set_checkout_fallback'), 10, 3); } } add_filter('woocommerce_get_settings_pages', array($this, 'add_settings')); add_filter('woocommerce_enqueue_styles', array($this, 'add_styles')); // Load after WooCommerce Frontend scripts add_action('wp_enqueue_scripts', array($this, 'add_scripts'), 15); add_action('wp_enqueue_scripts', array($this, 'add_inline_styles')); add_action('wp_print_scripts', array($this, 'localize_scripts'), 5); add_filter('woocommerce_email_classes', array($this, 'add_emails')); add_filter('woocommerce_locate_core_template', array($this, 'email_templates'), 0, 3); add_action('woocommerce_email_order_meta', array($this, 'email_small_business_notice'), 1); // Add better tax display to order totals add_filter('woocommerce_get_order_item_totals', array($this, 'order_item_totals'), 0, 2); // Unsure wether this could lead to future problems - tax classes with same name wont be merged anylonger //add_filter( 'woocommerce_rate_code', array( $this, 'prevent_tax_name_merge' ), PHP_INT_MAX, 2 ); // Hide cart estimated text if chosen add_action('woocommerce_cart_totals_after_order_total', array($this, 'hide_cart_estimated_text')); add_action('woocommerce_after_cart_totals', array($this, 'remove_cart_tax_zero_filter')); // Add better WooCommerce shipping taxation add_filter('woocommerce_package_rates', array($this, 'replace_shipping_rate_class'), 0, 2); // Payment gateways add_filter('woocommerce_payment_gateways', array($this, 'register_gateways')); // Check for customer activation add_action('template_redirect', array($this, 'customer_account_activation_check')); add_action('woocommerce_gzd_customer_cleanup', array(WC_GZD_Admin_Customer::instance(), 'account_cleanup')); // Remove cart subtotal filter add_action('template_redirect', array($this, 'remove_cart_unit_price_filter')); // Let third party apps disable instant order confirmation if (apply_filters('woocommerce_gzd_instant_order_confirmation', true) && 'yes' !== get_option('woocommerce_gzd_disable_instant_order_confirmation')) { // Unregister WooCommerce default order confirmation mails $this->unregister_order_confirmation_hooks(); // Send order notice directly after new order is being added - use these filters because order status has to be updated already add_filter('woocommerce_payment_successful_result', array($this, 'send_order_confirmation_mails'), 0, 2); add_filter('woocommerce_checkout_no_payment_needed_redirect', array($this, 'send_order_confirmation_mails'), 0, 2); } $this->units = new WC_GZD_Units(); $this->emails = new WC_GZD_Emails(); // Init action do_action('woocommerce_germanized_init'); }