Merge branch 'package-bundles' into 'master'
Add package bundles See merge request saburly/wiaas/new-wiaas!14
This commit was merged in pull request #14.
This commit is contained in:
BIN
backend/3rdparty/woocommerce-product-bundles.zip
vendored
Normal file
BIN
backend/3rdparty/woocommerce-product-bundles.zip
vendored
Normal file
Binary file not shown.
@@ -11,7 +11,8 @@ class Wiaas_DB_Update {
|
|||||||
'20180807222206' => 'wiaas_db_update_setup_customer_capabilities',
|
'20180807222206' => 'wiaas_db_update_setup_customer_capabilities',
|
||||||
'20180809134511' => 'wiaas_db_update_add_customer_read_permission',
|
'20180809134511' => 'wiaas_db_update_add_customer_read_permission',
|
||||||
'20180811134511' => 'wiaas_db_update_enable_orders_access_management',
|
'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() {
|
public static function execute() {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class Wiaas_Order {
|
|||||||
|
|
||||||
add_filter('woocommerce_rest_check_permissions', array( __CLASS__, 'check_order_access'), 10, 4);
|
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);
|
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 $data
|
||||||
* @param $order
|
* @param $order
|
||||||
* @param $request
|
* @param $request
|
||||||
@@ -156,35 +156,41 @@ class Wiaas_Order {
|
|||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
private static function _append_products_info($data, $order, $request) {
|
private static function _append_products_info($data, $order, $request) {
|
||||||
|
$line_items = array();
|
||||||
foreach ($data['line_items'] as $index => $product_line) {
|
foreach ($data['line_items'] as $index => $product_line) {
|
||||||
# lock all products to `Purchase` payment type
|
// add only product lines that represent product bundles
|
||||||
$product_line['payment_type'] = 'Purchase';
|
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
|
# lock all products to have no service
|
||||||
$product_line['service_price'] = 0;
|
$product_line['service_price'] = 0;
|
||||||
$product_line['service_contract_period'] = 0;
|
$product_line['service_contract_period'] = 0;
|
||||||
$product_line['max_contract_period'] = 36;
|
$product_line['max_contract_period'] = 36;
|
||||||
$product_line['period_unit'] = 'month';
|
$product_line['period_unit'] = 'month';
|
||||||
|
|
||||||
# simplify payment for all products
|
# simplify payment for all products
|
||||||
$product_line['recurring_price'] = 0;
|
$product_line['recurring_price'] = 0;
|
||||||
$product_line['pay_period'] = 0;
|
$product_line['pay_period'] = 0;
|
||||||
|
|
||||||
# collect status from order
|
# collect status from order
|
||||||
if ($data['status'] === 'completed') {
|
if ($data['status'] === 'completed') {
|
||||||
$product_line['status'] = 'production';
|
$product_line['status'] = 'production';
|
||||||
} else if ($data['status'] === 'cancelled') {
|
} else if ($data['status'] === 'cancelled') {
|
||||||
$product_line['status'] = 'cancelled';
|
$product_line['status'] = 'cancelled';
|
||||||
} else {
|
} else {
|
||||||
$product_line['status'] = 'processing';
|
$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;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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_counter_reset_enabled', 'no');
|
||||||
update_option('wcj_order_number_prefix', '1000000');
|
update_option('wcj_order_number_prefix', '1000000');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function wiaas_create_broker_access_group() {
|
||||||
|
Groups_Group::create(array(
|
||||||
|
'name' => 'Broker',
|
||||||
|
));
|
||||||
|
}
|
||||||
@@ -29,6 +29,18 @@
|
|||||||
"reference": "origin/master"
|
"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": {
|
"require": {
|
||||||
@@ -51,7 +63,8 @@
|
|||||||
"wpackagist-plugin/wp-user-groups": "2.2.0",
|
"wpackagist-plugin/wp-user-groups": "2.2.0",
|
||||||
|
|
||||||
"3rdparty/gravityforms": "*",
|
"3rdparty/gravityforms": "*",
|
||||||
"3rdparty/gravityflow": "*"
|
"3rdparty/gravityflow": "*",
|
||||||
|
"3rdparty/woocommerce-product-bundles": "*"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"vlucas/phpdotenv": "2.5.0"
|
"vlucas/phpdotenv": "2.5.0"
|
||||||
@@ -73,6 +86,7 @@
|
|||||||
],
|
],
|
||||||
"activate-plugins": [
|
"activate-plugins": [
|
||||||
"wp plugin activate woocommerce",
|
"wp plugin activate woocommerce",
|
||||||
|
"wp plugin activate woocommerce-product-bundles",
|
||||||
"wp plugin activate woocommerce-jetpack",
|
"wp plugin activate woocommerce-jetpack",
|
||||||
"wp plugin activate jwt-authentication-for-wp-rest-api",
|
"wp plugin activate jwt-authentication-for-wp-rest-api",
|
||||||
"wp plugin activate gravityforms",
|
"wp plugin activate gravityforms",
|
||||||
@@ -86,6 +100,7 @@
|
|||||||
"wp core update-db",
|
"wp core update-db",
|
||||||
"composer activate-plugins",
|
"composer activate-plugins",
|
||||||
"wp wc update",
|
"wp wc update",
|
||||||
|
"wp wc pb update",
|
||||||
"wp wiaas update-db"
|
"wp wiaas update-db"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
13
backend/composer.lock
generated
13
backend/composer.lock
generated
@@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "798e9b8b675248e2b8dbc2bc7dcab511",
|
"content-hash": "302f569929ecdaf4d349b0bf764de74c",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "3rdparty/gravityflow",
|
"name": "3rdparty/gravityflow",
|
||||||
@@ -26,6 +26,17 @@
|
|||||||
},
|
},
|
||||||
"type": "wordpress-plugin"
|
"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",
|
"name": "composer/installers",
|
||||||
"version": "v1.5.0",
|
"version": "v1.5.0",
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import {
|
|||||||
RECIEVE_SHOP_COMMERCIAL_LEADS,
|
RECIEVE_SHOP_COMMERCIAL_LEADS,
|
||||||
SELECT_SHOP_COMMERCIAL_LEAD
|
SELECT_SHOP_COMMERCIAL_LEAD
|
||||||
} from '../../constants/coMarketConstants';
|
} from '../../constants/coMarketConstants';
|
||||||
|
import { fromWCPackage } from '../../helpers/PackageHelper';
|
||||||
|
|
||||||
const client = new HtmlClient();
|
const client = new HtmlClient();
|
||||||
|
|
||||||
const requestShopPackages = () => ({
|
const requestShopPackages = () => ({
|
||||||
@@ -37,7 +39,7 @@ export const fetchShopPackages = (cl, search) => {
|
|||||||
})
|
})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (response.data) {
|
if (response.data) {
|
||||||
dispatch(recieveShopPackages(response.data))
|
dispatch(recieveShopPackages(response.data.map(wcPackage => fromWCPackage(wcPackage))))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
|
|||||||
@@ -14,7 +14,10 @@ class ShopItem extends Component {
|
|||||||
return (
|
return (
|
||||||
<Col xl="3" lg="4" md="6" sm="12" xs="12">
|
<Col xl="3" lg="4" md="6" sm="12" xs="12">
|
||||||
<Card className="shop-package-item">
|
<Card className="shop-package-item">
|
||||||
<div className="shop-image-photo" style={{'backgroundImage': 'url("'+(shopPackage.images[0].src || 'static/img/no-photo-package.jpg') +'")'}}></div>
|
<div
|
||||||
|
className="shop-image-photo"
|
||||||
|
style={{'backgroundImage': `url(${shopPackage.image})`}}
|
||||||
|
/>
|
||||||
<CardBody>
|
<CardBody>
|
||||||
<CardTitle className="shop-package-title">
|
<CardTitle className="shop-package-title">
|
||||||
<Link to={`/co-market/${idCommercialLead}/${shopPackage.id}`}>
|
<Link to={`/co-market/${idCommercialLead}/${shopPackage.id}`}>
|
||||||
|
|||||||
16
frontend/src/helpers/PackageHelper.js
Normal file
16
frontend/src/helpers/PackageHelper.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
const DEFAULT_PACKAGE_IMG = 'static/img/no-photo-package.jpg';
|
||||||
|
|
||||||
|
export const fromWCPackage = wcPackage => {
|
||||||
|
return {
|
||||||
|
id: wcPackage.id,
|
||||||
|
reference: wcPackage.slug,
|
||||||
|
image: wcPackage.images[0].src || DEFAULT_PACKAGE_IMG,
|
||||||
|
name: wcPackage.name,
|
||||||
|
country: 'Sweden',
|
||||||
|
countryCode: 'se',
|
||||||
|
currency: 'SEK',
|
||||||
|
documents: [],
|
||||||
|
shortDescription: wcPackage.description,
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user