How to display dynamic shipment, payment calculation on product detail views

Written by Max Milbers on . Posted in Templating & Layouts

VirtueMart triggers plgVmOnProductDisplayShipment and plgVmOnProductDisplayPayment and so plugins can dynamically display html on the product details page. This is interesting for example for displaying dynamic shipment or payment prices. Another example are calculation plugins that use this triggers to display discount rates. When we introduced this feature (svn version 5698), we used this code (in /components/com_virtuemart/views/productdetails/tmpl) [code] if (is_array($this->productDisplayShipments)) { foreach ($this->productDisplayShipments as $productDisplayShipment) { echo $productDisplayShipment . '
'; } } if (is_array($this->productDisplayPayments)) { foreach ($this->productDisplayPayments as $productDisplayPayment) { echo $productDisplayPayment . '
'; } } [/code] We replaced it in vm3.2 (svn 9398) against this [code] $productDisplayTypes = array('productDisplayShipments', 'productDisplayPayments'); foreach ($productDisplayTypes as $productDisplayType) { if(empty($this->$productDisplayType)){ continue; } else if (!is_array($this->$productDisplayType)) { $this->$productDisplayType = array($this->$productDisplayType); } foreach ($this->$productDisplayType as $productDisplay) { if(empty($productDisplay)){ continue; } else if (!is_array($productDisplay)){ $productDisplay = array($productDisplay); } foreach ($productDisplay as $virtuemart_method_id =>$productDisplayHtml) { ?>
productDisplayTypes as $type=>$productDisplayType) { foreach ($productDisplayType as $productDisplay) { foreach ($productDisplay as $virtuemart_method_id =>$productDisplayHtml) { ?>