Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Post Javascript To Invoice/e-Mail Rate Topic   - - - - -

 
  • mumbomedia
  • Member
  • Members
  • Join Date: 13-Jan 17
  • 49 posts

Posted 19 October 2018 - 07:18 AM #1

Our customer is selling a couple of handmade products that have a production time of max 2 weeks.
To display this to the customer i've wrote a little Javascript and placed it in a block and enable that for selected products.
Works just fine, however, would there be an easy-ish way to print this to the invoice and/or e-mails aswell?

ps. i was hoping for a existing addon for this, but only can find addons where customers can select their shipping date.

 

 

<script LANGUAGE="JavaScript"> 
<!--


var today = new Date();
today.setDate(today.getDate()+14);


var day = today.getDay(); //getDay() returns 0-6, 0 for sunday..
if (day == 6) {
    today.setDate(today.getDate() + 2);
} else if (day == 0) {
    today.setDate(today.getDate() + 1);


}
var options = {weekday: "long", year: "numeric", month: "numeric", day: "numeric"};


document.write("<strong>Expected shippingdate: </strong>  "+ today.toLocaleDateString("nl-NL", options));


//-->
</SCRIPT>

 



 
  • galtinbaeva
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 06-Dec 13
  • 3200 posts

Posted 19 October 2018 - 07:27 AM #2

 

Our customer is selling a couple of handmade products that have a production time of max 2 weeks.
To display this to the customer i've wrote a little Javascript and placed it in a block and enable that for selected products.
Works just fine, however, would there be an easy-ish way to print this to the invoice and/or e-mails aswell?

ps. i was hoping for a existing addon for this, but only can find addons where customers can select their shipping date.

 

 

<script LANGUAGE="JavaScript"> 
<!--


var today = new Date();
today.setDate(today.getDate()+14);


var day = today.getDay(); //getDay() returns 0-6, 0 for sunday..
if (day == 6) {
    today.setDate(today.getDate() + 2);
} else if (day == 0) {
    today.setDate(today.getDate() + 1);


}
var options = {weekday: "long", year: "numeric", month: "numeric", day: "numeric"};


document.write("<strong>Expected shippingdate: </strong>  "+ today.toLocaleDateString("nl-NL", options));


//-->
</SCRIPT>

 

 

Hello!

 

You can save this date to the order data. Or the easy way is to display static text without exact date for the required products.


Simtech Development | sales@simtechdev.com | www.simtechdev.com
CERTIFIED CS-CART PARTNER | LICENSES | DEVELOPMENT | ADD-ONS | DESIGN | UPGRADE

Mega SEO Package - All you need for your SEO


 
  • mumbomedia
  • Member
  • Members
  • Join Date: 13-Jan 17
  • 49 posts

Posted 19 October 2018 - 07:36 AM #3

Could you guide me in the direction on how to save this date to the order data?
The easy option is not really an option. Most customers tend to be 'less smart' and sending daily mails on WHEN the order is arriving



 
  • galtinbaeva
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 06-Dec 13
  • 3200 posts

Posted 19 October 2018 - 07:49 AM #4

Could you guide me in the direction on how to save this date to the order data?
The easy option is not really an option. Most customers tend to be 'less smart' and sending daily mails on WHEN the order is arriving

 

Create new column in ?:orders table, calculate the date while order placement, for example, in place_order hook (app/functions/fn.cart.php file) and save the value in database.


Simtech Development | sales@simtechdev.com | www.simtechdev.com
CERTIFIED CS-CART PARTNER | LICENSES | DEVELOPMENT | ADD-ONS | DESIGN | UPGRADE

Mega SEO Package - All you need for your SEO


 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11115 posts

Posted 19 October 2018 - 08:28 PM #5

Better practice would be to use the ?:order_data table.  But it's not easy to explain how to use it here in the forum.


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 18673 posts

Posted 22 October 2018 - 05:22 AM #6

Shipping information is store in the cscart_order_data table in serialized way with type = "L". All you need is to add value of new field to each chosen_shippings element of $cart['product_groups'] array


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    CS-Cart RU                         24500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      CS-Cart RU + UniTheme    36000 руб.