Reputation: 11
I have a problem, I have a code in smarty but I have to put it in a php file in one of the module, but I have no idea how to do it. It's me in this module can receive m.in the total width of the package.
{$db = Db::getInstance()}
{$flag = 0}
{foreach $products as $product}
{$flag = $flag + 1}
{assign var='productId' value=$product.id_product}
{*Height*}
{$sql = "SELECT height FROM ps_product WHERE id_product = $productId"}
{assign var='height' value=$db->getValue($sql)}
{*/Height*}
{*Width*}
{$sql = "SELECT width FROM ps_product WHERE id_product = $productId"}
{assign var='width' value=$db->getValue($sql)}
{*/Width*}
{*DEPTH*}
{$sql = "SELECT depth FROM ps_product WHERE id_product = $productId"}
{assign var='depth' value=$db->getValue($sql)}
{*/DEPTH*}
{assign var='quantity' value=$product.cart_quantity-$quantityDisplayed}
{assign var='capacity' value=$height*$width*$depth}
{$Arrayquantity.$flag = $quantity}
{$ArrayCapacity.$flag = $capacity}
{$weight = $cart->getTotalWeight()|escape:'htmlall':'UTF-8'|number_format:2}
{/foreach}
{$capacity = 0}
{foreach $ArrayCapacity as $key => $value}
{$capacity = $capacity + $value*$Arrayquantity[$key]/1000000}
{/foreach}
Upvotes: 0
Views: 678
Reputation: 1491
Oh, man, you don't really get how it works. You need to check how controllers assign variables to templates, how {assign} work in Smarty... this whole code should be in controller or in your module and you need to assign values to view using $this->context->smarty->assign.
I highly recommend you to look on few default modules to see how it work.
Upvotes: 1