The question is not simple.

It concerns the settings of the payment system in the online store woocommerce . The problem is this: the php variable (email address) is transferred to the script for some reason, encoded.

To get started, I get these email fields entered by the user. Using var_dump, I check that the variable contains correct information (email o4137889@nwytg.net ), but when the variable is passed inside the script

accountId: '<?=$order->billing_email?>'

I get this coded string in utf-8 accountId: '&#x6f;4&#x31;&#x33;7&#x38;&#x38;9&#x40;&#x6e;w&#x79;&#x74;g&#x2e;&#x6e;e&#x74;' ,

Moreover, it doesn’t matter whether it is output via abbreviated <?= ?> Or <?php ?> And echo

accountId: '<?php echo $billing_email ?>' ,

, through a variable or directly - the result is identical each time.

What can it be connected with and how to fix it?

 global $woocommerce; $order = new WC_Order( $order_id ); var_dump($order->billing_email); //o4137889@nwytg.net <script src="https://widget.cloudpayments.ru/bundles/cloudpayments"></script> <script> var widget = new cp.CloudPayments(); widget.<?=$widget_f?>({ // options <!-- /////////////??????????????? --> publicId: '<?=$this->public_id?>', //id ΠΈΠ· Π»ΠΈΡ‡Π½ΠΎΠ³ΠΎ ΠΊΠ°Π±ΠΈΠ½Π΅Ρ‚Π° description: 'ΠžΠΏΠ»Π°Ρ‚Π° Π·Π°ΠΊΠ°Π·Π° <?=$order_id?>', //Π½Π°Π·Π½Π°Ρ‡Π΅Π½ΠΈΠ΅ amount: <?=$order->get_total()?>, //сумма currency: '<?=$this->currency?>', //Π²Π°Π»ΡŽΡ‚Π° invoiceId: <?=$order_id?>, //Π½ΠΎΠΌΠ΅Ρ€ Π·Π°ΠΊΠ°Π·Π° accountId: '<?=$order->billing_email?>', //ΠΈΠ΄Π΅Π½Ρ‚ΠΈΡ„ΠΈΠΊΠ°Ρ‚ΠΎΡ€ ΠΏΠ»Π°Ρ‚Π΅Π»ΡŒΡ‰ΠΈΠΊΠ° data: <?php echo (($this->kassa_enabled == 'yes') ? json_encode($kassa_array) : "{}") ?> }, function (options) { // success window.location.replace('<?=$this->get_return_url($order)?>'); }, function (reason, options) { // fail window.location.replace('<?=$order->get_cancel_order_url()?>'); } ); </script> 

The server is on unix managed by vesta cp with php version 7.2

  • The string shown by you has nothing to do with utf-8. These are ASCII characters escaped for html / xml - andreymal
  • Show in the browser the source html-code of the page where you display your var_dump - andreymal
  • @andreymal are you talking about a hat? here it is then <!DOCTYPE html> <html lang="ru-RU" prefix="og: http://ogp.me/ns#"> <head> <meta charset="UTF-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge"> </head> - Vasya
  • @andreymal Can you somehow decode these ASCII characters? The joke is that all the other settings are $order_id correctly, for example, even $order_id where $order_id email is invoiceId: <?=$order_id?>, //Π½ΠΎΠΌΠ΅Ρ€ Π·Π°ΠΊΠ°Π·Π° - Vasya
  • one
    @andreymal because I excluded it and now I started testing with var_dump($order); var_dump for billing_email is output like this string (18) β€œo4137889@nwytg.net”, i.e. there, as it should be - 18 shows characters, not 78 as you might think - Vasya

1 answer 1

With great difficulty, but I managed to find the reason - I will share with you, maybe someone will need the thread. There is such an infection plugin Email Address Encoder

(A lightweight plugin protects email addresses from email-harvesting robots by encoding them into decimal and hexadecimal entities.)

Here he is just to blame for everything! Disconnected - and it all worked!