感谢任何可以提供帮助的人。我正在尝试使用 PHP 从任何给定的当前日期获得 X 天的交货日期。这是与 WordPress 中的 Google 调查选择加入代码和 WooCommerce 一起使用的。
参考此线程:WooCommerce 填写 Google 调查选择加入代码的字段
谷歌想要动态值,解释在这里:https : //support.google.com/merchants/answer/7106244?hl=en&ref_topic=7105160#example
我已经准备好了大部分代码,但是这个动态日期很难弄清楚。
我认为最简单的解决方案是在产品订单的当天添加几天,这可能发生在任何一天。
我的问题是:如何让 PHP 在这种情况下计算它?
我的理解是有 DateTime 和 strtotime,但 DateTime 是最近和“正确”的方式来做到这一点?
这是我到目前为止所得到的,但我不确定它是否正确:
//Google Survey code
function wh_CustomReadOrder($order_id) {
//getting order object
$order = wc_get_order($order_id);
$email = $order->billing_email;
?>
<script src="https://apis.google.com/js/platform.js?onload=renderOptIn" async defer></script>
<script>
window.renderOptIn = function () {
window.gapi.load('surveyoptin', function () {
window.gapi.surveyoptin.render(
{
"merchant_id": [merchant id],
"order_id": "<?php echo $order_id; ?>",
"email": "<?php echo $email; ?>",
"delivery_country": "CA",
"estimated_delivery_date": …Run Code Online (Sandbox Code Playgroud)