Jump to content

Edit History

knacky

knacky

/* cart-summary-totals.tpl */

obrazek.png.31d25c492d556ce5def8e8cdd3807fcf.png

/* cart-detailed-totals.tpl */

obrazek.png.73e4df7672ad7f4d8e97f1e5108db547.png

 

Module:

public function hookDisplayMyCustomTax($params)
    {
        $idCart = Context::getContext()->cart->id;

        $cart = new Cart($idCart);
        $productWithoutTax = $cart->getOrderTotal(true, Cart::ONLY_PRODUCTS);
        $productWithTax = $cart->getOrderTotal(false, Cart::ONLY_PRODUCTS);
        $getTaxAverage = ($cart->getAverageProductsTaxRate($productWithoutTax, $productWithTax) * 100);
        $getTax = Cart::getTaxesAverageUsed($idCart);

        $taxCalculate = abs($productWithTax - $productWithoutTax);

        $getPriceTax = Tools::displayPrice($taxCalculate);

        $label = $this->l('Ingresos Brutos');
        $tax = $getTaxAverage.'%';
        $value = $getPriceTax;

        $this->context->smarty->assign(array(
            'custom_tax_label' => $label,
            'custom_tax_tax' => $tax,
            'custom_tax_value' => $value
        ));

        return $this->display(_PS_MODULE_DIR_.$this->name, '/views/templates/front/custom-tax.tpl');

    }

 

Sample module:

ps_customtax.zip

knacky

knacky

/* cart-summary-totals.tpl */

obrazek.png.31d25c492d556ce5def8e8cdd3807fcf.png

/* cart-detailed-totals.tpl */

obrazek.png.73e4df7672ad7f4d8e97f1e5108db547.png

 

Module:

public function hookDisplayMyCustomTax($params)
    {
        $idCart = Context::getContext()->cart->id;

        $cart = new Cart($idCart);
        $productWithoutTax = $cart->getOrderTotal(true, Cart::ONLY_PRODUCTS);
        $productWithTax = $cart->getOrderTotal(false, Cart::ONLY_PRODUCTS);
        $getTaxAverage = ($cart->getAverageProductsTaxRate($productWithoutTax, $productWithTax) * 100);
        $getTax = Cart::getTaxesAverageUsed($idCart);

        $taxCalculate = abs($productWithTax - $productWithoutTax);

        $getPriceTax = Tools::displayPrice($taxCalculate);

        $label = $this->l('Ingresos Brutos');
        $tax = $getTaxAverage.'%';
        $value = $getPriceTax;

        $this->context->smarty->assign(array(
            'custom_tax_label' => $label,
            'custom_tax_tax' => $tax,
            'custom_tax_value' => $value
        ));

        return $this->display(_PS_MODULE_DIR_.$this->name, '/views/templates/front/custom-tax.tpl');

    }

 

×
×
  • Create New...