Google客户评论脚本代码(预计交货日期)

时间:2017-05-12 18:22:53

标签: javascript volusion

我正在电子商务的“谢谢”页面上实施Google客户评论脚本。唯一的问题是我无法从当月开始1个月的日期来显示“estimated_delivery_date”。其他一切都很好。

日期必须完全采用以下格式:“yyyy-mm-dd”

这是我到目前为止的代码:

<script>
var emailAddress = Order[9]; // pulls customer's email
var datePurchased = new Date();
var yyyy = datePurchased.getFullYear();
var mm = datePurchased.getMonth()+1;
var dd = datePurchased.getDate();
var delivery = yyyy+'-'+mm+'-'+dd;

  window.renderOptIn = function() {
    window.gapi.load('surveyoptin', function() {

      window.gapi.surveyoptin.render(
        {
          "merchant_id": 7654321,
          "order_id": "$(OrderNo)", // pulls order number
          "email": emailAddress, // pulls customer's email
          "delivery_country": "US",
          "estimated_delivery_date": "delivery", // not pulling delivery date. Why?
        });
    });
  }
</script>

感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

您将传递作为字符串传递:

"estimated_delivery_date": "delivery", // not pulling delivery date. Why?

尝试:

<script>
var emailAddress = Order[9];
var datePurchased = new Date();
var yyyy = datePurchased.getFullYear();
var mm = datePurchased.getMonth()+1;
var dd = datePurchased.getDate();
var delivery = yyyy+'-'+mm+'-'+dd;

  window.renderOptIn = function() {
    window.gapi.load('surveyoptin', function() {

      window.gapi.surveyoptin.render(
        {
          "merchant_id": 7654321,
          "order_id": "$(OrderNo)",
          "email": emailAddress,
          "delivery_country": "US",
          "estimated_delivery_date": delivery
        });
    });
  }
</script>