product details
This commit is contained in:
@@ -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']);
|
||||
|
||||
Reference in New Issue
Block a user