gift certificate tweak

Can anyone give me a quick how-to to add the order date stamp of a gift certificate on the gift certificate template?



Gift Certificate template is found: mail>addons>gift_certificates>templates>default.tpl, but I'm not sure how to make the date it was ordered show on the template. What I'm actually trying to to is make it say that it expires 1 year from the date ordered by showing the expire date, but thought that might be asking too much, ha.



In admin when viewing the gift certificate order, there is a date stamp showing there.

You need to add the date timestamp in the gift certificate template:-



{$gift.timestamp|date_format:"`$settings.Appearance.date_format`, `$settings.Appearance.time_format`"}

Just a heads up, in the US, there are state laws that vary from state to state regarding the legality of placing an expiration date on a “Gift Certificates”.

Great, that worked… except that is today's date stamp. I was hoping to be able to read in the date it was ordered though… and better yet add 365 days to it to arrive at my expire date.

Then:-



{$l.timestamp|date_format:"`$settings.Appearance.date_format`, `$settings.Appearance.time_format`"}




Those are the two timestamps as shown in the admin for gift certificates.

guys, i've tried this and i got my current time

i want to show gift expiration date which is 6 months from it's purchase date, is this possible?

Thanks

guys, i've tried this and i got my current time

i want to show gift expiration date which is 6 months from it's purchase date, is this possible?

Thanks

By default gift certificates do not have expiration date so some custom modifications are required.

By default gift certificates do not have expiration date so some custom modifications are required.

well i just want to show expiration date, and i will disable it manually

well i just want to show expiration date, and i will disable it manually

How the expiration date should be calculated? Try something similar to

{$expiration_date = $gift_cert_data.timestamp + (60 * $smarty.const.SECONDS_IN_DAY)}
{$expiration_date|date_format:"`$settings.Appearance.date_format`, `$settings.Appearance.time_format`"}

(!) Not tested

How the expiration date should be calculated? Try something similar to

{$expiration_date = $gift_cert_data.timestamp + (60 * $smarty.const.SECONDS_IN_DAY)}
{$expiration_date|date_format:"`$settings.Appearance.date_format`, `$settings.Appearance.time_format`"}

(!) Not tested

Hi eComLabs,

thanks for your answer, i've tried your code, but somehow my $gift_cert_data.timestamp value is empty

but after i check on my gift certificate menu on admin panel, it have value and not empty

is there any solution for this?

Thanks

What CS-Cart version do you use? Try to add the following code to see the whole content of the $gift_cert_data array:

{$gift_cert_data|fn_print_r}

What CS-Cart version do you use? Try to add the following code to see the whole content of the $gift_cert_data array:

{$gift_cert_data|fn_print_r}

i use cs cart version 4.24 for multi store

this is what my array contents:

Array
(
[recipient] =>
[sender] =>
[amount] =>
[message] =>
[send_via] =>
[email] =>
[template] =>
[company_id] =>
[http_location] =>
[subtotal] =>
[display_subtotal] =>
[tax_value] =>
[gift_cert_id] =>
[gift_cert_code] =>
)

it don't have timestamp field there

Try the following code:

{$_data = $gift_cert_data.gift_cert_id|fn_get_gift_certificate_info:'B'}
{$expiration_date = $_data.timestamp + (60 * $smarty.const.SECONDS_IN_DAY)}
{$expiration_date|date_format:"`$settings.Appearance.date_format`, `$settings.Appearance.time_format`"}

Try the following code:

{$_data = $gift_cert_data.gift_cert_id|fn_get_gift_certificate_info:'B'}
{$expiration_date = $_data.timestamp + (60 * $smarty.const.SECONDS_IN_DAY)}
{$expiration_date|date_format:"`$settings.Appearance.date_format`, `$settings.Appearance.time_format`"}

Thanks, it works !!

You are welcome!

How Can I add this in the twig template?

thanks Jorden

Unfortunately, you cannot use this code in the Twig template. It is required to extend array with available variables for templates to use this data

any idea how to get this done?

Jorden

any idea how to get this done?

Jorden

Please take a look

https://docs.cs-cart.com/latest/developer_guide/core/documents/documents.html