fix price in socolissimo

This commit is contained in:
Marion Muszynski 2016-03-18 17:06:08 +01:00
parent 6feaf9ff28
commit 7e3fe49847

View File

@ -580,18 +580,13 @@ class Socolissimo extends CarrierModule
(float) $this->seller_cost += (float) Configuration::get('PS_SHIPPING_HANDLING');
}
$product_cats = array();
foreach($params['cart']->getProducts() as $product) {
$product_cats[] = (int) $product['id_category_default'];
// Fix du prix si vente consommable
if ($this->getOrderShippingCostConsummable($params['cart'])) {
$this->seller_cost = 5;
$tax_rate = 0;
$tax_rate_seller = 0;
}
$sales = Db::getInstance()->ExecuteS('
SELECT DISTINCT `id_sale`
FROM `'._DB_PREFIX_.'privatesale_category`
WHERE `id_category` IN ('.implode(', ', $product_cats).')
');
$cpt_sales = count($sales);
if($cpt_sales == 2) {
(float) $this->initial_cost += (float) Configuration::get('PS_SHIPPING_HANDLING_PS_1');
if($this->seller_cost) {
@ -619,8 +614,7 @@ class Socolissimo extends CarrierModule
}
}
}
if ($tax_rate)
$std_cost_with_taxes = number_format((float)$this->initial_cost * (1 + ($tax_rate / 100)), 2, ',', ' ');
else
@ -1334,11 +1328,41 @@ class Socolissimo extends CarrierModule
$carrier = new Carrier((int)Configuration::get('SOCOLISSIMO_CARRIER_ID'));
$address = new Address((int)$this->context->cart->id_address_delivery);
$id_zone = Address::getZoneById((int)$address->id);
// Fix du prix si vente consommable
if ($this->getOrderShippingCostConsummable($this->context->cart)) {
$shipping_cost = 5;
return $shipping_cost;
}
return $this->getCostByShippingMethod($carrier, $id_zone);
}
return false;
}
public function getOrderShippingCostConsummable($cart) {
// Fix du prix si vente consommable
$product_cats = array();
foreach($cart->getProducts() as $product) {
$product_cats[] = (int) $product['id_category_default'];
}
$sales = Db::getInstance()->ExecuteS('
SELECT DISTINCT `id_sale`
FROM `'._DB_PREFIX_.'privatesale_category`
WHERE `id_category` IN ('.implode(', ', $product_cats).')
');
$cpt_sales = count($sales);
// si consommables forcer à 5euros
if ($cpt_sales==1) {
foreach ($sales as $key => $sale) {
if ((int) $sale['id_sale'] == (int) _SHOP_PRIVATESALES_CONSUMABLE) {
return true;
}
}
}
return false;
}
public function getOrderShippingCostExternal($params)
{
return;