Jump to content

Edit History

knacky

knacky

Or add new hook to template:

./themes/classic/templates/checkout/_partials/cart-summary-totals.tpl

module:

public function addMyHook()
{
	$lines = array();
	foreach(file(_PS_THEME_DIR_.'templates/checkout/_partials/cart-summary-totals.tpl') as $line)
	{
		if("{block name='cart_summary_total'}" === $line)
		{
			array_push($lines, "{hook h='displayMyCustomTax' cart=$cart.id}");
		}
		array_push($lines, $line);
	}
	file_put_contents(_PS_THEME_DIR_.'templates/checkout/_partials/cart-summary-totals.tpl', $lines);
}

public function removeMyHook()
{
	$readTemplate = file_get_contents(_PS_THEME_DIR_.'templates/checkout/_partials/cart-summary-totals.tpl');
	$replace = str_replace("{hook h='displayMyCustomTax' cart=$cart.id}", '', $readTemplate);
	file_put_contents(_PS_THEME_DIR_.'templates/checkout/_partials/cart-summary-totals.tpl', $replace);
}

public function install() 
{

	if (Shop::isFeatureActive())
	{
		Shop::setContext(Shop::CONTEXT_ALL);
	}
        
	if (!parent::install())
	{
		return false;
	}
        
	$this->registerHook('displayMyCustomTax');
	$this->addMyHook();

	return true;
}

public function uninstall()
{                                 
        
	$this->unregisterHook('displayMyCustomTax');
	$this->removeMyHook();

	if (Shop::isFeatureActive())
	{
		Shop::setContext(Shop::CONTEXT_ALL);
	}
        
	if (!parent::uninstall())
	{
		return false;
	}
  
	return true;
}

public function hookDisplayMyCustomTax($params)
{
	$idCart = $params['cart'];
	....
	....
	....
	
	return 'Hello !';
}

 

knacky

knacky

Or add new hook to template:

./themes/classic/templates/checkout/_partials/cart-summary-totals.tpl

module:

public function addMyHook()
{
	$lines = array();
	foreach(file(_PS_THEME_DIR_.'templates/checkout/_partials/cart-summary-totals.tpl') as $line)
	{
		if("{block name='cart_summary_total'}" === $line)
		{
			array_push($lines, "{hook h='displayMyCustomTax' cart=$cart.id}");
		}
		array_push($lines, $line);
	}
	file_put_contents(_PS_THEME_DIR_.'templates/checkout/_partials/cart-summary-totals.tpl', $lines);
}

public function removeMyHook()
{
	$readTemplate = file_get_contents(_PS_THEME_DIR_.'templates/checkout/_partials/cart-summary-totals.tpl');
	$replace = str_replace("{hook h='displayMyCustomTax' cart=$cart.id}", '', $readTemplate);
	file_put_contents(_PS_THEME_DIR_.'templates/checkout/_partials/cart-summary-totals.tpl', $replace);
}

public function install() 
{

	if (Shop::isFeatureActive())
	{
		Shop::setContext(Shop::CONTEXT_ALL);
	}
        
	if (!parent::install())
	{
		return false;
	}
        
	$this->registerHook('displayMyCustomTax');
        

	return true;
}

public function hookDisplayMyCustomTax($params)
{
	$idCart = $params['cart'];
	....
	....
	....
	
	return 'Hello !';
}

 

×
×
  • Create New...