product details

This commit is contained in:
Almira Krdzic
2018-09-12 16:42:21 +02:00
parent 35484c6d4f
commit e53b243d96
65 changed files with 3327 additions and 1520 deletions

View File

@@ -100,7 +100,7 @@ class Wiaas_Cart_API {
$package = wc_get_product($item['product_id']);
// Retrieve package addons
$addon_cart_items = Wiaas_Package_Addon::get_cart_item_addons($item);
$addon_cart_items = wiaas_get_cart_item_addons($item);
$additional_packages = array();
foreach ($addon_cart_items as $addon_cart_item) {
@@ -109,30 +109,34 @@ class Wiaas_Cart_API {
'idAdditionalPackage' => $additional_package->get_id(),
'packageName' => $additional_package->get_title(),
'prices' => array(
'fixedExtra' => $addon_cart_item['_wiaas_payment']['minimal_fixed_price'],
'recurentExtra' => $addon_cart_item['_wiaas_payment']['recurrent_price'],
'servicesExtra' => $addon_cart_item['_wiaas_payment']['minimal_services_price'],
'fixedExtra' => $addon_cart_item['_wiaas_payment']['fixed_extra'],
'recurrentExtra' => $addon_cart_item['_wiaas_payment']['recurrent_extra'],
'servicesExtra' => $addon_cart_item['_wiaas_payment']['services_extra'],
)
);
}
// Retrieve package options
$option_cart_items = Wiaas_Package_Option_Groups::get_cart_item_options($item);
$option_cart_items = wiaas_get_cart_item_options($item);
$package_options = array();
foreach ($option_cart_items as $option_cart_item) {
$option_package = wc_get_product($option_cart_item['product_id']);
$package_options[] = array(
'idOptionPackage' => $option_package->get_id(),
'groupName' => $option_package->get_title(),
'groupName' => $option_cart_item['_wiaas_option_group_name'],
'packageName' => $option_package->get_title(),
'prices' => array(
'fixedExtra' => $item['_wiaas_payment']['minimal_fixed_price'],
'recurentExtra' => $item['_wiaas_payment']['recurrent_price'],
'servicesExtra' => $item['_wiaas_payment']['minimal_services_price'],
'fixedExtra' => $option_cart_item['_wiaas_payment']['fixed_extra'],
'recurrentExtra' => $option_cart_item['_wiaas_payment']['recurrent_extra'],
'servicesExtra' => $option_cart_item['_wiaas_payment']['services_extra'],
)
);
}
$totalPrices = Wiaas_Cart::get_cart_item_total($item);
$country = Wiaas_Countries::get_package_country($package);
$result[] = array(
'idPackage' => $item['product_id'],
@@ -144,7 +148,7 @@ class Wiaas_Cart_API {
'bids' => array(),
'commercialLead' => 'Coor Service Management',
'country' => array(
'currency' => 'SEK'
'currency' => $country['currency']
),
'options' => $package_options,
'quantity' => $item['quantity'],
@@ -153,14 +157,14 @@ class Wiaas_Cart_API {
'payType' => $item['_wiaas_payment']['payment_type'],
'periodUnit' => $item['_wiaas_payment']['period_unit'],
'idPrice' => $item['_wiaas_payment']['id'],
'fixedPrice' => $item['_wiaas_payment']['minimal_fixed_price'],
'recurentPrice' => $item['_wiaas_payment']['recurrent_price'],
'servicesPrice' => $item['_wiaas_payment']['minimal_services_price'],
'fixedPrice' => $item['_wiaas_payment']['fixed_extra'],
'recurrentPrice' => $item['_wiaas_payment']['recurrent_extra'],
'servicesPrice' => $item['_wiaas_payment']['services_extra'],
'totalPrices' => array(
'fixedPrice' => $item['_wiaas_payment']['minimal_fixed_price'],
'recurentPrice' => $item['_wiaas_payment']['recurrent_price'],
'servicesPrice' => $item['_wiaas_payment']['minimal_services_price'],
'fixedPrice' => $totalPrices['fixed_extra'],
'recurrentPrice' => $totalPrices['recurrent_extra'],
'servicesPrice' => $totalPrices['services_extra'],
),
'status' => 'available',
@@ -302,6 +306,15 @@ class Wiaas_Cart_API {
$order_id = WC()->checkout()->create_order(array());
$order = wc_get_order( $order_id );
// set order currency
$line_items = $order->get_items();
foreach ($line_items as $line_item) {
if (isset($line_item['wiaas_currency'])) {
$order->set_currency($line_item['wiaas_currency']);
break;
}
}
$order->set_shipping_city($delivery_address['city']);
$order->set_shipping_country($delivery_address['countryName']);
$order->set_shipping_address_1($delivery_address['detailedAddress']);

View File

@@ -0,0 +1,42 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
/**
* TODO: This is temporary implemetation and will probably be changed during work on pending wiaas cart task
* Class Wiaas_Document_API
*/
class Wiaas_Document_API {
/**
* Endpoint namespace.
*
* @var string
*/
private static $namespace = 'wiaas';
public static function register_routes() {
register_rest_route( self::$namespace, 'download-package-file', array(
'methods' => 'GET',
'permission_callback' => 'is_user_logged_in',
'callback' => array(__CLASS__, 'download_package_file'),
) );
}
/**
* Download package document
*/
public static function download_package_file() {
$document_id = $_GET['document_id'];
$package_id = $_GET['package_id'];
$package = wc_get_product($package_id);
$file = $package->get_file($document_id);
if ($file) {
WC_Download_Handler::download_file_force($package->get_file_download_path($document_id), $file->get_name());
}
}
}