Added feature for adding standard product in cart
This commit is contained in:
194
classes/Cart.php
194
classes/Cart.php
@@ -179,7 +179,7 @@ class CartCore extends ObjectModel
|
||||
const ADVANCE_PAYMENT_ONLY_PRODUCTS = 10;
|
||||
const ONLY_ROOMS = 11;
|
||||
const ONLY_ROOM_SERVICES = 12;
|
||||
const ONLY_SERVICE_PRODUCTS = 13;
|
||||
const ONLY_STANDALONE_PRODUCTS = 13;
|
||||
|
||||
const ONLY_ROOM_SERVICES_WITHOUT_CONVENIENCE_FEE = 14;
|
||||
const ONLY_ROOM_SERVICES_WITHOUT_AUTO_ADD = 16;
|
||||
@@ -776,14 +776,26 @@ class CartCore extends ObjectModel
|
||||
$row['total_wt'] += Tools::processPriceRounding($service['unit_price_tax_incl'], $service['quantity']);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$objHotelServiceProductCartDetail = new HotelServiceProductCartDetail();
|
||||
$unitPriceByProductTaxIncl = $objHotelServiceProductCartDetail->getHotelProductUnitPrice($this->id, (int)$row['id_product'], 0, true);
|
||||
$unitPriceByProductTaxExcl = $objHotelServiceProductCartDetail->getHotelProductUnitPrice($this->id, (int)$row['id_product'], 0, false);
|
||||
|
||||
} else if (ProductCore::SERVICE_PRODUCT_lINKED_WITH_HOTEL == $row['service_product_type']) {
|
||||
$row['total'] = 0;
|
||||
$row['total_wt'] = 0;
|
||||
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail();
|
||||
$price_tax_excl = $objRoomTypeServiceProductCartDetail->getProducts($this->id, $row['id_product'], 0, null, 0, null, 0, 1, false);
|
||||
$price_tax_incl = $objRoomTypeServiceProductCartDetail->getProducts($this->id, $row['id_product'], 0, null, 0, null, 0, 1, true);
|
||||
// Rounding as per configurations
|
||||
$row['total'] += Tools::processPriceRounding($unitPriceByProductTaxExcl, $row['cart_quantity']);
|
||||
$row['total_wt'] += Tools::processPriceRounding($unitPriceByProductTaxIncl, $row['cart_quantity']);
|
||||
$row['total'] += Tools::processPriceRounding($price_tax_excl, $row['cart_quantity']);
|
||||
$row['total_wt'] += Tools::processPriceRounding($price_tax_incl, $row['cart_quantity']);
|
||||
|
||||
$row['price_wt'] = $row['price_with_reduction'];
|
||||
} else {
|
||||
$row['total'] = 0;
|
||||
$row['total_wt'] = 0;
|
||||
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail();
|
||||
$price_tax_excl = $objRoomTypeServiceProductCartDetail->getProducts($this->id, $row['id_product'], 0, null, 0, null, 0, 1, false);
|
||||
$price_tax_incl = $objRoomTypeServiceProductCartDetail->getProducts($this->id, $row['id_product'], 0, null, 0, null, 0, 1, true);
|
||||
// Rounding as per configurations
|
||||
$row['total'] += Tools::processPriceRounding($price_tax_excl, $row['cart_quantity']);
|
||||
$row['total_wt'] += Tools::processPriceRounding($price_tax_incl, $row['cart_quantity']);
|
||||
|
||||
$row['price_wt'] = $row['price_with_reduction'];
|
||||
}
|
||||
@@ -826,7 +838,7 @@ class CartCore extends ObjectModel
|
||||
$serviceProducts = array();
|
||||
$context = Context::getContext();
|
||||
foreach ($productList as $key => $product) {
|
||||
if (!$product['booking_product'] && (Product::SERVICE_PRODUCT_WITHOUT_ROOMTYPE == $product['service_product_type'])) {
|
||||
if (!$product['booking_product'] && (Product::SERVICE_PRODUCT_STANDALONE == $product['service_product_type'])) {
|
||||
if (Validate::isLoadedObject(
|
||||
$objProduct = new Product($product['id_product'], false, $this->id_lang)
|
||||
)) {
|
||||
@@ -1560,7 +1572,7 @@ class CartCore extends ObjectModel
|
||||
Cart::ONLY_ROOM_SERVICES_WITHOUT_AUTO_ADD,
|
||||
Cart::ONLY_ROOM_SERVICES_WITH_AUTO_ADD_WITHOUT_CONVENIENCE_FEE,
|
||||
Cart::ONLY_CONVENIENCE_FEE,
|
||||
Cart::ONLY_SERVICE_PRODUCTS,
|
||||
Cart::ONLY_STANDALONE_PRODUCTS,
|
||||
Cart::ONLY_DISCOUNTS,
|
||||
Cart::BOTH,
|
||||
Cart::BOTH_WITHOUT_SHIPPING,
|
||||
@@ -1635,7 +1647,6 @@ class CartCore extends ObjectModel
|
||||
if (Tax::excludeTaxeOption()) {
|
||||
$with_taxes = false;
|
||||
}
|
||||
|
||||
$products_total = array();
|
||||
$ecotax_total = 0;
|
||||
$totalDemandsPrice = 0;
|
||||
@@ -1644,7 +1655,7 @@ class CartCore extends ObjectModel
|
||||
// skip products if selection os for only room or only normal products
|
||||
if ($product['booking_product']) {
|
||||
if ($type == Cart::ONLY_ROOM_SERVICES
|
||||
|| $type == Cart::ONLY_SERVICE_PRODUCTS
|
||||
|| $type == Cart::ONLY_STANDALONE_PRODUCTS
|
||||
|| $type == Cart::ONLY_CONVENIENCE_FEE
|
||||
|| $type == Cart::ONLY_ROOM_SERVICES_WITHOUT_AUTO_ADD
|
||||
|| $type == Cart::ONLY_ROOM_SERVICES_WITHOUT_CONVENIENCE_FEE
|
||||
@@ -1658,7 +1669,7 @@ class CartCore extends ObjectModel
|
||||
}
|
||||
|
||||
if (Product::SERVICE_PRODUCT_WITH_ROOMTYPE == $product['service_product_type']) {
|
||||
if ($type == Cart::ONLY_SERVICE_PRODUCTS) {
|
||||
if ($type == Cart::ONLY_STANDALONE_PRODUCTS) {
|
||||
continue;
|
||||
}
|
||||
if ($product['auto_add_to_cart']) {
|
||||
@@ -1685,8 +1696,13 @@ class CartCore extends ObjectModel
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($type == Cart::ONLY_ROOM_SERVICES) {
|
||||
} elseif (Product::SERVICE_PRODUCT_STANDALONE == $product['service_product_type'] || Product::SERVICE_PRODUCT_lINKED_WITH_HOTEL == $product['service_product_type']) {
|
||||
if ($type == Cart::ONLY_ROOM_SERVICES
|
||||
|| $type == Cart::ONLY_CONVENIENCE_FEE
|
||||
|| $type == Cart::ONLY_ROOM_SERVICES_WITHOUT_AUTO_ADD
|
||||
|| $type == Cart::ONLY_ROOM_SERVICES_WITHOUT_CONVENIENCE_FEE
|
||||
|| $type == Cart::ONLY_ROOM_SERVICES_WITH_AUTO_ADD_WITHOUT_CONVENIENCE_FEE
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -1742,10 +1758,48 @@ class CartCore extends ObjectModel
|
||||
} elseif (!isset($products_total[$id_tax_rules_group.'_'.$id_address])) {
|
||||
$products_total[$id_tax_rules_group.'_'.$id_address] = 0;
|
||||
}
|
||||
if (!$product['booking_product'] && Product::SERVICE_PRODUCT_STANDALONE == $product['service_product_type']) {
|
||||
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail();
|
||||
if ($servicePorducts = $objRoomTypeServiceProductCartDetail->getProducts(
|
||||
$this->id,
|
||||
(int)$product['id_product']
|
||||
)) {
|
||||
foreach ($servicePorducts as $servicePorduct) {
|
||||
if ($with_taxes) {
|
||||
$priceAdd = $servicePorduct['unit_price_tax_incl'];
|
||||
} else {
|
||||
$priceAdd = $servicePorduct['unit_price_tax_excl'];
|
||||
}
|
||||
if ($ps_round_type == Order::ROUND_TOTAL) {
|
||||
$products_total[$id_tax_rules_group.'_'.$id_address] += Tools::processPriceRounding($priceAdd, (int)$servicePorduct['quantity']);
|
||||
} else {
|
||||
$products_total[$id_tax_rules_group] += Tools::processPriceRounding($priceAdd, (int)$servicePorduct['quantity']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$product['booking_product'] && Product::SERVICE_PRODUCT_WITHOUT_ROOMTYPE == $product['service_product_type']) {
|
||||
$objHotelServiceProductCartDetail = new HotelServiceProductCartDetail();
|
||||
$price = $objHotelServiceProductCartDetail->getHotelProductUnitPrice($this->id, (int)$product['id_product'], 0, $with_taxes);
|
||||
} else if (!$product['booking_product'] && Product::SERVICE_PRODUCT_lINKED_WITH_HOTEL == $product['service_product_type']) {
|
||||
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail();
|
||||
if ($servicePorducts = $objRoomTypeServiceProductCartDetail->getProducts(
|
||||
$this->id,
|
||||
(int)$product['id_product'],
|
||||
0,
|
||||
isset($product['id_hotel']) ? $product['id_hotel'] : 0
|
||||
)) {
|
||||
foreach ($servicePorducts as $servicePorduct) {
|
||||
if ($with_taxes) {
|
||||
$priceAdd = $servicePorduct['unit_price_tax_incl'];
|
||||
} else {
|
||||
$priceAdd = $servicePorduct['unit_price_tax_excl'];
|
||||
}
|
||||
|
||||
if ($ps_round_type == Order::ROUND_TOTAL) {
|
||||
$products_total[$id_tax_rules_group.'_'.$id_address] += Tools::processPriceRounding($priceAdd, (int)$servicePorduct['quantity']);
|
||||
} else {
|
||||
$products_total[$id_tax_rules_group] += Tools::processPriceRounding($priceAdd, (int)$servicePorduct['quantity']);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (!$product['booking_product'] && Product::SERVICE_PRODUCT_WITH_ROOMTYPE == $product['service_product_type']) {
|
||||
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail();
|
||||
if ($servicesWithRoom = $objRoomTypeServiceProductCartDetail->getServiceProductsInCart(
|
||||
@@ -1871,7 +1925,7 @@ class CartCore extends ObjectModel
|
||||
Cart::ONLY_ROOMS,
|
||||
Cart::ADVANCE_PAYMENT_ONLY_PRODUCTS,
|
||||
Cart::ONLY_ROOM_SERVICES,
|
||||
Cart::ONLY_SERVICE_PRODUCTS,
|
||||
Cart::ONLY_STANDALONE_PRODUCTS,
|
||||
Cart::ONLY_CONVENIENCE_FEE,
|
||||
Cart::ONLY_ROOM_SERVICES_WITHOUT_AUTO_ADD,
|
||||
Cart::ONLY_ROOM_SERVICES_WITHOUT_CONVENIENCE_FEE,
|
||||
@@ -2295,10 +2349,10 @@ class CartCore extends ObjectModel
|
||||
// Step 6 : Break $package_list hotel wise
|
||||
$orderPackage = array();
|
||||
$serviceProducts = array();
|
||||
$standaloneProduct = array();
|
||||
$objRoomType = new HotelRoomType();
|
||||
$objHtlCartBookingData = new HotelCartBookingData();
|
||||
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail();
|
||||
$objHotelServiceProductCartDetail = new HotelServiceProductCartDetail();
|
||||
foreach ($final_package_list as $id_address => $packages) {
|
||||
foreach ($packages as $id_package => $package) {
|
||||
foreach ($package['product_list'] as $product) {
|
||||
@@ -2384,32 +2438,64 @@ class CartCore extends ObjectModel
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif (Product::SERVICE_PRODUCT_STANDALONE == $product['service_product_type']) {
|
||||
if (!isset($standaloneProduct[$id_address])) {
|
||||
$standaloneProduct[$id_address] = array(
|
||||
'product_list' => array(),
|
||||
'warehouse_list' => $package['warehouse_list'],
|
||||
'carrier_list' => $product['carrier_list'],
|
||||
'id_warehouse' => $package['id_warehouse'],
|
||||
'id_carrier' => isset($package['id_carrier']) ? $package['id_carrier'] : 0
|
||||
);
|
||||
}
|
||||
$standaloneProduct[$id_address]['product_list'][] = $product;
|
||||
} else {
|
||||
if ($selectedServiceProducts = $objHotelServiceProductCartDetail->getHotelProducts($this->id, $product
|
||||
['id_product'])) {
|
||||
if ($selectedServiceProducts = $objRoomTypeServiceProductCartDetail->getProducts($this->id, $product['id_product'])) {
|
||||
$array = array();
|
||||
foreach($selectedServiceProducts as $hotelProduct) {
|
||||
if (isset($array[$hotelProduct['id_hotel']])) {
|
||||
$array[$hotelProduct['id_hotel']]['total_price_tax_excl'] += $hotelProduct['total_price_tax_excl'];
|
||||
$array[$hotelProduct['id_hotel']]['total_price_tax_incl'] += $hotelProduct['total_price_tax_incl'];
|
||||
$array[$hotelProduct['id_hotel']]['quantity'] += $hotelProduct['quantity'];
|
||||
} else {
|
||||
$array[$hotelProduct['id_hotel']] = array(
|
||||
'quantity' => $hotelProduct['quantity'],
|
||||
'id_hotel' => $hotelProduct['id_hotel'],
|
||||
'total_price_tax_excl' => $hotelProduct['total_price_tax_excl'],
|
||||
'total_price_tax_incl' => $hotelProduct['total_price_tax_incl'],
|
||||
);
|
||||
}
|
||||
}
|
||||
foreach($array as $hotelProduct) {
|
||||
$serviceProduct = $product;
|
||||
$serviceProduct['cart_quantity'] = $hotelProduct['quantity'];
|
||||
$unitPrice = $objHotelServiceProductCartDetail->getHotelProductUnitPrice($this->id, $product['id_product'], $hotelProduct['id_hotel'], false);
|
||||
$unitPriceWt = $objHotelServiceProductCartDetail->getHotelProductUnitPrice($this->id, $product['id_product'], $hotelProduct['id_hotel'], true);
|
||||
$serviceProduct['total'] = $unitPrice * $hotelProduct['quantity'];
|
||||
$serviceProduct['total_wt'] = $unitPriceWt * $hotelProduct['quantity'];
|
||||
$serviceProduct['price'] = $unitPrice;
|
||||
$serviceProduct['price_wt'] = $unitPriceWt;
|
||||
$serviceProduct['id_hotel'] = $hotelProduct['id_hotel'];
|
||||
$serviceProduct['total'] = $hotelProduct['total_price_tax_excl'];
|
||||
$serviceProduct['total_wt'] = $hotelProduct['total_price_tax_incl'];
|
||||
$serviceProduct['price'] = $hotelProduct['total_price_tax_excl'] / $product['cart_quantity'];
|
||||
$serviceProduct['price_wt'] = $hotelProduct['total_price_tax_incl'] / $product['cart_quantity'];
|
||||
// if (!empty($hotelProducts['products'])) {
|
||||
// foreach($hotelProducts['products'] as $hotelProduct) {
|
||||
$serviceProducts[$id_address][$hotelProduct['id_hotel']] = array(
|
||||
'product_list' => array(
|
||||
$serviceProduct
|
||||
),
|
||||
'id_hotel' => $hotelProduct['id_hotel'],
|
||||
'warehouse_list' => $package['warehouse_list'],
|
||||
'carrier_list' => $product['carrier_list'],
|
||||
'id_warehouse' => $package['id_warehouse'],
|
||||
'id_carrier' => isset($package['id_carrier']) ? $package['id_carrier'] : 0
|
||||
);
|
||||
// }
|
||||
// }
|
||||
$orderPackage[$id_address][$hotelProduct['id_hotel']]['product_list'][] = $serviceProduct;
|
||||
if (!isset($orderPackage[$id_address][$hotelProduct['id_hotel']]['id_hotel'])) {
|
||||
$orderPackage[$id_address][$hotelProduct['id_hotel']]['id_hotel'] = $hotelProduct['id_hotel'];
|
||||
}
|
||||
if (!isset($orderPackage[$id_address][$hotelProduct['id_hotel']]['carrier_list'])) {
|
||||
$orderPackage[$id_address][$hotelProduct['id_hotel']]['carrier_list'] = $product['carrier_list'];
|
||||
} else {
|
||||
$orderPackage[$id_address][$hotelProduct['id_hotel']]['carrier_list'] = array_intersect($orderPackage[$id_address][$hotelProduct['id_hotel']]['carrier_list'], $product['carrier_list']);
|
||||
}
|
||||
if (!isset($orderPackage[$id_address][$hotelProduct['id_hotel']]['warehouse_list'])) {
|
||||
$orderPackage[$id_address][$hotelProduct['id_hotel']]['warehouse_list'] = $package['warehouse_list'];
|
||||
}
|
||||
if (!isset($orderPackage[$id_address][$hotelProduct['id_hotel']]['id_warehouse'])) {
|
||||
$orderPackage[$id_address][$hotelProduct['id_hotel']]['id_warehouse'] = $package['id_warehouse'];
|
||||
}
|
||||
if (isset($package['id_carrier'])) {
|
||||
if (!isset($orderPackage[$id_address][$hotelProduct['id_hotel']]['id_carrier'])) {
|
||||
$orderPackage[$id_address][$hotelProduct['id_hotel']]['id_carrier'] = $package['id_carrier'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2421,14 +2507,18 @@ class CartCore extends ObjectModel
|
||||
$hotelWisePackageList = array();
|
||||
$numHotels = 0;
|
||||
|
||||
|
||||
if (!empty($serviceProducts)) {
|
||||
foreach ($serviceProducts as $id_address => $packagesByHotels) {
|
||||
foreach ($packagesByHotels as $packageByHotel) {
|
||||
$hotelWisePackageList[$id_address][] = $packageByHotel;
|
||||
}
|
||||
if (!empty($standaloneProduct)) {
|
||||
foreach ($standaloneProduct as $id_address => $packagesByAddress) {
|
||||
$hotelWisePackageList[$id_address][] = $packagesByAddress;
|
||||
}
|
||||
}
|
||||
// if (!empty($serviceProducts)) {
|
||||
// foreach ($serviceProducts as $id_address => $packagesByHotels) {
|
||||
// foreach ($packagesByHotels as $packageByHotel) {
|
||||
// $hotelWisePackageList[$id_address][] = $packageByHotel;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
foreach ($orderPackage as $id_address => $packageByAddress) {
|
||||
$numHotels += count($packageByAddress);
|
||||
foreach ($packageByAddress as $id_package => $package) {
|
||||
@@ -3661,8 +3751,8 @@ class CartCore extends ObjectModel
|
||||
$convenience_fee_wt = $this->getOrderTotal(true, Cart::ONLY_CONVENIENCE_FEE);
|
||||
$convenience_fee = $this->getOrderTotal(false, Cart::ONLY_CONVENIENCE_FEE);
|
||||
$convenience_fee_tax = $convenience_fee_wt - $convenience_fee;
|
||||
$total_service_products_wt = $this->getOrderTotal(true, Cart::ONLY_SERVICE_PRODUCTS);
|
||||
$total_service_products = $this->getOrderTotal(false, Cart::ONLY_SERVICE_PRODUCTS);
|
||||
$total_standalone_service_products_wt = $this->getOrderTotal(true, Cart::ONLY_STANDALONE_PRODUCTS);
|
||||
$total_standalone_service_products = $this->getOrderTotal(false, Cart::ONLY_STANDALONE_PRODUCTS);
|
||||
$total_discounts = $this->getOrderTotal(true, Cart::ONLY_DISCOUNTS);
|
||||
$total_discounts_tax_exc = $this->getOrderTotal(false, Cart::ONLY_DISCOUNTS);
|
||||
$objCartBookingData = new HotelCartBookingData();
|
||||
@@ -3772,8 +3862,8 @@ class CartCore extends ObjectModel
|
||||
}
|
||||
|
||||
$objHotelAdvancedPayment = new HotelAdvancedPayment();
|
||||
$total_rooms_with_services_without_discount_te = $total_rooms + $total_demands + $total_additional_services + $total_additional_services_auto_add;
|
||||
$total_rooms_with_services_without_discount_ti = $total_rooms_wt + $total_demands_wt + $total_additional_services_wt + $total_additional_services_auto_add_wt;
|
||||
$total_rooms_with_services_without_discount_te = $total_rooms + $total_demands + $total_additional_services + $total_additional_services_auto_add + $total_standalone_service_products;
|
||||
$total_rooms_with_services_without_discount_ti = $total_rooms_wt + $total_demands_wt + $total_additional_services_wt + $total_additional_services_auto_add_wt + $total_standalone_service_products_wt;
|
||||
|
||||
$cart_total_without_discount_te = $total_rooms_with_services_without_discount_te + $convenience_fee;
|
||||
$cart_total_without_discount_ti = $total_rooms_with_services_without_discount_ti + $convenience_fee_wt;
|
||||
@@ -3809,8 +3899,8 @@ class CartCore extends ObjectModel
|
||||
'convenience_fee_wt' => $convenience_fee_wt,
|
||||
'convenience_fee' => $convenience_fee,
|
||||
'convenience_fee_tax' => $convenience_fee_tax,
|
||||
'total_service_products_wt' => $total_service_products_wt,
|
||||
'total_service_products' => $total_service_products,
|
||||
'total_standalone_service_products_wt' => $total_standalone_service_products_wt,
|
||||
'total_standalone_service_products' => $total_standalone_service_products,
|
||||
'total_extra_demands_wt' => $total_demands_wt,
|
||||
'total_extra_demands' => $total_demands,
|
||||
'total_price' => $base_total_tax_inc,
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
use Twig\Node\Expression\Binary\AddBinary;
|
||||
|
||||
abstract class PaymentModuleCore extends Module
|
||||
{
|
||||
const DEBUG_MODE = false;
|
||||
@@ -286,9 +288,19 @@ abstract class PaymentModuleCore extends Module
|
||||
$order->id_customer = (int)$this->context->cart->id_customer;
|
||||
$order->id_address_invoice = (int)$this->context->cart->id_address_invoice;
|
||||
$order->id_address_delivery = (int)$id_address;
|
||||
$addressInfo = HotelBranchInformation::getAddress($package['id_hotel']);
|
||||
if (isset($package['id_hotel']) && $package['id_hotel']) {
|
||||
$addressInfo = HotelBranchInformation::getAddress($package['id_hotel']);
|
||||
$order->id_address_tax = $addressInfo['id_address'];
|
||||
} else {
|
||||
$order->id_address_tax = $order->id_address_invoice;
|
||||
}
|
||||
|
||||
// $id_tax_rules_group = (int)Product::getIdTaxRulesGroupByIdProduct((int)11, $this->context);
|
||||
// $address = new Address($order->id_address_tax);
|
||||
// $tax_manager = TaxManagerFactory::getManager($address, $id_tax_rules_group);
|
||||
// // ddd($tax_manager);
|
||||
// ddd($tax_manager->getTaxCalculator());
|
||||
|
||||
$order->id_address_tax = $addressInfo['id_address'];
|
||||
$order->id_currency = $this->context->currency->id;
|
||||
$order->id_lang = (int)$this->context->cart->id_lang;
|
||||
$order->id_cart = (int)$this->context->cart->id;
|
||||
@@ -495,6 +507,7 @@ abstract class PaymentModuleCore extends Module
|
||||
// Make sure CartRule caches are empty
|
||||
CartRule::cleanCache();
|
||||
$objRoomType = new HotelRoomType();
|
||||
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail();
|
||||
$cart_rules = $this->context->cart->getCartRules();
|
||||
foreach ($order_detail_list as $key => $order_detail) {
|
||||
/** @var OrderDetail $order_detail */
|
||||
@@ -587,7 +600,12 @@ abstract class PaymentModuleCore extends Module
|
||||
$idHotel = $roomDetail['id_hotel'];
|
||||
}
|
||||
}
|
||||
if (!$product['booking_product'] && $product['service_product_type'] == Product::SERVICE_PRODUCT_WITHOUT_ROOMTYPE) {
|
||||
if (!$product['booking_product']
|
||||
&& (
|
||||
$product['service_product_type'] == Product::SERVICE_PRODUCT_STANDALONE
|
||||
|| $product['service_product_type'] == Product::SERVICE_PRODUCT_lINKED_WITH_HOTEL
|
||||
)
|
||||
) {
|
||||
$cover_image_arr = $objProduct->getCover($product['id_product']);
|
||||
|
||||
if (!empty($cover_image_arr)) {
|
||||
@@ -596,7 +614,11 @@ abstract class PaymentModuleCore extends Module
|
||||
$cover_img = $this->context->link->getImageLink($product['link_rewrite'], $this->context->language->iso_code."-default", 'small_default');
|
||||
}
|
||||
$product_var_tpl['cover_img'] = $cover_img;
|
||||
$orderServiceProducts[] = $product_var_tpl;
|
||||
$serviceProducts = $objRoomTypeServiceProductCartDetail->getProducts($order->id_cart, $product['id_product']);
|
||||
|
||||
foreach ($serviceProducts as $serviceProduct) {
|
||||
$orderServiceProducts[] = array_merge($product_var_tpl, $serviceProduct);
|
||||
}
|
||||
}
|
||||
} // end foreach ($products)
|
||||
|
||||
@@ -727,7 +749,11 @@ abstract class PaymentModuleCore extends Module
|
||||
$maxOverbookingCount = 0;
|
||||
foreach ($order->product_list as $product) {
|
||||
$idProduct = $product['id_product'];
|
||||
$cartBookingData = $objCartBookingData->getOnlyCartBookingData($this->context->cart->id, $this->context->cart->id_guest, $idProduct);
|
||||
$cartBookingData = $objCartBookingData->getOnlyCartBookingData(
|
||||
$this->context->cart->id,
|
||||
$this->context->cart->id_guest,
|
||||
$idProduct
|
||||
);
|
||||
if ($cartBookingData) {
|
||||
foreach ($cartBookingData as $bookingInfo) {
|
||||
$objCartBookingData = new HotelCartBookingData($bookingInfo['id']);
|
||||
@@ -936,41 +962,95 @@ abstract class PaymentModuleCore extends Module
|
||||
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail();
|
||||
foreach($normalProducts as $product) {
|
||||
$idProduct = $product['id_product'];
|
||||
if ($cartAdditialServices = $objRoomTypeServiceProductCartDetail->getServiceProductsInCart(
|
||||
$this->context->cart->id,
|
||||
$product['id_product'],
|
||||
isset($product['id_hotel']) ? $product['id_hotel'] : 0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
null,
|
||||
null
|
||||
)) {
|
||||
$idOrderDetail = $objBookingDetail->getPsOrderDetailIdByIdProduct($idProduct, $order->id);
|
||||
foreach ($cartAdditialServices as $additionalService) {
|
||||
$roomBookingDetail = $objBookingDetail->getRowByIdOrderIdProductInDateRange(
|
||||
$order->id,
|
||||
$additionalService['room_type_id_product'],
|
||||
$additionalService['date_from'],
|
||||
$additionalService['date_to'],
|
||||
$additionalService['id_room']
|
||||
);
|
||||
$objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail();
|
||||
$objRoomTypeServiceProductOrderDetail->id_product = $idProduct;
|
||||
$objRoomTypeServiceProductOrderDetail->id_order = $order->id;
|
||||
$objRoomTypeServiceProductOrderDetail->id_order_detail = $idOrderDetail;
|
||||
$objRoomTypeServiceProductOrderDetail->id_cart = $this->context->cart->id;
|
||||
$objRoomTypeServiceProductOrderDetail->id_htl_booking_detail = $roomBookingDetail['id'];
|
||||
$objRoomTypeServiceProductOrderDetail->unit_price_tax_excl = $additionalService['unit_price_tax_excl'];
|
||||
$objRoomTypeServiceProductOrderDetail->unit_price_tax_incl = $additionalService['unit_price_tax_incl'];
|
||||
$objRoomTypeServiceProductOrderDetail->total_price_tax_excl = $additionalService['total_price_tax_excl'];
|
||||
$objRoomTypeServiceProductOrderDetail->total_price_tax_incl = $additionalService['total_price_tax_incl'];
|
||||
$objRoomTypeServiceProductOrderDetail->name = $product['name'];
|
||||
$objRoomTypeServiceProductOrderDetail->quantity = $additionalService['quantity'];
|
||||
$objRoomTypeServiceProductOrderDetail->auto_added = $additionalService['auto_add_to_cart'];
|
||||
$objRoomTypeServiceProductOrderDetail->save();
|
||||
if (Product::SERVICE_PRODUCT_WITH_ROOMTYPE == $product['service_product_type']) {
|
||||
if ($cartAdditialServices = $objRoomTypeServiceProductCartDetail->getServiceProductsInCart(
|
||||
$this->context->cart->id,
|
||||
$product['id_product'],
|
||||
isset($product['id_hotel']) ? $product['id_hotel'] : 0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
null,
|
||||
null
|
||||
)) {
|
||||
$idOrderDetail = $objBookingDetail->getPsOrderDetailIdByIdProduct($idProduct, $order->id);
|
||||
foreach ($cartAdditialServices as $additionalService) {
|
||||
$roomBookingDetail = $objBookingDetail->getRowByIdOrderIdProductInDateRange(
|
||||
$order->id,
|
||||
$additionalService['room_type_id_product'],
|
||||
$additionalService['date_from'],
|
||||
$additionalService['date_to'],
|
||||
$additionalService['id_room']
|
||||
);
|
||||
$objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail();
|
||||
$objRoomTypeServiceProductOrderDetail->id_product = $idProduct;
|
||||
$objRoomTypeServiceProductOrderDetail->id_order = $order->id;
|
||||
$objRoomTypeServiceProductOrderDetail->id_order_detail = $idOrderDetail;
|
||||
$objRoomTypeServiceProductOrderDetail->id_cart = $this->context->cart->id;
|
||||
$objRoomTypeServiceProductOrderDetail->id_htl_booking_detail = $roomBookingDetail['id'];
|
||||
$objRoomTypeServiceProductOrderDetail->unit_price_tax_excl = $additionalService['unit_price_tax_excl'];
|
||||
$objRoomTypeServiceProductOrderDetail->unit_price_tax_incl = $additionalService['unit_price_tax_incl'];
|
||||
$objRoomTypeServiceProductOrderDetail->total_price_tax_excl = $additionalService['total_price_tax_excl'];
|
||||
$objRoomTypeServiceProductOrderDetail->total_price_tax_incl = $additionalService['total_price_tax_incl'];
|
||||
$objRoomTypeServiceProductOrderDetail->name = $product['name'];
|
||||
$objRoomTypeServiceProductOrderDetail->quantity = $additionalService['quantity'];
|
||||
$objRoomTypeServiceProductOrderDetail->auto_added = $additionalService['auto_add_to_cart'];
|
||||
$objRoomTypeServiceProductOrderDetail->save();
|
||||
}
|
||||
}
|
||||
} elseif (Product::SERVICE_PRODUCT_lINKED_WITH_HOTEL == $product['service_product_type']) {
|
||||
if ($hotelProducts = $objRoomTypeServiceProductCartDetail->getProducts(
|
||||
$this->context->cart->id,
|
||||
$product['id_product'],
|
||||
ProductCore::SERVICE_PRODUCT_lINKED_WITH_HOTEL,
|
||||
isset($product['id_hotel']) ? $product['id_hotel'] : 0
|
||||
)) {
|
||||
$idOrderDetail = $objBookingDetail->getPsOrderDetailIdByIdProduct($idProduct, $order->id);
|
||||
foreach ($hotelProducts as $hotelProduct) {
|
||||
$objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail();
|
||||
$objRoomTypeServiceProductOrderDetail->id_product = $idProduct;
|
||||
$objRoomTypeServiceProductOrderDetail->id_service_product_option = $hotelProduct['id_service_product_option'];
|
||||
$objRoomTypeServiceProductOrderDetail->id_order = $order->id;
|
||||
$objRoomTypeServiceProductOrderDetail->id_order_detail = $idOrderDetail;
|
||||
$objRoomTypeServiceProductOrderDetail->id_cart = $this->context->cart->id;
|
||||
$objRoomTypeServiceProductOrderDetail->id_hotel = $product['id_hotel'];
|
||||
$objRoomTypeServiceProductOrderDetail->unit_price_tax_excl = $hotelProduct['unit_price_tax_excl'];
|
||||
$objRoomTypeServiceProductOrderDetail->unit_price_tax_incl = $hotelProduct['unit_price_tax_incl'];
|
||||
$objRoomTypeServiceProductOrderDetail->total_price_tax_excl = $hotelProduct['total_price_tax_excl'];
|
||||
$objRoomTypeServiceProductOrderDetail->total_price_tax_incl = $hotelProduct['total_price_tax_incl'];
|
||||
$objRoomTypeServiceProductOrderDetail->name = $hotelProduct['name'];
|
||||
$objRoomTypeServiceProductOrderDetail->option_name = $hotelProduct['option_name'];
|
||||
$objRoomTypeServiceProductOrderDetail->quantity = $hotelProduct['quantity'];
|
||||
$objRoomTypeServiceProductOrderDetail->save();
|
||||
|
||||
}
|
||||
}
|
||||
} elseif (Product::SERVICE_PRODUCT_STANDALONE == $product['service_product_type']) {
|
||||
if ($standaloneProducts = $objRoomTypeServiceProductCartDetail->getProducts(
|
||||
$this->context->cart->id,
|
||||
$product['id_product'],
|
||||
ProductCore::SERVICE_PRODUCT_STANDALONE
|
||||
)) {
|
||||
$idOrderDetail = $objBookingDetail->getPsOrderDetailIdByIdProduct($idProduct, $order->id);
|
||||
foreach ($standaloneProducts as $standaloneProduct) {
|
||||
$objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail();
|
||||
$objRoomTypeServiceProductOrderDetail->id_product = $idProduct;
|
||||
$objRoomTypeServiceProductOrderDetail->id_service_product_option = $standaloneProduct['id_service_product_option'];
|
||||
$objRoomTypeServiceProductOrderDetail->id_order = $order->id;
|
||||
$objRoomTypeServiceProductOrderDetail->id_order_detail = $idOrderDetail;
|
||||
$objRoomTypeServiceProductOrderDetail->id_cart = $this->context->cart->id;
|
||||
$objRoomTypeServiceProductOrderDetail->unit_price_tax_excl = $standaloneProduct['unit_price_tax_excl'];
|
||||
$objRoomTypeServiceProductOrderDetail->unit_price_tax_incl = $standaloneProduct['unit_price_tax_incl'];
|
||||
$objRoomTypeServiceProductOrderDetail->total_price_tax_excl = $standaloneProduct['total_price_tax_excl'];
|
||||
$objRoomTypeServiceProductOrderDetail->total_price_tax_incl = $standaloneProduct['total_price_tax_incl'];
|
||||
$objRoomTypeServiceProductOrderDetail->name = $standaloneProduct['name'];
|
||||
$objRoomTypeServiceProductOrderDetail->option_name = $standaloneProduct['option_name'];
|
||||
$objRoomTypeServiceProductOrderDetail->quantity = $standaloneProduct['quantity'];
|
||||
$objRoomTypeServiceProductOrderDetail->save();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1076,9 +1156,8 @@ abstract class PaymentModuleCore extends Module
|
||||
|
||||
$extra_demands_details_html = $this->getEmailTemplateContent('booking_extra_demands.tpl', Mail::TYPE_HTML, $cart_booking_data['cart_htl_data']);
|
||||
$extra_demands_details_text = $this->getEmailTemplateContent('booking_extra_demands_text.tpl', Mail::TYPE_HTML, $cart_booking_data['cart_htl_data']);
|
||||
|
||||
$normal_products_data_html = $this->getEmailTemplateContent('hotel-service-product-data.tpl', Mail::TYPE_TEXT, $orderServiceProducts);
|
||||
$normal_products_data_txt = $this->getEmailTemplateContent('hotel-service-product-data-text.tpl', Mail::TYPE_TEXT, $orderServiceProducts);
|
||||
$normal_products_data_html = $this->getEmailTemplateContent('service-product-data.tpl', Mail::TYPE_TEXT, $orderServiceProducts);
|
||||
$normal_products_data_txt = $this->getEmailTemplateContent('service-product-data-text.tpl', Mail::TYPE_TEXT, $orderServiceProducts);
|
||||
|
||||
// total room price
|
||||
$room_price_tax_excl = $order->getTotalProductsWithoutTaxes(false, true) + $order->getTotalProductsWithoutTaxes(false, false, Product::SERVICE_PRODUCT_WITH_ROOMTYPE, 1, Product::PRICE_ADDITION_TYPE_WITH_ROOM);
|
||||
@@ -1096,9 +1175,9 @@ abstract class PaymentModuleCore extends Module
|
||||
$total_convenience_fee_tax = $total_convenience_fee_ti - $total_convenience_fee_te;
|
||||
|
||||
// service products
|
||||
// $service_products_price_tax_excl = $order->getTotalProductsWithoutTaxes(false, false, Product::SERVICE_PRODUCT_WITHOUT_ROOMTYPE);
|
||||
// $service_products_price_tax_incl = $order->getTotalProductsWithTaxes(false, false, Product::SERVICE_PRODUCT_WITHOUT_ROOMTYPE);
|
||||
// $service_products_tax = ($order->getTotalProductsWithTaxes(false, false, Product::SERVICE_PRODUCT_WITHOUT_ROOMTYPE) - $order->getTotalProductsWithoutTaxes(false, false, Product::SERVICE_PRODUCT_WITHOUT_ROOMTYPE));
|
||||
// $service_products_price_tax_excl = $order->getTotalProductsWithoutTaxes(false, false, Product::SERVICE_PRODUCT_STANDALONE);
|
||||
// $service_products_price_tax_incl = $order->getTotalProductsWithTaxes(false, false, Product::SERVICE_PRODUCT_STANDALONE);
|
||||
// $service_products_tax = ($order->getTotalProductsWithTaxes(false, false, Product::SERVICE_PRODUCT_STANDALONE) - $order->getTotalProductsWithoutTaxes(false, false, Product::SERVICE_PRODUCT_STANDALONE));
|
||||
$total_order_tax = $room_tax + $additional_service_tax + $total_convenience_fee_tax;
|
||||
|
||||
$idOrderHotel = HotelBookingDetail::getIdHotelByIdOrder($order->id);
|
||||
|
||||
@@ -551,7 +551,8 @@ class ProductCore extends ObjectModel
|
||||
const PRICE_DISPALY_INDIVISUAL = 2;
|
||||
|
||||
const SERVICE_PRODUCT_WITH_ROOMTYPE = 1;
|
||||
const SERVICE_PRODUCT_WITHOUT_ROOMTYPE = 2;
|
||||
const SERVICE_PRODUCT_STANDALONE = 2;
|
||||
const SERVICE_PRODUCT_lINKED_WITH_HOTEL = 3;
|
||||
|
||||
const PRICE_ADDITION_TYPE_WITH_ROOM = 1;
|
||||
const PRICE_ADDITION_TYPE_INDEPENDENT = 2;
|
||||
@@ -931,6 +932,14 @@ class ProductCore extends ObjectModel
|
||||
), 'id_product = '.(int)$id_product);
|
||||
}
|
||||
|
||||
public static function getServiceProductType($id_product) {
|
||||
return Db::getInstance()->getValue(
|
||||
'SELECT p.`service_product_type`
|
||||
FROM `'._DB_PREFIX_.'product` p '.Shop::addSqlAssociation('product', 'p').'
|
||||
WHERE p.`id_product` = '.(int)$id_product
|
||||
);
|
||||
}
|
||||
|
||||
public static function getProductPriceCalculation($id_product) {
|
||||
return Db::getInstance()->getValue(
|
||||
'SELECT product_shop.`price_calculation_method`
|
||||
@@ -3100,6 +3109,10 @@ class ProductCore extends ObjectModel
|
||||
}
|
||||
}
|
||||
|
||||
if (is_null($id_customer) && Validate::isLoadedObject($context->customer)) {
|
||||
$id_customer = $context->customer->id;
|
||||
}
|
||||
|
||||
$id_currency = Validate::isLoadedObject($context->currency) ? (int)$context->currency->id : (int)Configuration::get('PS_CURRENCY_DEFAULT');
|
||||
|
||||
// retrieve address informations
|
||||
@@ -3112,6 +3125,14 @@ class ProductCore extends ObjectModel
|
||||
if ($id_product_roomtype) {
|
||||
// if room type is provided with product then we know that the service product price should be calculated accroding to roomt type
|
||||
$id_address = Cart::getIdAddressForTaxCalculation($id_product_roomtype);
|
||||
} else {
|
||||
if (Product::getServiceProductType($id_product) == ProductCore::SERVICE_PRODUCT_lINKED_WITH_HOTEL) {
|
||||
|
||||
} else {
|
||||
if (isset($id_customer)) {
|
||||
$id_address = (int)Address::getFirstCustomerAddressId($id_customer);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$id_address = Cart::getIdAddressForTaxCalculation($id_product);
|
||||
@@ -3140,10 +3161,6 @@ class ProductCore extends ObjectModel
|
||||
$usetax = false;
|
||||
}
|
||||
|
||||
if (is_null($id_customer) && Validate::isLoadedObject($context->customer)) {
|
||||
$id_customer = $context->customer->id;
|
||||
}
|
||||
|
||||
$return = Product::priceCalculation(
|
||||
$context->shop->id,
|
||||
$id_product,
|
||||
@@ -3220,6 +3237,13 @@ class ProductCore extends ObjectModel
|
||||
$id_customer = 0;
|
||||
}
|
||||
|
||||
if ($id_product_attribute) {
|
||||
$id_service_product_option = $id_product_attribute;
|
||||
$id_product_attribute = null;
|
||||
} else {
|
||||
$id_service_product_option = null;
|
||||
}
|
||||
|
||||
if ($id_product_attribute === null) {
|
||||
$id_product_attribute = Product::getDefaultAttribute($id_product);
|
||||
}
|
||||
@@ -3227,7 +3251,7 @@ class ProductCore extends ObjectModel
|
||||
$cache_id = (int)$id_product.'-'.(int)$id_shop.'-'.(int)$id_currency.'-'.(int)$id_country.'-'.$id_state.'-'.$zipcode.'-'.(int)$id_group.
|
||||
'-'.(int)$quantity.'-'.(int)$id_product_attribute.
|
||||
'-'.(int)$with_ecotax.'-'.(int)$id_customer.'-'.(int)$use_group_reduction.'-'.(int)$id_cart.'-'.(int)$real_quantity.
|
||||
'-'.($only_reduc?'1':'0').'-'.($use_reduc?'1':'0').'-'.($use_tax?'1':'0').'-'.(int)$decimals.'-'.($id_product_roomtype?(int)$id_product_roomtype:'0');
|
||||
'-'.($only_reduc?'1':'0').'-'.($use_reduc?'1':'0').'-'.($use_tax?'1':'0').'-'.(int)$decimals.'-'.($id_product_roomtype?(int)$id_product_roomtype:'0').'-'.($id_service_product_option?(int)$id_service_product_option:'0');
|
||||
|
||||
// reference parameter is filled before any returns
|
||||
$specific_price = SpecificPrice::getSpecificPrice(
|
||||
@@ -3253,6 +3277,9 @@ class ProductCore extends ObjectModel
|
||||
|
||||
// fetch price & attribute price
|
||||
$cache_id_2 = $id_product.'-'.$id_shop;
|
||||
if ($id_service_product_option) {
|
||||
$cache_id_2 .= '-'.$id_service_product_option;
|
||||
}
|
||||
if (!isset(self::$_pricesLevel2[$cache_id_2])) {
|
||||
$sql = new DbQuery();
|
||||
$sql->select('product_shop.`price`, product_shop.`ecotax`');
|
||||
@@ -3266,6 +3293,15 @@ class ProductCore extends ObjectModel
|
||||
$sql->select('0 as id_product_attribute');
|
||||
}
|
||||
|
||||
if (ServiceProductOption::productHasOptions($id_product)) {
|
||||
$sql->select('service_product_option.id_service_product_option, service_product_option.price_impact as option_impact_price');
|
||||
|
||||
if ($id_service_product_option) {
|
||||
$sql->leftJoin('service_product_option', 'service_product_option', '(service_product_option.id_product = p.id_product AND service_product_option.id_service_product_option = '.(int)$id_service_product_option.')');
|
||||
} else {
|
||||
$sql->leftJoin('service_product_option', 'service_product_option', '(service_product_option.id_product = p.id_product)');
|
||||
}
|
||||
}
|
||||
$res = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
|
||||
|
||||
if (is_array($res) && count($res)) {
|
||||
@@ -3275,11 +3311,19 @@ class ProductCore extends ObjectModel
|
||||
'ecotax' => $row['ecotax'],
|
||||
'attribute_price' => (isset($row['attribute_price']) ? $row['attribute_price'] : null)
|
||||
);
|
||||
if (isset($row['option_impact_price'])) {
|
||||
$array_tmp['option_impact_price'] = $row['option_impact_price'];
|
||||
$array_tmp['id_service_product_option'] = $row['id_service_product_option'];
|
||||
}
|
||||
|
||||
self::$_pricesLevel2[$cache_id_2][(int)$row['id_product_attribute']] = $array_tmp;
|
||||
|
||||
if (isset($row['default_on']) && $row['default_on'] == 1) {
|
||||
self::$_pricesLevel2[$cache_id_2][0] = $array_tmp;
|
||||
}
|
||||
if (isset($row['option_impact_price']) && !$id_service_product_option) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3309,6 +3353,10 @@ class ProductCore extends ObjectModel
|
||||
$price = (float)$specific_price['price'];
|
||||
}
|
||||
|
||||
if (isset($result['option_impact_price'])) {
|
||||
$price += (float)$result['option_impact_price'];
|
||||
}
|
||||
|
||||
// convert only if the specific price is in the default currency (id_currency = 0)
|
||||
if (!$specific_price || !($specific_price['price'] >= 0 && $specific_price['id_currency'])) {
|
||||
$price = Tools::convertPrice($price, $id_currency);
|
||||
@@ -4075,7 +4123,7 @@ class ProductCore extends ObjectModel
|
||||
* @param string $query Search query
|
||||
* @return array Matching products
|
||||
*/
|
||||
public static function searchByName($id_lang, $query, Context $context = null, $id_hotel = false)
|
||||
public static function searchByName($id_lang, $query, $booking_product = null, $service_product_type = null, $id_hotel = false, Context $context = null)
|
||||
{
|
||||
if (!$context) {
|
||||
$context = Context::getContext();
|
||||
@@ -4090,13 +4138,22 @@ class ProductCore extends ObjectModel
|
||||
AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl')
|
||||
);
|
||||
$sql->leftJoin('manufacturer', 'm', 'm.`id_manufacturer` = p.`id_manufacturer`');
|
||||
if ($id_hotel) {
|
||||
$sql->innerJoin(
|
||||
'htl_room_type',
|
||||
'hrt',
|
||||
'p.`id_product` = hrt.`id_product` AND hrt.`id_hotel` = '.(int)$id_hotel
|
||||
);
|
||||
|
||||
if ($booking_product) {
|
||||
if ($id_hotel) {
|
||||
$sql->innerJoin(
|
||||
'htl_room_type',
|
||||
'hrt',
|
||||
'p.`id_product` = hrt.`id_product` AND hrt.`id_hotel` = '.(int)$id_hotel
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if (Product::SERVICE_PRODUCT_lINKED_WITH_HOTEL == $service_product_type && $id_hotel) {
|
||||
$sql->innerJoin(
|
||||
'htl_room_type_service_product',
|
||||
'hrtsp',
|
||||
'p.`id_product` = hrtsp.`id_product` AND hrtsp.`id_element` = '.(int)$id_hotel.' AND hrtsp.`element_type` = '.(int)RoomTypeServiceProduct::WK_ELEMENT_TYPE_HOTEL
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$where = 'pl.`name` LIKE \'%'.pSQL($query).'%\'
|
||||
|
||||
@@ -29,7 +29,7 @@ class CheckoutCustomerDetailsStepCore extends AbstractCheckoutStepCore
|
||||
public function handleRequest()
|
||||
{
|
||||
$idAddressDelivery = $this->context->cart->id_address_delivery;
|
||||
$objAddress = new Address($idAddressDelivery);
|
||||
// $objAddress = new Address($idAddressDelivery);
|
||||
if (Tools::getValue('proceed_to_customer_dtl')) {
|
||||
$this->step_is_reachable = 1;
|
||||
$this->step_is_current = 1;
|
||||
|
||||
@@ -1267,13 +1267,14 @@ class OrderCore extends ObjectModel
|
||||
*/
|
||||
public function isReturnable()
|
||||
{
|
||||
$objBookingDetail = new HotelBookingDetail();
|
||||
if ($bookingInfo = $objBookingDetail->getBookingDataByOrderId($this->id)) {
|
||||
$idHotel = reset($bookingInfo)['id_hotel'];
|
||||
$objHotelBranch = new HotelBranchInformation($idHotel);
|
||||
$vatAddress = new Address((int)$this->id_address_tax);
|
||||
if ($vatAddress->id_hotel) {
|
||||
$objHotelBranch = new HotelBranchInformation($vatAddress->id_hotel);
|
||||
|
||||
// check if global as well as hotel refund is allowed
|
||||
return (Configuration::get('WK_ORDER_REFUND_ALLOWED') && $objHotelBranch->active_refund);
|
||||
} else {
|
||||
return Configuration::get('WK_ORDER_REFUND_ALLOWED');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -2649,63 +2650,84 @@ class OrderCore extends ObjectModel
|
||||
*/
|
||||
public function hasCompletelyRefunded($action = 0, $includeCheckIn = 0)
|
||||
{
|
||||
$res = true;
|
||||
// check rooms in booking
|
||||
$objHotelBooking = new HotelBookingdetail();
|
||||
if ($orderBookings = $objHotelBooking->getOrderCurrentDataByOrderId($this->id)) {
|
||||
// If action is Order::ORDER_COMPLETE_REFUND_FLAG (for refunded) then we will check
|
||||
// that all rooms must be refunded and at least one booking is not cancelled
|
||||
if ($action == Order::ORDER_COMPLETE_REFUND_FLAG) {
|
||||
$uniqueRefundedBookings = array_unique(array_column($orderBookings, 'is_refunded'));
|
||||
if (count($uniqueRefundedBookings) == 1 && $uniqueRefundedBookings[0] == 1) {
|
||||
foreach ($orderBookings as $booking) {
|
||||
if ($booking['is_cancelled'] == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// If action is Order::ORDER_COMPLETE_CANCELLATION_FLAG (for cancelled) then we will check that all rooms must be cancelled
|
||||
} elseif ($action == Order::ORDER_COMPLETE_CANCELLATION_FLAG) {
|
||||
$uniqueRefundedBookings = array_unique(array_column($orderBookings, 'is_cancelled'));
|
||||
if (count($uniqueRefundedBookings) == 1 && $uniqueRefundedBookings[0] == 1) {
|
||||
return true;
|
||||
}
|
||||
// If action is Order::ORDER_COMPLETE_CANCELLATION_OR_REFUND_REQUEST_FLAG (for cancelled and refund requests) then we will check that all rooms are either cancelled or requested for refund
|
||||
} elseif ($action == Order::ORDER_COMPLETE_CANCELLATION_OR_REFUND_REQUEST_FLAG) {
|
||||
foreach ($orderBookings as $booking) {
|
||||
if (!$booking['is_refunded']) {
|
||||
// If booking refund request is created and request is completed but booking is not refunded then return false
|
||||
if ($bookingRefundDetail = OrderReturn::getOrdersReturnDetail($this->id, 0, $booking['id'])) {
|
||||
$bookingRefundDetail = reset($bookingRefundDetail);
|
||||
if ($bookingRefundDetail['refunded']) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
// Default process to check if order is fully refunded or cancelled or not
|
||||
} else {
|
||||
// if is_refunded is 1 means booking either is cancelled or refunded. So check all bookings must have is_refunded = 1
|
||||
$uniqueRefundedBookings = array_unique(array_column($orderBookings, 'is_refunded'));
|
||||
if (count($uniqueRefundedBookings) == 1 && $uniqueRefundedBookings[0] == 1) {
|
||||
return true;
|
||||
} elseif ($includeCheckIn) {
|
||||
foreach ($orderBookings as $booking) {
|
||||
if ($booking['is_refunded'] == 0
|
||||
&& !OrderReturn::getOrdersReturnDetail($this->id, 0, $booking['id'])
|
||||
&& $booking['id_status'] == HotelBookingDetail::STATUS_ALLOTED
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
$res = $res && $this->checkList($orderBookings, $action, $includeCheckIn);
|
||||
}
|
||||
|
||||
return false;
|
||||
// check hotel linked products
|
||||
$objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail();
|
||||
if ($hotelProducts = $objRoomTypeServiceProductOrderDetail->getProducts($this->id, 0, 0, Product::SERVICE_PRODUCT_lINKED_WITH_HOTEL)) {
|
||||
$res = $res && $this->checkList($hotelProducts, $action, false);
|
||||
}
|
||||
|
||||
if ($standaloneProducts = $objRoomTypeServiceProductOrderDetail->getProducts($this->id, 0, 0, Product::SERVICE_PRODUCT_STANDALONE)) {
|
||||
$res = $res && $this->checkList($standaloneProducts, $action, false);
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function checkList($list, $action = 0, $includeCheckIn = 0) {
|
||||
// If action is Order::ORDER_COMPLETE_REFUND_FLAG (for refunded) then we will check
|
||||
// that all rooms must be refunded and at least one booking is not cancelled
|
||||
if ($action == Order::ORDER_COMPLETE_REFUND_FLAG) {
|
||||
$uniqueRefundedBookings = array_unique(array_column($list, 'is_refunded'));
|
||||
if (count($uniqueRefundedBookings) == 1 && $uniqueRefundedBookings[0] == 1) {
|
||||
foreach ($list as $booking) {
|
||||
if ($booking['is_cancelled'] == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// If action is Order::ORDER_COMPLETE_CANCELLATION_FLAG (for cancelled) then we will check that all rooms must be cancelled
|
||||
} elseif ($action == Order::ORDER_COMPLETE_CANCELLATION_FLAG) {
|
||||
$uniqueRefundedBookings = array_unique(array_column($list, 'is_cancelled'));
|
||||
if (count($uniqueRefundedBookings) == 1 && $uniqueRefundedBookings[0] == 1) {
|
||||
return true;
|
||||
}
|
||||
// If action is Order::ORDER_COMPLETE_CANCELLATION_OR_REFUND_REQUEST_FLAG (for cancelled and refund requests) then we will check that all rooms are either cancelled or requested for refund
|
||||
} elseif ($action == Order::ORDER_COMPLETE_CANCELLATION_OR_REFUND_REQUEST_FLAG) {
|
||||
foreach ($list as $product) {
|
||||
if (!$product['is_refunded']) {
|
||||
// If booking refund request is created and request is completed but booking is not refunded then return false
|
||||
if ($bookingRefundDetail = OrderReturn::getOrdersReturnDetail(
|
||||
$this->id,
|
||||
0,
|
||||
isset($product['id']) ? $product['id'] : 0,
|
||||
isset($product['id_room_type_service_product_order_detail']) ? $product['id_room_type_service_product_order_detail'] : 0,
|
||||
)) {
|
||||
$bookingRefundDetail = reset($bookingRefundDetail);
|
||||
if ($bookingRefundDetail['refunded']) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
// Default process to check if order is fully refunded or cancelled or not
|
||||
} else {
|
||||
// if is_refunded is 1 means booking either is cancelled or refunded. So check all bookings must have is_refunded = 1
|
||||
$uniqueRefundedBookings = array_unique(array_column($list, 'is_refunded'));
|
||||
if (count($uniqueRefundedBookings) == 1 && $uniqueRefundedBookings[0] == 1) {
|
||||
return true;
|
||||
} elseif ($includeCheckIn) {
|
||||
foreach ($list as $booking) {
|
||||
if ($booking['is_refunded'] == 0
|
||||
&& !OrderReturn::getOrdersReturnDetail($this->id, 0, isset($product['id']) ? $product['id'] : 0)
|
||||
&& $booking['id_status'] == HotelBookingDetail::STATUS_ALLOTED
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getWsBookings()
|
||||
|
||||
@@ -478,14 +478,16 @@ class OrderDetailCore extends ObjectModel
|
||||
/*
|
||||
*By webkul so that product quantity will not be decreased when product is ordered
|
||||
*/
|
||||
/*$update_quantity = true;
|
||||
if (!StockAvailable::dependsOnStock($product['id_product'])) {
|
||||
$update_quantity = StockAvailable::updateQuantity($product['id_product'], $product['id_product_attribute'], -(int)$product['cart_quantity']);
|
||||
}
|
||||
if (!$product['booking_product']) {
|
||||
$update_quantity = true;
|
||||
if (!StockAvailable::dependsOnStock($product['id_product'])) {
|
||||
$update_quantity = StockAvailable::updateQuantity($product['id_product'], $product['id_product_attribute'], -(int)$product['cart_quantity']);
|
||||
}
|
||||
|
||||
if ($update_quantity) {
|
||||
$product['stock_quantity'] -= $product['cart_quantity'];
|
||||
}*/
|
||||
if ($update_quantity) {
|
||||
$product['stock_quantity'] -= $product['cart_quantity'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($product['stock_quantity'] < 0 && Configuration::get('PS_STOCK_MANAGEMENT')) {
|
||||
$this->outOfStock = true;
|
||||
|
||||
@@ -618,9 +618,13 @@ class OrderInvoiceCore extends ObjectModel
|
||||
$breakdown = array();
|
||||
$order_detail = $this->getProducts();
|
||||
$order_detail = array_filter($order_detail, function($v) {
|
||||
return (!$v['is_booking_product'] && $v['product_service_type'] == Product::SERVICE_PRODUCT_WITHOUT_ROOMTYPE);
|
||||
return (!$v['is_booking_product'] && (
|
||||
$v['product_service_type'] == Product::SERVICE_PRODUCT_STANDALONE
|
||||
|| $v['product_service_type'] == Product::SERVICE_PRODUCT_lINKED_WITH_HOTEL
|
||||
));
|
||||
});
|
||||
$details = $order->getProductTaxesDetails($order_detail, false, Product::SERVICE_PRODUCT_WITHOUT_ROOMTYPE);
|
||||
|
||||
$details = $order->getProductTaxesDetails($order_detail, false);
|
||||
|
||||
if ($sum_composite_taxes) {
|
||||
$grouped_details = array();
|
||||
|
||||
@@ -189,8 +189,8 @@ class OrderReturnCore extends ObjectModel
|
||||
public function getOrderRefundRequestedBookings($idOrder, $idOrderReturn = 0, $onlyBookingIds = 0, $customerView = 0, $skipReqCompletedNonRefunded = 0)
|
||||
{
|
||||
$sql = 'SELECT hbd.*, ord.*, orr.`state` as id_return_state FROM `'._DB_PREFIX_.'order_return` orr';
|
||||
$sql .= ' LEFT JOIN `'._DB_PREFIX_.'order_return_detail` ord ON (orr.`id_order_return` = ord.`id_order_return`)';
|
||||
$sql .= ' LEFT JOIN `'._DB_PREFIX_.'htl_booking_detail` hbd ON (hbd.`id` = ord.`id_htl_booking`)';
|
||||
$sql .= ' INNER JOIN `'._DB_PREFIX_.'order_return_detail` ord ON (orr.`id_order_return` = ord.`id_order_return`)';
|
||||
$sql .= ' INNER JOIN `'._DB_PREFIX_.'htl_booking_detail` hbd ON (hbd.`id` = ord.`id_htl_booking`)';
|
||||
$sql .= ' WHERE orr.`id_order` = '.(int)$idOrder;
|
||||
|
||||
if ($idOrderReturn) {
|
||||
@@ -309,6 +309,54 @@ class OrderReturnCore extends ObjectModel
|
||||
return $returnDetails;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get order refund request products
|
||||
*/
|
||||
public function getOrderRefundRequestedProducts($idOrder, $idOrderReturn = 0, $onlyIds = 0, $customerView = 0, $skipReqCompletedNonRefunded = 0)
|
||||
{
|
||||
$sql = 'SELECT spod.*, ord.*, orr.`state` as id_return_state FROM `'._DB_PREFIX_.'order_return` orr';
|
||||
$sql .= ' INNER JOIN `'._DB_PREFIX_.'order_return_detail` ord ON (orr.`id_order_return` = ord.`id_order_return`)';
|
||||
$sql .= ' INNER JOIN `'._DB_PREFIX_.'htl_room_type_service_product_order_detail` spod ON (spod.`id_room_type_service_product_order_detail` = ord.`id_room_type_service_product_order_detail`)';
|
||||
$sql .= ' WHERE orr.`id_order` = '.(int)$idOrder;
|
||||
|
||||
if ($idOrderReturn) {
|
||||
$sql .= ' AND ord.`id_order_return` = '.(int)$idOrderReturn;
|
||||
}
|
||||
if ($returnDetails = Db::getInstance()->executeS($sql)) {
|
||||
if ($customerView) {
|
||||
$returnsCustView = array();
|
||||
}
|
||||
$objOrder = new Order($idOrder);
|
||||
|
||||
foreach ($returnDetails as $key => &$product) {
|
||||
if ($skipReqCompletedNonRefunded) {
|
||||
$objReturnState = new OrderReturnState($product['id_return_state']);
|
||||
if ($objReturnState->refunded && !$product['is_refunded']) {
|
||||
unset($returnDetails[$key]);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$product['paid_amount'] = 0;
|
||||
if ($product['total_price_tax_incl'] > 0) {
|
||||
if ($objOrder->total_paid_real > 0) {
|
||||
$product['paid_amount'] = ($objOrder->total_paid_real*$product['total_price_tax_incl'])/ ($objOrder->total_paid_tax_incl + $objOrder->total_discounts_tax_incl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($onlyIds) {
|
||||
return array_column($returnDetails, 'id_room_type_service_product_order_detail');
|
||||
}
|
||||
|
||||
if ($customerView) {
|
||||
return $returnsCustView;
|
||||
}
|
||||
}
|
||||
|
||||
return $returnDetails;
|
||||
}
|
||||
|
||||
public static function getOrdersReturn($customer_id, $order_id = false, $no_denied = false, $only_customer = 0, Context $context = null)
|
||||
{
|
||||
if (!$context) {
|
||||
@@ -322,6 +370,8 @@ class OrderReturnCore extends ObjectModel
|
||||
ON (ord.`id_order_return` = orr.`id_order_return`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'htl_booking_detail` hbd
|
||||
ON (hbd.`id` = ord.`id_htl_booking`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'htl_room_type_service_product_order_detail` rtspod
|
||||
ON (rtspod.`id_room_type_service_product_order_detail` = ord.`id_room_type_service_product_order_detail`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'order_slip` ors
|
||||
ON (ors.`id_order_slip` = orr.`id_return_type` AND orr.`return_type` = '.(int) self::RETURN_TYPE_ORDER_SLIP.')
|
||||
WHERE orr.`id_customer` = '.(int)$customer_id.
|
||||
@@ -353,6 +403,7 @@ class OrderReturnCore extends ObjectModel
|
||||
$idOrder,
|
||||
$idOrderReturn = 0,
|
||||
$idHtlBooking = 0,
|
||||
$idServiceProductOrderOetail = 0,
|
||||
$idLang = 0,
|
||||
$orderByLatestRequest = 1
|
||||
) {
|
||||
@@ -373,6 +424,10 @@ class OrderReturnCore extends ObjectModel
|
||||
$sql .= ' AND ord.`id_htl_booking` = '.(int)$idHtlBooking;
|
||||
}
|
||||
|
||||
if ($idServiceProductOrderOetail) {
|
||||
$sql .= ' AND ord.`id_room_type_service_product_order_detail` = '.(int)$idServiceProductOrderOetail;
|
||||
}
|
||||
|
||||
if ($orderByLatestRequest) {
|
||||
$sql .= ' ORDER BY orr.`id_order_return` DESC';
|
||||
}
|
||||
|
||||
@@ -26,6 +26,9 @@ class OrderReturnDetailCore extends ObjectModel
|
||||
/** @var int */
|
||||
public $id_htl_booking;
|
||||
|
||||
/** @var int */
|
||||
public $id_room_type_service_product_order_detail;
|
||||
|
||||
/** @var float amount of the refund transaction */
|
||||
public $refunded_amount;
|
||||
|
||||
@@ -47,7 +50,8 @@ class OrderReturnDetailCore extends ObjectModel
|
||||
'primary' => 'id_order_return_detail',
|
||||
'fields' => array(
|
||||
'id_order_return' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
|
||||
'id_htl_booking' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
|
||||
'id_htl_booking' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
|
||||
'id_room_type_service_product_order_detail' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
|
||||
'id_order_detail' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'default' => 0),
|
||||
'id_customization' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'default' => 0),
|
||||
'product_quantity' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'default' => 0),
|
||||
|
||||
@@ -183,13 +183,19 @@ class OrderSlipCore extends ObjectModel
|
||||
|
||||
$slipDetails = array();
|
||||
foreach ($productsRet as &$slipRow) {
|
||||
$objHtlBooking = new HotelBookingDetail($slipRow['id_htl_booking']);
|
||||
$slipRow['product_id'] = $objHtlBooking->id_product;
|
||||
$slipRow['date_from'] = $objHtlBooking->date_from;
|
||||
$slipRow['date_to'] = $objHtlBooking->date_to;
|
||||
$slipRow['hotel_name'] = $objHtlBooking->hotel_name;
|
||||
$slipRow['product_name'] = $objHtlBooking->room_type_name;
|
||||
$slipRow['room_num'] = $objHtlBooking->room_num;
|
||||
if ($slipRow['id_htl_booking']) {
|
||||
$objHtlBooking = new HotelBookingDetail($slipRow['id_htl_booking']);
|
||||
$slipRow['product_id'] = $objHtlBooking->id_product;
|
||||
$slipRow['date_from'] = $objHtlBooking->date_from;
|
||||
$slipRow['date_to'] = $objHtlBooking->date_to;
|
||||
$slipRow['hotel_name'] = $objHtlBooking->hotel_name;
|
||||
$slipRow['product_name'] = $objHtlBooking->room_type_name;
|
||||
$slipRow['room_num'] = $objHtlBooking->room_num;
|
||||
} else {
|
||||
$objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail($slipRow['id_room_type_service_product_order_detail']);
|
||||
$slipRow['product_name'] = $objRoomTypeServiceProductOrderDetail->name;
|
||||
}
|
||||
|
||||
|
||||
if (isset($orderDetailCustom[$slipRow['id_order_detail']])) {
|
||||
$slipRow = array_merge($orderDetailCustom[$slipRow['id_order_detail']], $slipRow);
|
||||
@@ -304,7 +310,7 @@ class OrderSlipCore extends ObjectModel
|
||||
return OrderSlip::create($order, $product_list, $shipping);
|
||||
}
|
||||
|
||||
public static function create(Order $order, $booking_list, $shipping_cost = false, $amount = 0, $amount_choosen = false, $add_tax = true)
|
||||
public static function create(Order $order, $product_list, $shipping_cost = false, $amount = 0, $amount_choosen = false, $add_tax = true)
|
||||
{
|
||||
$currency = new Currency((int)$order->id_currency);
|
||||
$order_slip = new OrderSlip();
|
||||
@@ -347,25 +353,31 @@ class OrderSlipCore extends ObjectModel
|
||||
$order_slip->{'total_products_tax_'.$inc_or_ex_2} = 0;
|
||||
|
||||
$total_products = array();
|
||||
foreach ($booking_list as &$booking) {
|
||||
$objHtlBooking = new HotelBookingDetail($booking['id_htl_booking']);
|
||||
$order_detail = new OrderDetail((int)$objHtlBooking->id_order_detail);
|
||||
foreach ($product_list as &$product_row) {
|
||||
if (isset($product_row['id_htl_booking'])) {
|
||||
$objHtlBooking = new HotelBookingDetail($product_row['id_htl_booking']);
|
||||
$order_detail = new OrderDetail((int)$objHtlBooking->id_order_detail);
|
||||
$quantity = (int)$product_row['num_days'];
|
||||
} else if (isset($product_row['id_room_type_service_product_order_detail'])) {
|
||||
$objRoomTypeServiceProductOrderDetail = new RoomTypeServiceProductOrderDetail($product_row['id_room_type_service_product_order_detail']);
|
||||
$order_detail = new OrderDetail((int)$objRoomTypeServiceProductOrderDetail->id_order_detail);
|
||||
$quantity = (int)$product_row['quantity'];
|
||||
}
|
||||
$price = (float)$product_row['unit_price'];
|
||||
|
||||
$price = (float)$booking['unit_price'];
|
||||
$numDays = (int)$booking['num_days'];
|
||||
|
||||
$order_slip_resume = OrderSlip::getProductSlipResume((int)$order_detail->id);
|
||||
|
||||
if ($numDays + $order_slip_resume['product_quantity'] > $order_detail->product_quantity) {
|
||||
$numDays = $order_detail->product_quantity - $order_slip_resume['product_quantity'];
|
||||
if ($quantity + $order_slip_resume['product_quantity'] > $order_detail->product_quantity) {
|
||||
$quantity = $order_detail->product_quantity - $order_slip_resume['product_quantity'];
|
||||
}
|
||||
|
||||
if ($numDays == 0) {
|
||||
if ($quantity == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!Tools::isSubmit('cancelProduct') && $order->hasBeenPaid()) {
|
||||
$order_detail->product_quantity_refunded += $numDays;
|
||||
$order_detail->product_quantity_refunded += $quantity;
|
||||
}
|
||||
|
||||
$address = Address::initialize($order->id_address_tax, false);
|
||||
@@ -385,7 +397,7 @@ class OrderSlipCore extends ObjectModel
|
||||
}
|
||||
|
||||
$product_tax_inc_or_ex_1 = Tools::processPriceRounding(
|
||||
($price * $numDays),
|
||||
($price * $quantity),
|
||||
1,
|
||||
$order->round_type,
|
||||
$order->round_mode
|
||||
@@ -394,7 +406,7 @@ class OrderSlipCore extends ObjectModel
|
||||
$order_slip->{'total_products_tax_'.$inc_or_ex_1} += $product_tax_inc_or_ex_1;
|
||||
|
||||
$product_tax_inc_or_ex_2 = Tools::processPriceRounding(
|
||||
($tax_calculator->{$add_or_remove.'Taxes'}($price * $numDays)),
|
||||
($tax_calculator->{$add_or_remove.'Taxes'}($price * $quantity)),
|
||||
1,
|
||||
$order->round_type,
|
||||
$order->round_mode
|
||||
@@ -405,10 +417,10 @@ class OrderSlipCore extends ObjectModel
|
||||
$total_products[$id_tax_rules_group] += $product_tax_inc_or_ex_2;
|
||||
}
|
||||
|
||||
$booking['unit_price_tax_'.$inc_or_ex_1] = $price;
|
||||
$booking['unit_price_tax_'.$inc_or_ex_2] = $tax_calculator->{$add_or_remove.'Taxes'}($price);
|
||||
$booking['total_price_tax_'.$inc_or_ex_1] = $product_tax_inc_or_ex_1;
|
||||
$booking['total_price_tax_'.$inc_or_ex_2] = $product_tax_inc_or_ex_2;
|
||||
$product_row['unit_price_tax_'.$inc_or_ex_1] = $price;
|
||||
$product_row['unit_price_tax_'.$inc_or_ex_2] = $tax_calculator->{$add_or_remove.'Taxes'}($price);
|
||||
$product_row['total_price_tax_'.$inc_or_ex_1] = $product_tax_inc_or_ex_1;
|
||||
$product_row['total_price_tax_'.$inc_or_ex_2] = $product_tax_inc_or_ex_2;
|
||||
}
|
||||
|
||||
foreach ($total_products as $key => $price) {
|
||||
@@ -441,26 +453,27 @@ class OrderSlipCore extends ObjectModel
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($booking_list as $bookingRow) {
|
||||
$order_slip->addProductOrderSlip($bookingRow);
|
||||
foreach ($product_list as $product_row) {
|
||||
$order_slip->addProductOrderSlip($product_row);
|
||||
}
|
||||
|
||||
return $order_slip->id;
|
||||
}
|
||||
|
||||
protected function addProductOrderSlip($booking)
|
||||
protected function addProductOrderSlip($product_row)
|
||||
{
|
||||
return Db::getInstance()->insert('order_slip_detail', array(
|
||||
'id_order_slip' => (int)$this->id,
|
||||
'id_htl_booking' => (int)$booking['id_htl_booking'],
|
||||
'id_order_detail' => (int)$booking['id_order_detail'],
|
||||
'product_quantity' => $booking['quantity'],
|
||||
'unit_price_tax_excl' => $booking['unit_price_tax_excl'],
|
||||
'unit_price_tax_incl' => $booking['unit_price_tax_incl'],
|
||||
'total_price_tax_excl' => $booking['total_price_tax_excl'],
|
||||
'total_price_tax_incl' => $booking['total_price_tax_incl'],
|
||||
'amount_tax_excl' => $booking['total_price_tax_excl'],
|
||||
'amount_tax_incl' => $booking['total_price_tax_incl']
|
||||
'id_htl_booking' => isset($product_row['id_htl_booking']) ? (int)$product_row['id_htl_booking'] : 0,
|
||||
'id_room_type_service_product_order_detail' => isset($product_row['id_room_type_service_product_order_detail']) ? (int)$product_row['id_room_type_service_product_order_detail'] : 0,
|
||||
'id_order_detail' => (int)$product_row['id_order_detail'],
|
||||
'product_quantity' => $product_row['quantity'],
|
||||
'unit_price_tax_excl' => $product_row['unit_price_tax_excl'],
|
||||
'unit_price_tax_incl' => $product_row['unit_price_tax_incl'],
|
||||
'total_price_tax_excl' => $product_row['total_price_tax_excl'],
|
||||
'total_price_tax_incl' => $product_row['total_price_tax_incl'],
|
||||
'amount_tax_excl' => $product_row['total_price_tax_excl'],
|
||||
'amount_tax_incl' => $product_row['total_price_tax_incl']
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -541,8 +541,29 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate
|
||||
foreach ($cart_htl_data[$type_key]['date_diff'] as $key => &$value) {
|
||||
$value['avg_paid_unit_price_tax_excl'] = Tools::ps_round($value['avg_paid_unit_price_tax_excl'] / $value['num_rm'], 6);
|
||||
}
|
||||
} else if (Product::SERVICE_PRODUCT_WITHOUT_ROOMTYPE == $type_value['product_service_type']) {
|
||||
$service_product_data[$type_key] = $type_value;
|
||||
} else if (Product::SERVICE_PRODUCT_lINKED_WITH_HOTEL == $type_value['product_service_type']
|
||||
|| Product::SERVICE_PRODUCT_STANDALONE == $type_value['product_service_type']
|
||||
) {
|
||||
$serviceProducts = $objRoomTypeServiceProductOrderDetail->getProducts($order_obj->id, $type_value['id_order_detail'], $type_value['product_id']);
|
||||
if ($taxes = OrderDetail::getTaxListStatic($type_value['id_order_detail'])) {
|
||||
$tax_temp = array();
|
||||
foreach ($taxes as $tax) {
|
||||
$obj = new Tax($tax['id_tax']);
|
||||
$tax_temp[] = sprintf($this->l('%1$s%2$s%%'), ($obj->rate + 0), '');
|
||||
}
|
||||
$order_detail_tax_label = implode(', ', $tax_temp);
|
||||
} else {
|
||||
$order_detail_tax_label = HTMLTemplateInvoice::l('No tax');
|
||||
}
|
||||
foreach ($serviceProducts as $serviceProduct) {
|
||||
if ($serviceProduct['id_hotel']) {
|
||||
$objHotel = new HotelBranchInformation($serviceProduct['id_hotel'], $order_obj->id_lang);
|
||||
$serviceProduct['hotel_name'] = $objHotel->hotel_name;
|
||||
}
|
||||
$serviceProduct = array_merge($type_value, $serviceProduct);
|
||||
$serviceProduct['order_detail_tax_label'] = $order_detail_tax_label;
|
||||
$service_product_data[] = $serviceProduct;
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($tax_temp);
|
||||
@@ -562,8 +583,8 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate
|
||||
if ($idsOrderDetail = array_column($order_details, 'id_order_detail')) {
|
||||
$footer['room_price_tax_excl'] = $this->order->getTotalProductsWithoutTaxes(false, true, null, null, null, $idsOrderDetail) + $this->order->getTotalProductsWithoutTaxes(false, false, Product::SERVICE_PRODUCT_WITH_ROOMTYPE, 1, Product::PRICE_ADDITION_TYPE_WITH_ROOM, $idsOrderDetail);
|
||||
$footer['room_price_tax_incl'] = $this->order->getTotalProductsWithTaxes(false, true, null, null, null, $idsOrderDetail) + $this->order->getTotalProductsWithTaxes(false, false, Product::SERVICE_PRODUCT_WITH_ROOMTYPE, 1, Product::PRICE_ADDITION_TYPE_WITH_ROOM, $idsOrderDetail);
|
||||
// $footer['service_products_price_tax_excl'] = $this->order->getTotalProductsWithoutTaxes(false, false, Product::SERVICE_PRODUCT_WITHOUT_ROOMTYPE);
|
||||
// $footer['service_products_price_tax_incl'] = $this->order->getTotalProductsWithTaxes(false, false, Product::SERVICE_PRODUCT_WITHOUT_ROOMTYPE);
|
||||
$footer['service_products_price_tax_excl'] = $this->order->getTotalProductsWithoutTaxes(false, false, Product::SERVICE_PRODUCT_STANDALONE, false, false, $idsOrderDetail) + $this->order->getTotalProductsWithoutTaxes(false, false, Product::SERVICE_PRODUCT_lINKED_WITH_HOTEL, false, false, $idsOrderDetail);
|
||||
$footer['service_products_price_tax_incl'] = $this->order->getTotalProductsWithTaxes(false, false, Product::SERVICE_PRODUCT_STANDALONE, false, false, $idsOrderDetail) + $this->order->getTotalProductsWithTaxes(false, false, Product::SERVICE_PRODUCT_lINKED_WITH_HOTEL, false, false, $idsOrderDetail);
|
||||
$footer['additional_service_price_tax_excl'] = $this->order->getTotalProductsWithoutTaxes(false, false, Product::SERVICE_PRODUCT_WITH_ROOMTYPE, 0, null, $idsOrderDetail) + $totalDemandsPriceTE;
|
||||
$footer['additional_service_price_tax_incl'] = $this->order->getTotalProductsWithTaxes(false, false, Product::SERVICE_PRODUCT_WITH_ROOMTYPE, 0, null, $idsOrderDetail) + $totalDemandsPriceTI;
|
||||
$footer['total_convenience_fee_te'] = $this->order->getTotalProductsWithoutTaxes(false, false, Product::SERVICE_PRODUCT_WITH_ROOMTYPE, 1, Product::PRICE_ADDITION_TYPE_INDEPENDENT, $idsOrderDetail);
|
||||
@@ -571,8 +592,8 @@ class HTMLTemplateInvoiceCore extends HTMLTemplate
|
||||
}
|
||||
|
||||
$footer['total_paid_real'] = $this->order_invoice->getTotalPaid();
|
||||
$footer['total_without_discount_te'] = $footer['room_price_tax_excl'] + $footer['total_convenience_fee_te'] + $footer['additional_service_price_tax_excl'];
|
||||
$footer['total_without_discount_ti'] = $footer['room_price_tax_incl'] + $footer['total_convenience_fee_ti'] + $footer['additional_service_price_tax_incl'];
|
||||
$footer['total_without_discount_te'] = $footer['room_price_tax_excl'] + $footer['total_convenience_fee_te'] + $footer['additional_service_price_tax_excl'] + $footer['service_products_price_tax_excl'];
|
||||
$footer['total_without_discount_ti'] = $footer['room_price_tax_incl'] + $footer['total_convenience_fee_ti'] + $footer['additional_service_price_tax_incl'] + $footer['service_products_price_tax_incl'];
|
||||
$footer['total_tax_without_discount'] = $footer['total_without_discount_ti'] - $footer['total_without_discount_te'];
|
||||
if ($footer['total_tax_without_discount'] < 0) {
|
||||
$footer['total_tax_without_discount'] = 0;
|
||||
|
||||
@@ -90,7 +90,8 @@ class HTMLTemplateOrderSlipCore extends HTMLTemplateInvoice
|
||||
|
||||
$customer = new Customer((int)$this->order->id_customer);
|
||||
$this->order->total_paid_tax_excl = $this->order->total_paid_tax_incl = $this->order->total_products = $this->order->total_products_wt = 0;
|
||||
|
||||
$roomsDetails = array();
|
||||
$productsDetails = array();
|
||||
if ($this->order_slip->amount > 0) {
|
||||
foreach ($this->order->products as &$product) {
|
||||
// $product['total_price_tax_excl'] = $product['unit_price_tax_excl'] * $product['product_quantity'];
|
||||
@@ -101,9 +102,10 @@ class HTMLTemplateOrderSlipCore extends HTMLTemplateInvoice
|
||||
SELECT * FROM `'._DB_PREFIX_.'order_slip_detail`
|
||||
WHERE `id_order_slip` = '.(int)$this->order_slip->id.'
|
||||
AND `id_order_detail` = '.(int)$product['id_order_detail'].'
|
||||
AND `id_htl_booking` = '.(int)$product['id_htl_booking']);
|
||||
AND `id_htl_booking` = '.(int)$product['id_htl_booking'].'
|
||||
AND `id_room_type_service_product_order_detail` = '.(int)$product['id_room_type_service_product_order_detail']);
|
||||
|
||||
$product['total_price_tax_excl'] = $order_slip_detail['amount_tax_excl'];
|
||||
$product['total_price_tax_excl'] = $order_slip_detail['amount_tax_excl'];
|
||||
$product['total_price_tax_incl'] = $order_slip_detail['amount_tax_incl'];
|
||||
}
|
||||
|
||||
@@ -111,6 +113,12 @@ class HTMLTemplateOrderSlipCore extends HTMLTemplateInvoice
|
||||
$this->order->total_products_wt += $product['total_price_tax_incl'];
|
||||
$this->order->total_paid_tax_excl = $this->order->total_products;
|
||||
$this->order->total_paid_tax_incl = $this->order->total_products_wt;
|
||||
|
||||
if ($product['id_htl_booking']) {
|
||||
$roomsDetails[] = $product;
|
||||
} else {
|
||||
$productsDetails[] = $product;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->order->products = null;
|
||||
@@ -144,10 +152,13 @@ class HTMLTemplateOrderSlipCore extends HTMLTemplateInvoice
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->smarty->assign(array(
|
||||
'order' => $this->order,
|
||||
'order_slip' => $this->order_slip,
|
||||
'order_details' => $this->order->products,
|
||||
'roomsDetails' => $roomsDetails,
|
||||
'productsDetails' => $productsDetails,
|
||||
'cart_rules' => $this->order_slip->order_slip_type == 1 ? $this->order->getCartRules($this->order_invoice->id) : false,
|
||||
'amount_choosen' => $this->order_slip->order_slip_type == 2 ? true : false,
|
||||
'delivery_address' => $formatted_delivery_address,
|
||||
|
||||
@@ -1842,8 +1842,8 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We
|
||||
// Checking if the auto add service was sent in the request
|
||||
if (!isset($this->wsRequestedRoomTypes[$dateRoomJoinKey]['services'][$service['id_product']])
|
||||
&& ($idRoomTypeServiceProductCartDetail = $objRoomTypeServiceProductCartDetail->alreadyExists(
|
||||
$service['id_product'],
|
||||
$this->context->cart->id,
|
||||
$service['id_product'],
|
||||
$serviceProduct['htl_cart_booking_id'])
|
||||
)) {
|
||||
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail((int) $idRoomTypeServiceProductCartDetail);
|
||||
@@ -3092,9 +3092,10 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We
|
||||
$services = $formattedServices;
|
||||
foreach ($services as $service) {
|
||||
$objRoomTypeServiceProductCartDetail->addServiceProductInCart(
|
||||
$objCart->id,
|
||||
$service['id_product'],
|
||||
$service['quantity'],
|
||||
$objCart->id,
|
||||
false,
|
||||
$roomHtlCartInfo['id']
|
||||
);
|
||||
}
|
||||
@@ -3105,8 +3106,8 @@ class WebserviceSpecificManagementBookingsCore Extends ObjectModel implements We
|
||||
$objOrderDetail->createList($objOrder, $objCart, $objOrder->getCurrentOrderState(), $productList, 0, true);
|
||||
foreach ($productList as &$product) {
|
||||
if ($idRoomTypeServiceProductCartDetail = $objRoomTypeServiceProductCartDetail->alreadyExists(
|
||||
$product['id_product'],
|
||||
$objCart->id,
|
||||
$product['id_product'],
|
||||
$roomHtlCartInfo['id'])
|
||||
) {
|
||||
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail((int) $idRoomTypeServiceProductCartDetail);
|
||||
|
||||
Reference in New Issue
Block a user