[+] BO: Add BackOffice orders

This commit is contained in:
rGaillard
2011-11-02 09:18:45 +00:00
parent a44f5fc8a1
commit bf3d89e1fb
9 changed files with 1156 additions and 26 deletions
+10
View File
@@ -677,4 +677,14 @@ class CustomerCore extends ObjectModel
Context::getContext()->cookie->mylogout();
$this->logged = 0;
}
public function getLastCart()
{
$carts = Cart::getCustomerCarts((int)$this->id);
if (!count($carts))
return false;
$cart = array_shift($carts);
$cart = new Cart((int)$cart['id_cart']);
return ($cart->nbProducts() === 0 ? (int)$cart->id : false);
}
}
+8
View File
@@ -587,4 +587,12 @@ class DiscountCore extends CartRule
Tools::displayAsDeprecated();
return CartRule::isFeatureActive();
}
public static function getVoucherByName($name, $id_lang)
{
return Db::getInstance()->ExecuteS('SELECT d.*, dl.*
FROM '._DB_PREFIX_.'discount d
LEFT JOIN '._DB_PREFIX_.'discount_lang dl ON (d.id_discount = dl.id_discount AND dl.id_lang='.(int)$id_lang.')
WHERE name LIKE \'%'.pSQL($name).'%\'');
}
}
+28
View File
@@ -119,6 +119,9 @@ class FrontControllerCore extends Controller
$link = new Link($protocol_link, $protocol_content);
$this->context->link = $link;
if ($id_cart = (int)$this->recoverCart())
$this->context->cookie->id_cart = (int)$id_cart;
if ($this->auth AND !$this->context->customer->isLogged($this->guestAllowed))
Tools::redirect('index.php?controller=authentication'.($this->authRedirection ? '&back='.$this->authRedirection : ''));
@@ -729,5 +732,30 @@ class FrontControllerCore extends Controller
return parent::addJS($js_uri);
}
protected function recoverCart()
{
if (($id_cart = (int)Tools::getValue('recover_cart')) && Tools::getValue('token_cart') == md5(_COOKIE_KEY_.'recover_cart_'.$id_cart))
{
$cart = new Cart((int)$id_cart);
if (Validate::isLoadedObject($cart))
{
$customer = new Customer((int)$cart->id_customer);
if(Validate::isLoadedObject($customer))
{
$this->context->cookie->id_customer = (int)$customer->id;
$this->context->cookie->customer_lastname = $customer->lastname;
$this->context->cookie->customer_firstname = $customer->firstname;
$this->context->cookie->logged = 1;
$this->context->cookie->is_guest = $customer->isGuest();
$this->context->cookie->passwd = $customer->passwd;
$this->context->cookie->email = $customer->email;
return $id_cart;
}
}
}
else
return false;
}
}
+2 -2
View File
@@ -74,12 +74,12 @@ class OrderHistoryCore extends ObjectModel
{
if ($new_order_state != NULL)
{
Hook::updateOrderStatus((int)($new_order_state), (int)($id_order));
Hook::updateOrderStatus((int)($new_order_state), (int)$id_order);
$order = new Order((int)($id_order));
/* Best sellers */
$newOS = new OrderState((int)($new_order_state), $order->id_lang);
$oldOrderStatus = OrderHistory::getLastOrderState((int)($id_order));
$oldOrderStatus = OrderHistory::getLastOrderState((int)$id_order);
$cart = Cart::getCartByOrderId($id_order);
$isValidated = $this->isValidated();
if (Validate::isLoadedObject($cart))
+1 -1
View File
@@ -203,7 +203,7 @@ abstract class PaymentModuleCore extends Module
foreach ($products AS $key => $product)
{
$price = Product::getPriceStatic((int)($product['id_product']), false, ($product['id_product_attribute'] ? (int)($product['id_product_attribute']) : NULL), 6, NULL, false, true, $product['cart_quantity'], false, (int)($order->id_customer), (int)($order->id_cart), (int)($order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
$price_wt = Product::getPriceStatic((int)($product['id_product']), true, ($product['id_product_attribute'] ? (int)($product['id_product_attribute']) : NULL), 2, NULL, false, true, $product['cart_quantity'], false, (int)($order->id_customer), (int)($order->id_cart), (int)($order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
$price_wt = Product::getPriceStatic((int)($product['id_product']), true, ($product['id_product_attribute'] ? (int)($product['id_product_attribute']) : NULL), 2, NULL, false, true, $product['cart_quantity'], false, (int)($order->id_customer), (int)($order->id_cart), (int)($order->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
$customizationQuantity = 0;
if (isset($customizedDatas[$product['id_product']][$product['id_product_attribute']]))