Saphali Woocommerce Russian - Version 1.8.6

Version Description

  • Fix WC 3.x.
Download this release

Release Info

Developer Saphali
Plugin Icon wp plugin Saphali Woocommerce Russian
Version 1.8.6
Comparing to
See all releases

Code changes from version 1.8.5 to 1.8.6

Files changed (2) hide show
  1. readme.txt +5 -2
  2. saphali-woocommerce-lite.php +69 -8
readme.txt CHANGED
@@ -5,8 +5,8 @@ Plugin URI: http://saphali.com/saphali-woocommerce-plugin-wordpress
5
  Donate link: https://money.yandex.ru/to/410011651211340
6
  Tags: woocommerce, woo commerce russian, russian ruble, ukrainian hryvnia, mod, manadger filds checkout
7
  Requires at least: WP 3.3 or higher & WooCommerce 1.6.6 or higher
8
- Tested up to: 5.0
9
- Stable tag: 1.8.5
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
@@ -76,6 +76,9 @@ define('SAPHALI_LITE_SYMBOL', 0 );
76
 
77
  == Changelog ==
78
 
 
 
 
79
  = 1.8.5 =
80
  * Fix при работе с плагином bookly-addon-pro
81
 
5
  Donate link: https://money.yandex.ru/to/410011651211340
6
  Tags: woocommerce, woo commerce russian, russian ruble, ukrainian hryvnia, mod, manadger filds checkout
7
  Requires at least: WP 3.3 or higher & WooCommerce 1.6.6 or higher
8
+ Tested up to: 5.3
9
+ Stable tag: 1.8.6
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
76
 
77
  == Changelog ==
78
 
79
+ = 1.8.6 =
80
+ * Fix вывод добавленных плагином полей в письмах для WC 3.x.
81
+
82
  = 1.8.5 =
83
  * Fix при работе с плагином bookly-addon-pro
84
 
saphali-woocommerce-lite.php CHANGED
@@ -3,13 +3,13 @@
3
  Plugin Name: Saphali Woocommerce Russian
4
  Plugin URI: http://saphali.com/saphali-woocommerce-plugin-wordpress
5
  Description: Saphali Woocommerce Russian - это бесплатный вордпресс плагин, который добавляет набор дополнений к интернет-магазину на Woocommerce.
6
- Version: 1.8.5
7
  Author: Saphali
8
  Author URI: http://saphali.com/
9
  Text Domain: saphali-woocommerce-lite
10
  Domain Path: /languages
11
  WC requires at least: 1.6.6
12
- WC tested up to: 3.5
13
  */
14
 
15
 
@@ -35,7 +35,7 @@ WC tested up to: 3.5
35
 
36
  // Подключение валюты и локализации
37
  define('SAPHALI_PLUGIN_DIR_URL',plugin_dir_url(__FILE__));
38
- define('SAPHALI_LITE_VERSION', '1.8.5' );
39
  define('SAPHALI_PLUGIN_DIR_PATH',plugin_dir_path(__FILE__));
40
  class saphali_lite {
41
  var $email_order_id;
@@ -53,7 +53,7 @@ WC tested up to: 3.5
53
  add_action( 'woocommerce_thankyou', array( $this, 'order_pickup_location' ), 20 );
54
  add_action( 'woocommerce_view_order', array( $this, 'order_pickup_location' ), 20 );
55
 
56
- add_action( 'woocommerce_after_template_part', array( $this, 'email_pickup_location' ), 10, 3 );
57
 
58
  // add_action( 'woocommerce_admin_order_totals_after_shipping', array( $this, 'woocommerce_admin_order_totals_after_shipping' ), 1 );
59
  add_action( 'woocommerce_order_status_pending_to_processing_notification', array( $this, 'store_order_id' ), 1 );
@@ -99,6 +99,7 @@ WC tested up to: 3.5
99
  add_filter( 'woocommerce_admin_billing_fields', array($this,'woocommerce_admin_billing_fields'), 10, 1 );
100
  add_filter( 'woocommerce_admin_shipping_fields', array($this,'woocommerce_admin_shipping_fields'), 10, 1 );
101
  }
 
