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 4.7.6 4.7.7 4.7.8 4.7.9 4.8.0 4.9.0 4.9.1 5.0.1 5.0.2 5.1.1 5.1.2 5.1.3 5.2.0 5.2.1 5.3.2 5.3.3.1 5.3.4 5.3.5 5.3.6 5.3.7
woocommerce-multilingual / inc / class-wcml-cart-sync-warnings.php
woocommerce-multilingual / inc Last commit date
admin-menus 2 weeks ago currencies 2 weeks ago template-classes 2 weeks ago translation-editor 2 weeks ago class-wcml-ajax-setup.php 2 weeks ago class-wcml-attributes.php 2 weeks ago class-wcml-capabilities.php 2 weeks ago class-wcml-cart-removed-items-widget.php 1 year ago class-wcml-cart-switch-lang-functions.php 2 weeks ago class-wcml-cart-sync-warnings.php 2 weeks ago class-wcml-cart.php 2 weeks ago class-wcml-comments.php 2 weeks ago class-wcml-compatibility.php 2 weeks ago class-wcml-coupons.php 2 weeks ago class-wcml-dependencies.php 2 weeks ago class-wcml-emails.php 2 weeks ago class-wcml-endpoints.php 2 weeks ago class-wcml-install.php 2 weeks ago class-wcml-languages-upgrader.php 2 weeks ago class-wcml-locale.php 2 weeks ago class-wcml-orders.php 2 weeks ago class-wcml-products-screen-options.php 2 weeks ago class-wcml-products.php 2 weeks ago class-wcml-reports.php 2 weeks ago class-wcml-requests.php 2 weeks ago class-wcml-resources.php 2 weeks ago class-wcml-store-pages.php 2 weeks ago class-wcml-terms.php 2 weeks ago class-wcml-tp-support.php 2 weeks ago class-wcml-troubleshooting.php 2 weeks ago class-wcml-upgrade.php 2 weeks ago class-wcml-url-translation.php 2 weeks ago class-wcml-wc-gateways.php 2 weeks ago class-wcml-wc-shipping.php 2 weeks ago class-wcml-wc-strings.php 2 weeks ago class-wcml-widgets.php 2 weeks ago constants.php 2 weeks ago functions-pure.php 2 weeks ago functions.php 2 weeks ago installer-loader.php 2 weeks ago missing-php-functions.php 2 weeks ago wcml-core-functions.php 2 weeks ago wcml-switch-lang-request.php 2 weeks ago
class-wcml-cart-sync-warnings.php
120 lines
1 <?php
2
3 class WCML_Cart_Sync_Warnings {
4
5 const KEY_DISMISS = 'dismiss_cart_warning';
6
7 private $woocommerce_wpml;
8 private $sitepress;
9 private $extensions_list = [
10 'WC_Subscriptions' => 'Woocommerce Subscriptions',
11 'WC_Product_Addons' => 'Woocommerce Product Addons',
12 'WC_Bookings' => 'Woocommerce Bookings',
13 'WC_Accommodation_Bookings_Plugin' => 'Woocommerce Accommodation Bookings',
14 'WC_Product_Bundle' => 'Woocommerce Product Bundles',
15 'WC_Composite_Products' => 'Woocommerce Composite Products',
16 'RP_WCDPD' => 'WooCommerce Dynamic Pricing & Discounts',
17 ];
18
19 public function __construct( $woocommerce_wpml, $sitepress ) {
20 $this->woocommerce_wpml = $woocommerce_wpml;
21 $this->sitepress = $sitepress;
22 }
23
24 public function add_hooks() {
25
26 if ( $this->check_if_show_notices_needed() ) {
27 add_action( 'admin_notices', [ $this, 'show_cart_notice' ] );
28 add_action( 'admin_enqueue_scripts', [ $this, 'register_styles' ] );
29 }
30
31 add_action( 'admin_init', [ $this, 'handle_dismiss_cart_notice' ] );
32 }
33
34 public function check_if_show_notices_needed() {
35
36 $cart_sync_settings = $this->woocommerce_wpml->settings['cart_sync'];
37
38 if (
39 (
40 $cart_sync_settings['lang_switch'] === $this->sitepress->get_wp_api()->constant( 'WCML_CART_SYNC' ) ||
41 $cart_sync_settings['currency_switch'] === $this->sitepress->get_wp_api()->constant( 'WCML_CART_SYNC' )
42 ) &&
43 ! $this->woocommerce_wpml->settings[self::KEY_DISMISS] &&
44 $this->get_list_of_active_extensions()
45 ) {
46 return true;
47 }
48
49 return false;
50
51 }
52
53 public function register_styles() {
54 wp_enqueue_style( 'wcml-cart-warning', $this->sitepress->get_wp_api()->constant( 'WCML_PLUGIN_URL' ) . '/res/css/wcml-cart-warning.css' );
55 }
56
57 public function show_cart_notice() {
58 $list_of_extensions = $this->get_list_of_active_extensions();
59 $request_url = esc_url( $_SERVER['REQUEST_URI'] );
60
61 $admin_settings_url = esc_url( \WCML\Utilities\AdminUrl::getSettingsTab() . '#cart' );
62 $documentation_link = esc_url( WCML_Tracking_Link::getWcmlClearCartDoc() );
63
64 $reset_cart_strings[] = esc_html_x( 'Because of some elements in your site configuration, when the users switch the currency or the language on the front end, the cart content might not be synchronized correctly.', 'Reset cart option warning 1', 'woocommerce-multilingual' );
65 /* translators: %s is link to "reset cart configuration" */
66 $reset_cart_strings[] = esc_html_x( 'It is recommended that you %s with the option to reset the cart in a situation like this.', 'Reset cart option warning 2', 'woocommerce-multilingual' );
67
68 $reset_cart_configure_link = '<strong><a href="' . $admin_settings_url . '">' . esc_html__( 'configure WPML Multilingual & Multicurrency for WooCommerce', 'woocommerce-multilingual' ) . '</a></strong>';
69
70 $reset_cart_message = $reset_cart_strings[0];
71 $reset_cart_message .= '</p>';
72 $reset_cart_message .= $list_of_extensions;
73 $reset_cart_message .= '<p>';
74 $reset_cart_message .= $reset_cart_strings[1];
75 $reset_cart_message .= '<strong><a href="' . $documentation_link . '" target="_blank">' . esc_html__( 'More details', 'woocommerce-multilingual' ) . '</a></strong>';
76
77 $message = '<div class="message error otgs-is-dismissible">';
78 $message .= '<p>';
79 $message .= sprintf( $reset_cart_message, $reset_cart_configure_link );
80 $message .= '</p>';
81 $message .= '<a class="notice-dismiss" href="' . esc_url( add_query_arg( 'wcml_action', self::KEY_DISMISS, $request_url ) ) . '"><span class="screen-reader-text">' . esc_html__( 'Dismiss', 'woocommerce-multilingual' ) . '</span></a>';
82 $message .= '</div>';
83
84 echo $message;
85 }
86
87 public function get_list_of_active_extensions() {
88
89 $html = '';
90
91 foreach ( $this->extensions_list as $extension_class => $display_name ) {
92
93 if ( class_exists( $extension_class ) ) {
94
95 if ( empty( $html ) ) {
96 $html .= '<ul>';
97 }
98
99 $html .= '<li>' . $display_name . '</li>';
100
101 }
102 }
103
104 if ( ! empty( $html ) ) {
105 $html .= '</ul>';
106 }
107
108 return $html;
109
110 }
111
112 public function handle_dismiss_cart_notice() {
113 if ( isset( $_GET['wcml_action'] ) && $_GET['wcml_action'] === self::KEY_DISMISS ) {
114 $this->woocommerce_wpml->settings[self::KEY_DISMISS] = true;
115 $this->woocommerce_wpml->update_settings();
116 wcml_safe_redirect( remove_query_arg( 'wcml_action' ) );
117 }
118 }
119 }
120