【发布时间】:2018-05-30 14:01:21
【问题描述】:
通过触发this Webhook,我收到一个order object,当我在电子邮件中输出它时,它看起来像这样:
数组{"id":1154,"parent_id":0,"status":"pending","currency":"EUR","version":"3.2.3","prices_include_tax":true," date_created":{"日期":"2017-12-15 15:58:42.000000","timezone_type":1,"timezone":"+00:00"},"date_modified":{"date":"2017-12-15 15:58:42.000000","timezone_type":1,"timezone":"+00:00"},"discount_total":"0","discount_tax":"0","shipping_total":"0"," shipping_tax":"0","cart_tax":"0","total":"6.50","total_tax":"0","customer_id":0,"order_key":"wc_order_5a33f1321ba43","billing":{ "first_name":"Peter","last_name":"Parker","company":"","address_1":"Baker Str.","address_2":"2","city":"London","state":"","postcode":"50668","country":"DE","email":"something@ gmail.com","phone":"01627423"},"shipping":{"first_name":"Peter","last_name":"Parker","company":"","address_1":"Baker Str.","address_2":"2","city":"London","state":"","postcode":"50668","country":"DE"},"payment_method":"cod ","payment_method_title":"贝 Abholung","交易 _id":"","customer_ip_address":"...","customer_user_agent":"mozilla/5.0 (macintosh; intel mac os x 10_13_2) applewebkit/537.36 (khtml, like 壁虎)铬/blabla safari/537.36","created_via":"checkout","customer_note":"","date_completed":null,"date_paid":null,"cart_hash":"be97db19eba58864b9166961ce22a706","number":"1154","meta_data ":[{"id":4731,"key":"_billing_title","value":"1"},{"id":4732,"key":"_shipping_title","value":"1"} ],"line_items":{"18":{}},"tax_lines":[],"shipping_lines":{"19":{}},"fee_lines":[],"coupon_lines":[]}
能否请您指出一种访问此 JSON 元素的可能性,以便我可以从 $order 对象的某些部分构建消息?我尝试将$data = json_decode($order) 与$data->date_created 结合使用,但是当我丢弃最后一部分时,这并没有给我任何帮助。
【问题讨论】:
标签: php json woocommerce