preorder price now comes from preorder product's attributes
This commit is contained in:
@@ -250,23 +250,30 @@ class PreorderApicontroller extends mfBaseApicontroller {
|
||||
if($type == "order") {
|
||||
$product = $this->campaign->setup_products['activation'][0];
|
||||
}
|
||||
if($type == "reorder") {
|
||||
$product = $this->campaign->setup_products['reorder'][0];
|
||||
}
|
||||
|
||||
if($product) {
|
||||
$preorder_data['setup_product_id'] = $product->id;
|
||||
$preorder_data['price_setup'] = $product->price_setup;
|
||||
if($connection_type == "multi-dwelling") {
|
||||
if($preorder_data['connection_count'] == 2) {
|
||||
$preorder_data['price_setup'] = round($product->price_setup * 2 - (($product->price_setup * 2) / 100) * TT_PREORDER_DISCOUNT_2);
|
||||
//$preorder_data['price_setup'] = round($product->price_setup * 2 - (($product->price_setup * 2) / 100) * TT_PREORDER_DISCOUNT_2);
|
||||
$preorder_data['price_setup'] = ($product->attributes["presales_setup_price2"]->value) ? $product->attributes["presales_setup_price2"]->value : $product->price_setup;
|
||||
}
|
||||
if($connection_type == "multi-dwelling" && $preorder_data['connection_count'] == 3) {
|
||||
$preorder_data['price_setup'] = round($product->price_setup * 3 - (($product->price_setup * 3) / 100) * TT_PREORDER_DISCOUNT_3);
|
||||
//$preorder_data['price_setup'] = round($product->price_setup * 3 - (($product->price_setup * 3) / 100) * TT_PREORDER_DISCOUNT_3);
|
||||
$preorder_data['price_setup'] = ($product->attributes["presales_setup_price3"]->value) ? $product->attributes["presales_setup_price3"]->value : $product->price_setup;
|
||||
}
|
||||
}
|
||||
if($connection_type == "apartment" && $type == "order") {
|
||||
$preorder_data['price_setup'] = round($product->price_setup - (($product->price_setup) / 100) * TT_PREORDER_DISCOUNT_APART);
|
||||
//$preorder_data['price_setup'] = round($product->price_setup - (($product->price_setup) / 100) * TT_PREORDER_DISCOUNT_APART);
|
||||
$preorder_data['price_setup'] = ($product->attributes["presales_setup_price4"]->value) ? $product->attributes["presales_setup_price4"]->value : $product->price_setup;
|
||||
}
|
||||
if($connection_type == "business") {
|
||||
$preorder_data['price_setup'] = round($product->price_setup - (($product->price_setup) / 100) * TT_PREORDER_DISCOUNT_BUSINESS);
|
||||
//$preorder_data['price_setup'] = round($product->price_setup - (($product->price_setup) / 100) * TT_PREORDER_DISCOUNT_BUSINESS);
|
||||
$preorder_data['price_setup'] = ($product->attributes["presales_setup_price_business"]->value) ? $product->attributes["presales_setup_price_business"]->value : $product->price_setup;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -279,14 +286,22 @@ class PreorderApicontroller extends mfBaseApicontroller {
|
||||
$preorder_data[$key] = $customer->$key;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if($customer->type == "tenant") {
|
||||
$preorder_data['contact_type'] = "tenant";
|
||||
} elseif($customer->type == "owner") {
|
||||
$preorder_data['contact_type'] = "owner";
|
||||
} else {
|
||||
return mfResponse::BadRequest(["message" => "customer type must be 'tenant' or 'owner'"]);
|
||||
}*/
|
||||
* check optional required fields
|
||||
*/
|
||||
if(is_array($this->campaign->required_fields) && count($this->campaign->required_fields)) {
|
||||
if(in_array("contact_type", $this->campaign->required_fields)) {
|
||||
if($customer->type == "tenant") {
|
||||
$preorder_data['contact_type'] = "tenant";
|
||||
} elseif($customer->type == "owner") {
|
||||
$preorder_data['contact_type'] = "owner";
|
||||
} else {
|
||||
return mfResponse::BadRequest(["message" => "customer type must be 'tenant' or 'owner'"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* create preorder record
|
||||
|
||||
Reference in New Issue
Block a user