Woocommerce chinese attribute encoding
-
My store has some products in Chinese language,
I am building a plugin to translate Chinese to English and save English version back to woocommerce.
If i ask woocommerce for products attributes, it returns the attributes in an encoded format like below
I use
$attributes = json_encode( $product->get_attributes()"attributes": { "%e8%b4%a7%e6%ba%90%e7%b1%bb%e5%88%ab": {}, "%e6%98%af%e5%90%a6%e6%94%af%e6%8c%81%e4%b8%80%e4%bb%b6%e4%bb%a3%e5%8f%91": {}, "pa_191386aef4bc441e": {}, "%e5%9e%8b%e5%8f%b7": {}, "%e5%b1%8f%e5%b9%95%e5%b0%ba%e5%af%b8": {}, "%e5%8a%a0%e5%b7%a5%e6%96%b9%e5%bc%8f": {}, "%e9%80%9a%e8%ae%af%e5%8a%9f%e8%83%bd": {}, "%e4%ba%a7%e5%93%81%e9%87%8d%e9%87%8f": {}, "%e4%b8%8a%e5%b8%82%e6%97%b6%e9%97%b4": {}, "%e6%8e%a5%e5%8f%a3": {}, "%e5%94%ae%e5%90%8e%e6%9c%8d%e5%8a%a1": {}, "%e6%9d%90%e8%b4%a8": {}, "%e9%99%84%e5%8a%a0%e5%8a%9f%e8%83%bd": {}, "%e9%80%82%e7%94%a8%e5%af%b9%e8%b1%a1": {}, "%e9%a2%9c%e8%89%b2%e5%88%86%e7%b1%bb": {}, "%e6%98%af%e5%90%a6%e8%b7%a8%e5%a2%83%e5%87%ba%e5%8f%a3%e4%b8%93%e4%be%9b%e8%b4%a7%e6%ba%90": {}, "%e5%8c%85%e8%a3%85%e6%b8%85%e5%8d%95": {}, "%e5%93%81%e7%89%8c": {}, "%e8%b4%a7%e5%8f%b7": {}, "%e6%97%a0%e7%ba%bf%e8%b7%9d%e7%a6%bb": {}, "%e6%9c%80%e5%bf%ab%e5%87%ba%e8%b4%a7%e6%97%b6%e9%97%b4": {}, "%e5%a4%96%e8%a7%82%e5%b0%ba%e5%af%b8": {}, "%e9%80%82%e7%94%a8%e4%ba%ba%e7%be%a4": {}, "%e6%9c%ba%e8%ba%ab%e5%86%85%e5%ad%98": {}, "%e7%94%b5%e6%b1%a0%e5%ae%b9%e9%87%8f": {}, "%e5%8a%a0%e5%8d%b0logo": {}, "%e6%93%8d%e4%bd%9c%e6%96%b9%e5%bc%8f": {}, "%e4%b8%bb%e8%a6%81%e4%b8%8b%e6%b8%b8%e5%b9%b3%e5%8f%b0": {}, "%e6%9c%89%e5%8f%af%e6%8e%88%e6%9d%83%e7%9a%84%e8%87%aa%e6%9c%89%e5%93%81%e7%89%8c": {}, "%e8%85%95%e5%b8%a6%e6%9d%90%e8%b4%a8": {}, "%e5%85%bc%e5%ae%b9%e5%b9%b3%e5%8f%b0": {}, "%e5%8a%9f%e8%83%bd": {}, "%e4%bd%a9%e6%88%b4%e6%96%b9%e5%bc%8f": {}, "%e9%80%82%e7%94%a8%e5%b9%b3%e5%8f%b0": {}, "%e6%98%af%e5%90%a6%e6%94%af%e6%8c%81%e6%b7%b7%e6%89%b9": {}, "%e4%b8%bb%e8%a6%81%e9%94%80%e5%94%ae%e5%9c%b0%e5%8c%ba": {}, "%e5%8f%91%e7%a5%a8": {} },You can notice that the attribute keys start
%e,
I figured out that the attribute key was saved by firstly sanitizing the text likeecho filter_var("货源类别",FILTER_SANITIZE_ENCODED);the result prints the first entry on the above attributes i.e.%E8%B4%A7%E6%BA%90%E7%B1%BB%E5%88%ABHow can i read back the original chinese string for the attribute key instead of the encoded attribute key ?
The topic ‘Woocommerce chinese attribute encoding’ is closed to new replies.