UltraCart / rest_api_v2_sdk_php

UltraCart REST API PHP Client
Apache License 2.0
3 stars 4 forks source link

How to get order date in receipt email template #14

Closed chadhakavita closed 6 years ago

chadhakavita commented 6 years ago

Hi Perry,

Could you please assist me regarding how I can get the order date in receipt email template? And from where I can change the $instructions variable value? And how I can create a new cancellation email template?

Regards,

perrytew commented 6 years ago

For the order date, you want $order.getCreationDate() Here's the $order object: https://ultracart.atlassian.net/wiki/spaces/ucdoc/pages/1377777/Order+SFO

The $instructions variable is created depending on the payment method used. The various texts are found in your StoreFront under the StoreFront -> Languages tab. Edit the language you are wanting to change, and do a search for "notification". You'll find numerous instructions within. Here's a sample of the notifications for the English language (ENG).

  "notification": {
    "receipt": {
      "creditcardappearas": "The bill will appear on your credit card as: {0}",
      "creditcardinstructions": "Please keep a printed copy of this order for your records.",
      "customerserviceemailfield": "Email",
      "customerserviceheader": "Customer Service",
      "customerservicephonefield": "Phone",
      "mailcheckinstructions": "Please print this order and mail along with your check to:",
      "moneyorderinstructions": "Please print this order and mail along with your money order to:",
      "returnpolicyheader": "Return Policy",
      "sendwiretransferto": "Please submit your wire transfer to",
      "wiretransferaccountnumberlabel": "Account Number",
      "wiretransferintermediateroutingnumberlabel": "Intermediary Routing Number",
      "wiretransferroutingnumberlabel": "Routing Number"
    }

As for a cancellation email template, are you referring to an auto order cancel email? All email templates are found within the StoreFront -> Emails tab.

Regards, Perry

chadhakavita commented 6 years ago

Perry, How I can fetch the only date from $order.getCreationDate(). Right, now I'm getting time as well.

perrytew commented 6 years ago
$order.getCreationDateFormatted()

returns back a string. And the velocity template language is a java engine. So you could use the substring method of java.lang.String to extract the date portion.

https://docs.oracle.com/javase/7/docs/api/java/lang/String.html#substring(int,%20int)

I think it would look something like this:

$order.getCreationDateFormatted().substring(0,11)

You could trial and error until you get the correct upper limit on substring. It's going to be 10 or 11 most likely. All date formatted fields are in this format:

dd MMM yyyy HH:mm:ss
chadhakavita commented 6 years ago

Thanks.