本文整理汇总了PHP中Tax::calculate方法的典型用法代码示例。如果您正苦于以下问题:PHP Tax::calculate方法的具体用法?PHP Tax::calculate怎么用?PHP Tax::calculate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tax
的用法示例。
在下文中一共展示了Tax::calculate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTotal
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;
}
示例2: getById
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;
}
}