Add support for package payment methods and basic checkout proccess

This commit is contained in:
Almira Krdzic
2018-08-29 07:56:37 +02:00
parent 5ac3bfff36
commit 438d92e16e
35 changed files with 1600 additions and 309 deletions

View File

@@ -93,6 +93,8 @@ class Wiaas_Order {
$data = self::_append_commercial_lead_info($data, $order, $request);
$data = self::_append_wiaas_order_details($data, $order, $request);
$response->set_data($data);
return $response;
@@ -102,6 +104,17 @@ class Wiaas_Order {
* PRIVATE
*/
/**
* Append specific wiaas order details, like reference
* @param $data
* @param $order
* @param $request
*/
private static function _append_wiaas_order_details($data, $order, $request) {
$data['reference'] = get_post_meta($order->get_id(), '_wiaas_reference', true);
return $data;
}
/**
* Appends additional wiaas customer lead info to order json response
* @param $data
@@ -160,18 +173,22 @@ class Wiaas_Order {
foreach ($data['line_items'] as $index => $product_line) {
// add only product lines that represent product bundles
if (empty($product_line['bundled_by'])) {
$item = $order->get_item($product_line['id']);
$payment = $item->get_meta('_wiaas_payment', true);
# lock all products to `Purchase` payment type
$product_line['payment_type'] = 'Purchase';
$product_line['payment_type'] = $payment['payment_type'];
# lock all products to have no service
$product_line['service_price'] = 0;
$product_line['service_contract_period'] = 0;
$product_line['max_contract_period'] = 36;
$product_line['period_unit'] = 'month';
$product_line['service_price'] = $payment['minimal_services_price'];
$product_line['service_contract_period'] = $payment['services_contract_period'];
$product_line['max_contract_period'] = $payment['max_contract_period'];
$product_line['period_unit'] = $payment['period_unit'];
# simplify payment for all products
$product_line['recurring_price'] = 0;
$product_line['pay_period'] = 0;
$product_line['recurring_price'] = $payment['recurrent_price'];
$product_line['pay_period'] = $payment['package_pay_period'];
# collect status from order
if ($data['status'] === 'completed') {