Quote from: bennyb at Mar 02, 2017, 12:31 PMQuote from: Ysanmiguel at Mar 02, 2017, 05:10 AM
But can I use [[+price]] and [[+date]] placeholders if they are coming from the JS?:
You'll need to have a hidden input for both price and date. Then set their values with JS. These will then be available as placeholders in the emailTpl.
Ok I understand but the JS is calling a JSON string, Price and Date might be the values of one product, but it is possible that there are 2 or more products with the same vales, eg:
here the string for one product (in that case is easy create an input field for every value.):
{"SCI-1":{"id":"SCI-1","price":75,"date":"Wednesday, 8 March, 2017"}}
but how can I do it with more than one product?:
{"SCI-1":{"id":"SCI-1","price":75,"date":"Wednesday, 8 March, 2017"},"SCI-2":{"id":"SCI-2","price":45,"date":"Thursday, 9 March, 2017"}}
If you see the JS it's getting all values and put them all inside one <input field, no matter how many different items the string has, it works but the HTML labels get lost in the process:
function submitCheckout(){
var finalplanString = "";
var elements = JSON.parse(localStorage.local_items);
for(var plan in elements){
finalplanString += "<div class=\"wrap\">";
finalplanString += "price: $" + elements[plan].price + "<br>";
finalplanString += "date: " + elements[plan].date + "<br>";
finalplanString += "</div>";
}
document.getElementById('hiddenInput').value = finalplanString;
$('#checkoutForm').submit();
};