Bonjour,
Merci pour t'a réponse,
J'ai modifier la ligne expliquer dans ce poste :
www.hikashop.com/forum/5-support-en-fran...iquer-l-ecotaxe.html
$sum += $p->$value;
en:
$sum += $p->$value*$p->cart_product_quantity;
dans le fichier principal du plugin.
Voici le code du plugin actuellement:
<?php
/**
*
*/
class plgHikashopGlobal_cart_fee extends hikashopPlugin {
var $multiple = true;
var $name = 'global_cart_fee';
var $pluginConfig = array(
'name' => array('HIKA_NAME', 'input'),
'price' => array('PRICE', 'input'), //if value has a custom field name, you can enter here either + or - to indicate whether the calculated sum should be shown for information purpose only or add itself to the total
'value' => array('VALUE', 'input'), //can be the name of a custom field and in that case the system will sum the values of that field
);
function onAfterCartProductsLoad(&$cart) {
$plugins = array();
$this->listPlugins($this->name, $plugins, false, true);
if(!count($plugins)){
return;
}
foreach($plugins as $plugin){
$this->pluginParams($plugin);
if(isset($cart->additional['global_cart_fee_'.$plugin]))
continue;
$additional = new stdClass();
if(!empty($this->plugin_params->name)){
$key = strtoupper($this->plugin_params->name);
if(JText::_($key)!=$key){
$this->plugin_params->name = JText::_($key);
}
}
$additional->name = $this->plugin_params->name;
$value = $this->plugin_params->value;
$firstProduct = reset($cart->products);
if(isset($firstProduct->$value)){
$sum = 0;
foreach($cart->products as $p){
$sum += $p->$value*$p->cart_product_quantity;
}
if($this->plugin_params->price != '+'){
$currencyHelper = hikashop_get('class.currency');
$additional->value = $currencyHelper->format($sum,hikashop_getCurrency());
}else{
$additional->price_currency_id = hikashop_getCurrency();
$additional->price_value = $sum;
$additional->price_value_with_tax = $sum;
}
}else{
$additional->value = $value;
if(!empty($this->plugin_params->price)){
$additional->price_currency_id = hikashop_getCurrency();
$additional->price_value = $this->plugin_params->price;
$additional->price_value_with_tax = $this->plugin_params->price;
}else{
$additional->price_currency_id = 0;
$additional->price_value = 0;
$additional->price_value_with_tax = 0;
}
}
$cart->additional['global_cart_fee_'.$plugin] = $additional;
}
}
}
Le plugin fonctionne bien, mais il ne prend un compte que le premier article, si mon premier article à 6 en quantité la taxe va augmenter, mais le second, et suivant, ne sont pas prit en compte.
Merci