public function getTotal() { $total = 0; foreach ($this->getProducts() as $product) { $total += $this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax')) * $product['quantity']; } return $total; }
public function getById() { $product_id = $this->request->get['product_id']; $this->load->auto('store/product'); $this->load->auto('image'); $this->load->auto('tax'); $this->load->auto('currency'); $tax = new Tax($this->registry); $currency = new Currency($this->registry); $strProducts = ''; $product = $this->modelProduct->getById($product_id); $tags = $this->modelProduct->getTags($product_id); if (isset($this->request->get['format']) && !empty($this->request->get['format'])) { $strProducts .= "Producto: " . $product['name'] . "\n"; $strProducts .= "Precio: " . $currency->format($tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax'))) . "\n"; //TODO: cureency format $strProducts .= "URL: " . Url::createUrl("product/product", array("product_id" => $product['product_id']), "NONSSL", HTTP_CATALOG . "/"); if ($tags) { foreach ($tags as $key => $tag) { $ntag = $key + 1; $strProducts .= "\nTag " . $ntag . ": " . Url::createUrl("product/search", array("keyword" => $tag['tag']), "NONSSL", HTTP_CATALOG . "/") . "\n"; } } $strProducts .= "\n"; echo $strProducts; } else { $strProducts .= "<div style='margin:5px;padding:3px;background:#FFF;float:left;border:dotted 1px #ccc;width:100px;display:block;text-align:center'>"; $strProducts .= "<br><p><a href='" . Url::createUrl("product/product", array("product_id" => $product['product_id']), "NONSSL", HTTP_CATALOG . "/") . "'>" . $product['name'] . "</a></p>"; if (empty($product['image'])) { $strProducts .= "<a href='" . Url::createUrl("product/product", array("product_id" => $product['product_id']), "NONSSL", HTTP_CATALOG . "/") . "'>"; $strProducts .= "<img src='" . NTImage::resizeAndSave('no_image.jpg', 50, 50) . "' alt='" . $product['name'] . "'>"; $strProducts .= "</a>"; } else { $strProducts .= "<a href='" . Url::createUrl("product/product", array("product_id" => $product['product_id'])) . "'>"; $strProducts .= "<img src='" . NTImage::resizeAndSave($product['image'], 50, 50) . "' alt='" . $product['name'] . "'>"; $strProducts .= "</a>"; } $strProducts .= "<input type='hidden' name='" . $product['product_id'] . "' value='" . $product['product_id'] . "'>"; $strProducts .= "<br><b>" . $currency->format($tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax'))) . "</b><br>"; if ($tags) { foreach ($tags as $key => $tag) { $strProducts .= " <a href='" . Url::createUrl("product/search", array("keyword" => $tag['tag']), "NONSSL", HTTP_CATALOG . "/") . "' style='font:normal 9px verdana'>" . $tag['tag'] . "</a> "; } } $strProducts .= "<br></div>"; echo $strProducts; } }