Add package bundles

This commit is contained in:
Almira Krdzic
2018-08-26 15:41:08 +02:00
parent 6017ae8cf3
commit 5ac3bfff36
9 changed files with 90 additions and 30 deletions

Binary file not shown.

View File

@@ -11,7 +11,8 @@ class Wiaas_DB_Update {
'20180807222206' => 'wiaas_db_update_setup_customer_capabilities',
'20180809134511' => 'wiaas_db_update_add_customer_read_permission',
'20180811134511' => 'wiaas_db_update_enable_orders_access_management',
'20180813134511' => 'wiaas_db_update_enable_order_numbers'
'20180813134511' => 'wiaas_db_update_enable_order_numbers',
'20180826153509' => 'wiaas_create_broker_access_group'
);
public static function execute() {

View File

@@ -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;
}

View File

@@ -107,3 +107,9 @@ function wiaas_db_update_enable_order_numbers() {
update_option('wcj_order_number_counter_reset_enabled', 'no');
update_option('wcj_order_number_prefix', '1000000');
}
function wiaas_create_broker_access_group() {
Groups_Group::create(array(
'name' => 'Broker',
));
}

View File

@@ -29,6 +29,18 @@
"reference": "origin/master"
}
}
},
{
"type": "package",
"package": {
"name": "3rdparty/woocommerce-product-bundles",
"type": "wordpress-plugin",
"version": "5.7.11",
"dist": {
"url": "3rdparty/woocommerce-product-bundles.zip",
"type": "zip"
}
}
}
],
"require": {
@@ -51,7 +63,8 @@
"wpackagist-plugin/wp-user-groups": "2.2.0",
"3rdparty/gravityforms": "*",
"3rdparty/gravityflow": "*"
"3rdparty/gravityflow": "*",
"3rdparty/woocommerce-product-bundles": "*"
},
"require-dev": {
"vlucas/phpdotenv": "2.5.0"
@@ -73,6 +86,7 @@
],
"activate-plugins": [
"wp plugin activate woocommerce",
"wp plugin activate woocommerce-product-bundles",
"wp plugin activate woocommerce-jetpack",
"wp plugin activate jwt-authentication-for-wp-rest-api",
"wp plugin activate gravityforms",
@@ -86,6 +100,7 @@
"wp core update-db",
"composer activate-plugins",
"wp wc update",
"wp wc pb update",
"wp wiaas update-db"
]
}

13
backend/composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "798e9b8b675248e2b8dbc2bc7dcab511",
"content-hash": "302f569929ecdaf4d349b0bf764de74c",
"packages": [
{
"name": "3rdparty/gravityflow",
@@ -26,6 +26,17 @@
},
"type": "wordpress-plugin"
},
{
"name": "3rdparty/woocommerce-product-bundles",
"version": "5.7.11",
"dist": {
"type": "zip",
"url": "3rdparty/woocommerce-product-bundles.zip",
"reference": null,
"shasum": null
},
"type": "wordpress-plugin"
},
{
"name": "composer/installers",
"version": "v1.5.0",