well for one, it looks like you have Smarty variables inside literal tags, that is why they aren't populating.
See
http://www.smarty.net/docsv2/en/language.function.literal
http://www.smarty.net/docsv2/en/language.function.ldelim.tpl
Basically when you use {literal} the smarty variables do not work. So you must {/literal}{$smarty.variable}{literal} each time
This is a quick google search on using smarty variables inside literal tags.
http://stackoverflow.com/questions/5001886/how-can-a-smarty-variable-be-made-working-under-literal-literal
As far as your foreach loop. I believe you need a second foreach loop for the products.
You should have one (like you do) for orders, and a separate for the products inside the orders to get variables like {$product.productid}
Try using
Code:
{foreach from=$order.products item="product"}
// Push all products to refiral_cart_items array
var refiral_cart_items = [];
refiral_cart_items.push({
product_id: '{$product.productid}', // Product ID
quantity: '{$product.amount}', // Quantity
name: '{$product.product}', // Name of product
});
refiral_cart_items.push({
product_id: '{$product.productid}', // Item Product ID
quantity: '{$product.amount}', // Item Quantity
name: '{$product.product}', // Name of product
});
{/foreach}