@php
$pricing = array();
$customer_price = 0;
$customer_price=0;
$customeroffer_price;
$show_price = 0;
$convert_price = 0;
if($a != null){
$products = array_unique($products);
}
$current_date = date('Y-m-d H:i:s');
@endphp
@if($products != null && count($products)>0)
@foreach($products as $product)
@foreach($product->subvariants as $key=> $sub)
@if($price_login == 0 || Auth::user())
@php
$commision_setting = App\CommissionSetting::first();
if($commision_setting->type == "flat"){
$commission_amount = $commision_setting->rate;
if($commision_setting->p_type == 'f'){
if($product->tax_r !=''){
$cit = $commission_amount*$product->tax_r/100;
$totalprice = $product->vender_price+$sub->price+$commission_amount+$cit;
if($product->vender_offer_price != 0 || $product->vender_offer_price != NULL)
{
$totalsaleprice = $product->vender_offer_price + $sub->price + $commission_amount+$cit;
}else{
$totalsaleprice = 0;
}
}else{
$totalprice = $product->vender_price+$orivar->price+$commission_amount;
if($product->vender_offer_price != 0 || $product->vender_offer_price != NULL)
{
$totalsaleprice = $product->vender_offer_price + $sub->price + $commission_amount;
}else{
$totalsaleprice = 0;
}
}
if($totalsaleprice == 0){
$customer_price = $totalprice;
$customer_price = round($customer_price * round($conversion_rate, 4), 2);
$convert_price = 0;
$show_price = $customer_price;
}else{
$customer_price = $totalsaleprice;
$customer_price = round($customer_price * round($conversion_rate, 4), 2);
$convert_price = $totalsaleprice;
$show_price = $totalprice;
}
}else{
$totalprice = ($product->vender_price+$sub->price)*$commission_amount;
if($product->vender_offer_price != 0 || $product->vender_offer_price != NULL){
$totalsaleprice = ($product->vender_offer_price+$sub->price)*$commission_amount;
}
$buyerprice = ($product->vender_price+$sub->price)+($totalprice/100);
if($product->vender_offer_price != 0 || $product->vender_offer_price != NULL){
$buyersaleprice = ($product->vender_offer_price+$sub->price)+($totalsaleprice/100);
}else {
$buyersaleprice = 0;
}
if($buyersaleprice ==0){
$customer_price = round($buyerprice,2);
$customer_price = round($customer_price * round($conversion_rate, 4), 2);
$convert_price = 0;
$show_price = $buyerprice;
}else{
$customer_price = round($buyersaleprice,2);
$customer_price = round($customer_price * round($conversion_rate, 4), 2);
$convert_price = $buyersaleprice;
$show_price = $buyerprice;
}
}
}else{
$comm = App\Commission::where('category_id',$product->category_id)->first();
if(isset($comm)){
if($comm->type=='f'){
$commission_amount = $comm->rate;
if($product->tax_r !=''){
$cit = $commission_amount*$product->tax_r/100;
$totalprice = $product->vender_price+$sub->price+$commission_amount+$cit;
if($product->vender_offer_price != 0 || $product->vender_offer_price != NULL)
{
$totalsaleprice = $product->vender_offer_price + $sub->price + $commission_amount + $cit;
}else{
$totalsaleprice = 0;
}
}else{
$totalprice = $product->vender_price+$sub->price+$commission_amount;
if($product->vender_offer_price != 0 || $product->vender_offer_price != NULL)
{
$totalsaleprice = $product->vender_offer_price + $sub->price + $commission_amount;
}else{
$totalsaleprice = 0;
}
}
if($totalsaleprice == 0){
$customer_price = $totalprice;
$customer_price = round($customer_price * round($conversion_rate, 4), 2);
$convert_price = 0;
$show_price = $totalprice;
}else{
$customer_price = $totalsaleprice;
$customer_price = round($customer_price * round($conversion_rate, 4), 2);
$convert_price = $totalsaleprice;
$show_price = $totalprice;
}
}
else{
$commission_amount = $comm->rate;
$totalprice = ($product->vender_price+$sub->price)*$commission_amount;
if($product->vender_offer_price != 0 || $product->vender_offer_price != NULL){
$totalsaleprice = ($product->vender_offer_price+$sub->price)*$commission_amount;
}
$buyerprice = ($product->vender_price+$sub->price)+($totalprice/100);
if($product->vender_offer_price != 0 || $product->vender_offer_price != NULL){
$buyersaleprice = ($product->vender_offer_price+$sub->price)+($totalsaleprice/100);
}else {
$buyersaleprice = 0;
}
if($buyersaleprice ==0){
$customer_price = round($buyerprice,2);
$customer_price = round($customer_price * round($conversion_rate, 4), 2);
$convert_price = 0;
$show_price = $buyerprice;
}else{
$customer_price = round($buyersaleprice,2);
$customer_price = round($customer_price * round($conversion_rate, 4), 2);
$convert_price = $buyersaleprice;
$show_price = $buyerprice;
}
}
}else{
$commission_amount = 0;
$totalprice = ($product->vender_price + $sub->price) * $commission_amount;
$totalsaleprice = ($product->vender_offer_price + $sub->price) * $commission_amount;
$buyerprice = ($product->vender_price + $sub->price) + ($totalprice / 100);
$buyersaleprice = ($product->vender_offer_price + $sub->price) + ($totalsaleprice / 100);
if ($product->vender_offer_price == 0)
{
$customer_price = round($buyerprice, 2);
$customer_price = round($customer_price * round($conversion_rate, 4) , 2);
}
else
{
$customer_price = round($buyersaleprice, 2);
$customer_price = round($customer_price * round($conversion_rate, 4) , 2);
$convert_price = $buyersaleprice == '' ? $buyerprice : $buyersaleprice;
$show_price = $buyerprice;
}
}
}
@endphp
@endif
@php
$var_name_count = count($sub['main_attr_id']);
$name;
$var_name;
$newarr = array();
for($i = 0; $i<$var_name_count; $i++){
$var_id=$sub['main_attr_id'][$i];
$var_name[$i]=$sub['main_attr_value'][$var_id]; // echo($orivar['main_attr_id'][$i]);
$name[$i]=App\ProductAttributes::where('id',$var_id)->first();
}
try{
$url = url('details').'/'.$product->id.'?'.$name[0]['attr_name'].'='.$var_name[0].'&'.$name[1]['attr_name'].'='.$var_name[1];
}catch(Exception $e)
{
$url = url('details').'/'.$product->id.'?'.$name[0]['attr_name'].'='.$var_name[0];
}
array_push($pricing, $customer_price);
@endphp
@if($outofstock == 1)
@if($sub->stock > 0)
@if($start_price == 1)
@if($starts <= $customer_price && $ends>= $customer_price)
@if($a != null)
@foreach($a as $provars)
@if($provars->id == $sub->id)