chocolatdemariage/www/override/controllers/front/ParentOrderController.php

137 lines
5.1 KiB
PHP
Raw Normal View History

2017-07-06 17:41:10 +02:00
<?php
class ParentOrderController extends ParentOrderControllerCore
{
public function setMedia()
{
parent::setMedia();
// Adding JS files
if ((Configuration::get('PS_ORDER_PROCESS_TYPE') == 0 && (Tools::getValue('step') == 1 || Tools::getValue('step') == 2)) || Configuration::get('PS_ORDER_PROCESS_TYPE') == 1)
$this->addJS(_THEME_JS_DIR_.'order-address.js');
if (in_array((int)Tools::getValue('step'), array(0, 1, 2)) || Configuration::get('PS_ORDER_PROCESS_TYPE'))
{
$this->addJqueryPlugin('typewatch');
$this->addJS(_THEME_JS_DIR_.'cart-summary.js');
}
}
protected function _assignSummaryInformations()
{
$summary = $this->context->cart->getSummaryDetails();
$customizedDatas = Product::getAllCustomizedDatas($this->context->cart->id);
// override customization tax rate with real tax (tax rules)
if ($customizedDatas)
{
foreach ($summary['products'] as &$productUpdate)
{
$productId = (int)(isset($productUpdate['id_product']) ? $productUpdate['id_product'] : $productUpdate['product_id']);
$productAttributeId = (int)(isset($productUpdate['id_product_attribute']) ? $productUpdate['id_product_attribute'] : $productUpdate['product_attribute_id']);
if (isset($customizedDatas[$productId][$productAttributeId]))
$productUpdate['tax_rate'] = Tax::getProductTaxRate($productId, $this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
}
Product::addCustomizationPrice($summary['products'], $customizedDatas);
}
$cart_product_context = Context::getContext()->cloneContext();
$extensions = array();
foreach ($summary['products'] as $key => &$product)
{
$product['quantity'] = $product['cart_quantity'];// for compatibility with 1.2 themes
if ($cart_product_context->shop->id != $product['id_shop'])
$cart_product_context->shop = new Shop((int)$product['id_shop']);
$product['price_without_specific_price'] = Product::getPriceStatic(
$product['id_product'],
!Product::getTaxCalculationMethod(),
$product['id_product_attribute'],
2,
null,
false,
false,
1,
false,
null,
null,
null,
$null,
true,
true,
$cart_product_context);
if (Product::getTaxCalculationMethod())
$product['is_discounted'] = $product['price_without_specific_price'] != $product['price'];
else
$product['is_discounted'] = $product['price_without_specific_price'] != $product['price_wt'];
// On sépare les produits normaux des extensions...
if($product['id_category_default'] == 8)
{
$extensions[] = $product;
unset($summary['products'][$key]);
}
}
$summary['products'] = array_merge($summary['products'], $extensions);
// Get available cart rules and unset the cart rules already in the cart
$available_cart_rules = CartRule::getCustomerCartRules($this->context->language->id, (isset($this->context->customer->id) ? $this->context->customer->id : 0), true, true, true, $this->context->cart);
$cart_cart_rules = $this->context->cart->getCartRules();
foreach ($available_cart_rules as $key => $available_cart_rule)
{
if (!$available_cart_rule['highlight'] || strpos($available_cart_rule['code'], 'BO_ORDER_') === 0)
{
unset($available_cart_rules[$key]);
continue;
}
foreach ($cart_cart_rules as $cart_cart_rule)
if ($available_cart_rule['id_cart_rule'] == $cart_cart_rule['id_cart_rule'])
{
unset($available_cart_rules[$key]);
continue 2;
}
}
$show_option_allow_separate_package = (!$this->context->cart->isAllProductsInStock(true) && Configuration::get('PS_SHIP_WHEN_AVAILABLE'));
$this->context->smarty->assign($summary);
$this->context->smarty->assign(array(
'token_cart' => Tools::getToken(false),
'isLogged' => $this->isLogged,
'isVirtualCart' => $this->context->cart->isVirtualCart(),
'productNumber' => $this->context->cart->nbProducts(),
'voucherAllowed' => CartRule::isFeatureActive(),
'shippingCost' => $this->context->cart->getOrderTotal(true, Cart::ONLY_SHIPPING),
'shippingCostTaxExc' => $this->context->cart->getOrderTotal(false, Cart::ONLY_SHIPPING),
'customizedDatas' => $customizedDatas,
'CUSTOMIZE_FILE' => Product::CUSTOMIZE_FILE,
'CUSTOMIZE_TEXTFIELD' => Product::CUSTOMIZE_TEXTFIELD,
'lastProductAdded' => $this->context->cart->getLastProduct(),
'displayVouchers' => $available_cart_rules,
'currencySign' => $this->context->currency->sign,
'currencyRate' => $this->context->currency->conversion_rate,
'currencyFormat' => $this->context->currency->format,
'currencyBlank' => $this->context->currency->blank,
'show_option_allow_separate_package' => $show_option_allow_separate_package,
'smallSize' => Image::getSize(ImageType::getFormatedName('small'))
));
$this->context->smarty->assign(array(
'HOOK_SHOPPING_CART' => Hook::exec('displayShoppingCartFooter', $summary),
'HOOK_SHOPPING_CART_EXTRA' => Hook::exec('displayShoppingCart', $summary)
));
$summary = $this->context->cart->getSummaryDetails();
$this->context->smarty->assign(array(
'DISPLAY_CART_SUMMARY_STOCK_INFO' => Hook::exec('displayCartSummaryStockInfo', $summary)
));
}
}