102
  add_action("wp_footer", array($this,'print_script_payment_method') );
103
  if( version_compare( WOOCOMMERCE_VERSION, '3.0.0', '<' ) )
104
  add_action( 'woocommerce_after_checkout_validation', array( $this, 'after_checkout_validation' ), 10 );
@@ -150,6 +151,57 @@ WC tested up to: 3.5
150
  }
151
  return $is_e;
152
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
153
  public function after_checkout_validation( $data, $errors = array() ) {
154
  if(! isset($this->fieldss) )
155
  $this->fieldss = get_option('woocommerce_saphali_filds_filters');
@@ -194,6 +246,10 @@ WC tested up to: 3.5
194
  }
195
  $is_e = false;
196
  foreach($keys as $key => $value) {
 
 
 
 
197
  if( $value["r"] ) {
198
  if(in_array($_POST['payment_method'], $value["pm"]) ) {
199
  if( empty($_POST[$key])) {
@@ -223,7 +279,7 @@ WC tested up to: 3.5
223
  $is_e = $this->remove_no_valid_filds($key, $value, $errors);
224
  }
225
  }
226
- $s_m = in_array($_POST['shipping_method'], $value["pm"]) || in_array($_POST['shipping_method'][0], $value["pm"]) || in_array( preg_replace('/\:(.*)$/', '', $_POST['shipping_method'][0]), $value["pm"]);
227
  if( $s_m ) {
228
  if( empty($_POST[$key])) {
229
  $is_e = $this->remove_no_valid_filds($key, $value, $errors);
@@ -764,7 +820,8 @@ WC tested up to: 3.5
764
  $filds["billing"] = array_merge($filds["billing"] , $_POST["billing"], $addFild["billing"]);
765
 
766
  foreach($filds["billing"] as $key_post => $value_post) {
767
-
 
768
  if( !isset($global_f_checkout_fields["billing"][$key_post]['type']) && (isset($filds["billing"][$key_post]['type']) && $filds["billing"][$key_post]['type'] != 'select' && $filds["billing"][$key_post]['type'] != 'checkbox' && $filds["billing"][$key_post]['type'] != 'textarea' || !isset($filds["billing"][$key_post]['type'])) ) unset($filds["billing"][$key_post]['type'], $value_post["type"]);
769
 
770
 
@@ -791,7 +848,7 @@ WC tested up to: 3.5
791
  if(!is_array($_POST["shipping"])) $_POST["shipping"] = array();
792
  $filds["shipping"] = array_merge($filds["shipping"] , $_POST["shipping"], $addFild["shipping"]);
793
  foreach($filds["shipping"] as $key_post => $value_post) {
794
-
795
  if( !isset($global_f_checkout_fields["shipping"][$key_post]['type']) ) unset($filds["shipping"][$key_post]['type'], $value_post["type"]);
796
 
797
  if( isset($filds["shipping"][$key_post]['public']) && $filds["shipping"][$key_post]['public'] != 'on') {
@@ -1749,8 +1806,12 @@ WC tested up to: 3.5
1749
  if ( is_int( $arg ) ) $this->email_order_id = $arg;
1750
  elseif ( is_array( $arg ) && array_key_exists( 'order_id', $arg ) ) $this->email_order_id = $arg['order_id'];
1751
  }
1752
- public function email_pickup_location( $template_name, $template_path, $located ) {
1753
  global $_shipping_data, $_billing_data;
 
 
 
 
1754
  if ( $template_name == 'emails/email-addresses.php' && $this->email_order_id ) {
1755
 
1756
  $order = new WC_Order( $this->email_order_id );
3
  Plugin Name: Saphali Woocommerce Russian
4
  Plugin URI: http://saphali.com/saphali-woocommerce-plugin-wordpress
5
  Description: Saphali Woocommerce Russian - это бесплатный вордпресс плагин, который добавляет набор дополнений к интернет-магазину на Woocommerce.
6
+ Version: 1.8.6
7
  Author: Saphali
8
  Author URI: http://saphali.com/
9
  Text Domain: saphali-woocommerce-lite
10
  Domain Path: /languages
11
  WC requires at least: 1.6.6
12
+ WC tested up to: 3.8
13
  */
14
 
15
 
35
 
36
  // Подключение валюты и локализации
37
  define('SAPHALI_PLUGIN_DIR_URL',plugin_dir_url(__FILE__));
38
+ define('SAPHALI_LITE_VERSION', '1.8.6' );
39
  define('SAPHALI_PLUGIN_DIR_PATH',plugin_dir_path(__FILE__));
40
  class saphali_lite {
41
  var $email_order_id;
53
  add_action( 'woocommerce_thankyou', array( $this, 'order_pickup_location' ), 20 );
54
  add_action( 'woocommerce_view_order', array( $this, 'order_pickup_location' ), 20 );
55
 
56
+ add_action( 'woocommerce_after_template_part', array( $this, 'email_pickup_location' ), 10, 4 );
57
 
58
  // add_action( 'woocommerce_admin_order_totals_after_shipping', array( $this, 'woocommerce_admin_order_totals_after_shipping' ), 1 );
59
  add_action( 'woocommerce_order_status_pending_to_processing_notification', array( $this, 'store_order_id' ), 1 );
99
  add_filter( 'woocommerce_admin_billing_fields', array($this,'woocommerce_admin_billing_fields'), 10, 1 );
100
  add_filter( 'woocommerce_admin_shipping_fields', array($this,'woocommerce_admin_shipping_fields'), 10, 1 );
101
  }
102
+ add_filter( 'woocommerce_checkout_posted_data', array($this,'woocommerce_checkout_posted_data'), 10, 1 );
103
  add_action("wp_footer", array($this,'print_script_payment_method') );
104
  if( version_compare( WOOCOMMERCE_VERSION, '3.0.0', '<' ) )
105
  add_action( 'woocommerce_after_checkout_validation', array( $this, 'after_checkout_validation' ), 10 );
151
  }
152
  return $is_e;
153
  }
154
+ public function woocommerce_checkout_posted_data( $data ) {
155
+ if(! isset($this->fieldss) )
156
+ $this->fieldss = get_option('woocommerce_saphali_filds_filters');
157
+ $fieldss = $this->fieldss;
158
+ $keys = array();
159
+ if( !version_compare( WOOCOMMERCE_VERSION, '2.1.0', '<' ) && isset($_POST['ship_to_different_address']) || version_compare( WOOCOMMERCE_VERSION, '2.1.0', '<' ) && !isset($_POST['shiptobilling']) ) {
160
+ $fieldss____ = array('billing', 'shipping');
161
+ } else $fieldss____ = array('billing');
162
+ foreach($fieldss____ as $type) {
163
+ foreach($fieldss[$type] as $key => $value) {
164
+ if(isset($value['payment_method'])) {
165
+ $pm_k_remove = array();
166
+ foreach($value['payment_method'] as $k => $v) {
167
+ if($v === '0') {
168
+ $pm_k_remove[] = $k;
169
+ }
170
+ }
171
+ foreach($pm_k_remove as $k_remove) {
172
+ unset($value['payment_method'][$k_remove]);
173
+ }
174
+ }
175
+ if(isset($value['payment_method']) && !empty($value['payment_method'])) {
176
+ $r = ( isset($value["required"]) && $value["required"] );
177
+ $keys[ $key ] = array( 'pm' => $value['payment_method'], 'r' => $r, 'rf' => $value["label"], 'type' => $type );
178
+ }
179
+ if(isset($value['shipping_method'])) {
180
+ $pm_k_remove = array();
181
+ foreach($value['shipping_method'] as $k => $v) {
182
+ if($v === '0') {
183
+ $pm_k_remove[] = $k;
184
+ }
185
+ }
186
+ foreach($pm_k_remove as $k_remove) {
187
+ unset($value['shipping_method'][$k_remove]);
188
+ }
189
+ }
190
+ if(isset($value['shipping_method']) && !empty($value['shipping_method'])) {
191
+ $r = ( isset($value["required"]) && $value["required"] );
192
+ $keys[ $key ] = array( 'pm' => $value['shipping_method'], 'r' => $r, 'rf' => $value["label"], 'type' => $type );
193
+ }
194
+ }
195
+ }
196
+
197
+ foreach($keys as $key => $value) {
198
+ $s_m= in_array($_POST['shipping_method'], $value["pm"]) || in_array($_POST['shipping_method'][0], $value["pm"]) || in_array( preg_replace('/\:(.*)$/', '', $_POST['shipping_method'][0]), $value["pm"]);
199
+ if( !( in_array($_POST['payment_method'], $value["pm"]) || $s_m ) ) {
200
+ unset( $data[$key] );
201
+ }
202
+ }
203
+ return $data;
204
+ }
205
  public function after_checkout_validation( $data, $errors = array() ) {
206
  if(! isset($this->fieldss) )
207
  $this->fieldss = get_option('woocommerce_saphali_filds_filters');
246
  }
247
  $is_e = false;
248
  foreach($keys as $key => $value) {
249
+ $s_m = in_array($_POST['shipping_method'], $value["pm"]) || in_array($_POST['shipping_method'][0], $value["pm"]) || in_array( preg_replace('/\:(.*)$/', '', $_POST['shipping_method'][0]), $value["pm"]);
250
+ if( !( in_array($_POST['payment_method'], $value["pm"]) || $s_m ) ) {
251
+ unset( $_POST[$key] );
252
+ }
253
  if( $value["r"] ) {
254
  if(in_array($_POST['payment_method'], $value["pm"]) ) {
255
  if( empty($_POST[$key])) {
279
  $is_e = $this->remove_no_valid_filds($key, $value, $errors);
280
  }
281
  }
282
+
283
  if( $s_m ) {
284
  if( empty($_POST[$key])) {
285
  $is_e = $this->remove_no_valid_filds($key, $value, $errors);
820
  $filds["billing"] = array_merge($filds["billing"] , $_POST["billing"], $addFild["billing"]);
821
 
822
  foreach($filds["billing"] as $key_post => $value_post) {
823
+ $filds["billing"][$key_post]["label"] = str_replace("'", '&rsquo;', stripcslashes($filds["billing"][$key_post]["label"]) );
824
+ $value_post["label"] = str_replace("'", '&rsquo;', stripcslashes($value_post["label"]) );
825
  if( !isset($global_f_checkout_fields["billing"][$key_post]['type']) && (isset($filds["billing"][$key_post]['type']) && $filds["billing"][$key_post]['type'] != 'select' && $filds["billing"][$key_post]['type'] != 'checkbox' && $filds["billing"][$key_post]['type'] != 'textarea' || !isset($filds["billing"][$key_post]['type'])) ) unset($filds["billing"][$key_post]['type'], $value_post["type"]);
826
 
827
 
848
  if(!is_array($_POST["shipping"])) $_POST["shipping"] = array();
849
  $filds["shipping"] = array_merge($filds["shipping"] , $_POST["shipping"], $addFild["shipping"]);
850
  foreach($filds["shipping"] as $key_post => $value_post) {
851
+ $value_post["label"] = str_replace("'", '&rsquo;', stripcslashes($value_post["label"]) );
852
  if( !isset($global_f_checkout_fields["shipping"][$key_post]['type']) ) unset($filds["shipping"][$key_post]['type'], $value_post["type"]);
853
 
854
  if( isset($filds["shipping"][$key_post]['public']) && $filds["shipping"][$key_post]['public'] != 'on') {
1806
  if ( is_int( $arg ) ) $this->email_order_id = $arg;
1807
  elseif ( is_array( $arg ) && array_key_exists( 'order_id', $arg ) ) $this->email_order_id = $arg['order_id'];
1808
  }
1809
+ public function email_pickup_location( $template_name, $template_path, $located, $args = array() ) {
1810
  global $_shipping_data, $_billing_data;
1811
+ if($template_name == 'emails/email-addresses.php' && isset($args["order"]) && is_object($args["order"]) ) {
1812
+ $this->email_order_id = $args["order"]->get_id();
1813
+ }
1814
+
1815
  if ( $template_name == 'emails/email-addresses.php' && $this->email_order_id ) {
1816
 
1817
  $order = new WC_Order( $this->email_order_id );