Add package bundles
This commit is contained in:
@@ -15,7 +15,7 @@ class Wiaas_Order {
|
||||
|
||||
add_filter('woocommerce_rest_check_permissions', array( __CLASS__, 'check_order_access'), 10, 4);
|
||||
|
||||
add_filter('woocommerce_rest_prepare_shop_order_object', array(__CLASS__, 'transform_rest_order'), 10, 3);
|
||||
add_filter('woocommerce_rest_prepare_shop_order_object', array(__CLASS__, 'transform_rest_order'), 999, 3);
|
||||
|
||||
add_filter('woocommerce_rest_orders_prepare_object_query', array( __CLASS__, 'wiaas_prepare_rest_orders_query'), 10, 2);
|
||||
}
|
||||
@@ -148,7 +148,7 @@ class Wiaas_Order {
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends additional wiaas products info to order json response
|
||||
* Filters only package product lines and appends additional wiaas products info to order json response
|
||||
* @param $data
|
||||
* @param $order
|
||||
* @param $request
|
||||
@@ -156,35 +156,41 @@ class Wiaas_Order {
|
||||
* @return mixed
|
||||
*/
|
||||
private static function _append_products_info($data, $order, $request) {
|
||||
$line_items = array();
|
||||
foreach ($data['line_items'] as $index => $product_line) {
|
||||
# lock all products to `Purchase` payment type
|
||||
$product_line['payment_type'] = 'Purchase';
|
||||
// add only product lines that represent product bundles
|
||||
if (empty($product_line['bundled_by'])) {
|
||||
# lock all products to `Purchase` payment type
|
||||
$product_line['payment_type'] = 'Purchase';
|
||||
|
||||
# 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';
|
||||
# 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';
|
||||
|
||||
# simplify payment for all products
|
||||
$product_line['recurring_price'] = 0;
|
||||
$product_line['pay_period'] = 0;
|
||||
# simplify payment for all products
|
||||
$product_line['recurring_price'] = 0;
|
||||
$product_line['pay_period'] = 0;
|
||||
|
||||
# collect status from order
|
||||
if ($data['status'] === 'completed') {
|
||||
$product_line['status'] = 'production';
|
||||
} else if ($data['status'] === 'cancelled') {
|
||||
$product_line['status'] = 'cancelled';
|
||||
} else {
|
||||
$product_line['status'] = 'processing';
|
||||
# collect status from order
|
||||
if ($data['status'] === 'completed') {
|
||||
$product_line['status'] = 'production';
|
||||
} else if ($data['status'] === 'cancelled') {
|
||||
$product_line['status'] = 'cancelled';
|
||||
} else {
|
||||
$product_line['status'] = 'processing';
|
||||
}
|
||||
$product_line['short_desc'] = $product_line['status'];
|
||||
|
||||
# collect completion data from order
|
||||
$product_line['date_completed'] = $data['date_completed'];
|
||||
|
||||
$line_items[] = $product_line;
|
||||
}
|
||||
$product_line['short_desc'] = $product_line['status'];
|
||||
|
||||
# collect completion data from order
|
||||
$product_line['date_completed'] = $data['date_completed'];
|
||||
|
||||
$data['line_items'][$index] = $product_line;
|
||||
}
|
||||
$data['line_items'] = $line_items;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user