if(!empty($element->prices)){
$this->selectDiscount($element,$discounts);
if(!empty($element->prices)){
foreach($element->prices as $k=>$price){
$this->addDiscount($element->prices[$k],$element->discount,$discount_before_tax,$zone_id,$element->product_tax_id);
}
}
}
if(!empty($element->variants)){
foreach($element->variants as $k => $row){
if(!empty($row->prices)){
$this->selectDiscount($element->variants[$k],$discounts);
if(!empty($element->variants[$k]->discount)){
foreach($row->prices as $k2=>$price){
$this->addDiscount($element->variants[$k]->prices[$k2],$element->variants[$k]->discount,$discount_before_tax,$zone_id,$element->product_tax_id);
}
}
}
}
}
if(empty($element->discount) && !empty($element->prices)){
$this->selectDiscount($element,$discounts);
if(!empty($element->discount)){
foreach($element->prices as $k=>$price){
$this->addDiscount($element->prices[$k],$element->discount,$discount_before_tax,$zone_id,$element->product_tax_id);
}
}
}
if(!empty($element->variants)){
foreach($element->variants as $k => $row){
if(empty($row->discount) && !empty($row->prices)){
$this->selectDiscount($element->variants[$k],$discounts);
if(!empty($element->variants[$k]->discount)){
foreach($row->prices as $k2=>$price){
$this->addDiscount($element->variants[$k]->prices[$k2],$element->variants[$k]->discount,$discount_before_tax,$zone_id,$element->product_tax_id);
}
}
}
}
}