Added feature for adding standard product in cart

This commit is contained in:
Shreesh Arora
2025-02-26 11:07:31 +05:30
parent 950b37ed1c
commit ec23dbd4f3
98 changed files with 8153 additions and 3882 deletions

View File

@@ -299,6 +299,95 @@ class ParentOrderControllerCore extends FrontController
return true;
}
protected function _assignCheckoutVars()
{
if ($orderRestrictErr = HotelCartBookingData::validateCartBookings()) {
$this->errors = array_merge($this->errors, $orderRestrictErr);
}
$show_option_allow_separate_package = (!$this->context->cart->isAllProductsInStock(true) && Configuration::get('PS_SHIP_WHEN_AVAILABLE'));
$advanced_payment_api = (bool)Configuration::get('PS_ADVANCED_PAYMENT_API');
$this->context->smarty->assign(array(
'THEME_DIR' => _THEME_DIR_,
'PS_ROOM_PRICE_AUTO_ADD_BREAKDOWN' => Configuration::get('PS_ROOM_PRICE_AUTO_ADD_BREAKDOWN'),
'orderRestrictErr' => count($orderRestrictErr) ? 1 : 0,
'show_option_allow_separate_package' => $show_option_allow_separate_package,
'advanced_payment_api' => $advanced_payment_api
));
}
protected function _assignShoppingCart()
{
$summary = $this->context->cart->getSummaryDetails();
$cartProducts = $this->context->cart->getProducts();
if (!empty($cartProducts)) {
if ($cartBookingInfo = HotelCartBookingData::getHotelCartBookingData()) {
$this->context->smarty->assign('cart_htl_data', $cartBookingInfo);
}
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail();
if ($hotelProducts = $objRoomTypeServiceProductCartDetail->getProducts(
$this->context->cart->id,
0,
Product::SERVICE_PRODUCT_lINKED_WITH_HOTEL,
0,
0,
null,
0,
0,
null,
null,
true
)) {
$this->context->smarty->assign('hotel_products', $hotelProducts);
}
$standaloneProducts = $objRoomTypeServiceProductCartDetail->getProducts(
$this->context->cart->id,
0,
ProductCore::SERVICE_PRODUCT_STANDALONE
);
if (count($standaloneProducts)) {
$this->context->smarty->assign('standalone_products', $standaloneProducts);
}
// For Advanced Payment work
$objAdvPayment = new HotelAdvancedPayment();
if ($objAdvPayment->isAdvancePaymentAvailableForCurrentCart()) {
if (Tools::isSubmit('submitAdvPayment')) {
if (Tools::getValue('payment_type') == Order::ORDER_PAYMENT_TYPE_ADVANCE) {
$this->context->cart->is_advance_payment = 1;
} else {
$this->context->cart->is_advance_payment = 0;
}
$this->context->cart->save();
Tools::redirect($this->context->link->getPageLink('order-opc'));
}
// set if advance payment is selected by the customer
if ($this->context->cart->is_advance_payment) {
$this->context->smarty->assign('is_advance_payment', 1);
}
// get advance payment amount and send data to the template
$advPaymentAmount = $this->context->cart->getOrderTotal(true, Cart::ADVANCE_PAYMENT);
$this->context->smarty->assign(array(
'advance_payment_active'=> 1,
'advPaymentAmount'=> $advPaymentAmount,
'dueAmount'=> ($this->context->cart->getOrderTotal() - $advPaymentAmount),
));
}
}
$this->context->smarty->assign($summary);
$this->context->smarty->assign(array(
'HOOK_SHOPPING_CART' => Hook::exec('displayShoppingCartFooter', $summary),
'HOOK_SHOPPING_CART_EXTRA' => Hook::exec('displayShoppingCart', $summary)
));
}
protected function _assignSummaryInformations()
{
$summary = $this->context->cart->getSummaryDetails();
@@ -362,9 +451,6 @@ class ParentOrderControllerCore extends FrontController
}
}
$show_option_allow_separate_package = (!$this->context->cart->isAllProductsInStock(true) && Configuration::get('PS_SHIP_WHEN_AVAILABLE'));
$advanced_payment_api = (bool)Configuration::get('PS_ADVANCED_PAYMENT_API');
$this->context->smarty->assign($summary);
$this->context->smarty->assign(array(
'token_cart' => Tools::getToken(false),
@@ -379,9 +465,7 @@ class ParentOrderControllerCore extends FrontController
'CUSTOMIZE_TEXTFIELD' => Product::CUSTOMIZE_TEXTFIELD,
'lastProductAdded' => $this->context->cart->getLastProduct(),
'displayVouchers' => $available_cart_rules,
'show_option_allow_separate_package' => $show_option_allow_separate_package,
'smallSize' => Image::getSize(ImageType::getFormatedName('small')),
'advanced_payment_api' => $advanced_payment_api
));
@@ -398,7 +482,15 @@ class ParentOrderControllerCore extends FrontController
$this->context->customer->logout();
Tools::redirect('');
} elseif (!Customer::getAddressesTotalById($this->context->customer->id)) {
$multi = (int)Tools::getValue('multi-shipping');
$objRoomTypeServiceProductCartDetail = new RoomTypeServiceProductCartDetail();
if (count($objRoomTypeServiceProductCartDetail->getProducts(
$this->context->cart->id,
0,
Product::SERVICE_PRODUCT_STANDALONE
))) {
$multi = (int)Tools::getValue('multi-shipping');
Tools::redirect('index.php?controller=address&back='.urlencode('order.php?step=1'.($multi ? '&multi-shipping='.$multi : '')));
}
}
$customer = $this->context->customer;