public function renderDetails($tpl = null) { $orderModel = new JeproshopOrderModelOrder(); $orders = $orderModel->getOrderList(); $this->assignRef('orders', $orders); $pagination = $orderModel->getPagination(); $this->assignRef('pagination', $pagination); $this->addToolBar(); $this->sideBar = JHtmlSideBar::render(); parent::display($tpl); }
public static function getOrdersReturn($customer_id, $order_id = false, $no_denied = false, JeproshopContext $context = null) { if (!$context) { $context = JeproshopContext::getContext(); } $db = JFactory::getDBO(); $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_order_return') . " WHERE " . $db->quoteName('customer_id'); $query .= " = " . (int) $customer_id . ($order_id ? " AND " . $db->quoteName('order_id') . " = " . (int) $order_id : ""); $query .= ($no_denied ? " AND " . $db->quoteName('state') . " != 4" : "") . " ORDER BY " . $db->quoteName('date_add') . " DESC "; $db->setQuery($query); $data = $db->loadObjectList(); foreach ($data as $k => $or) { $state = new JeproshopOrderReturnStateModelOrderReturnState($or->state); $data[$k]->state_name = $state->name[$context->language->lang_id]; $data[$k]->type = 'Return'; $data[$k]->tracking_number = $or->order_return_id; $data[$k]->can_edit = false; $data[$k]->reference = JeproshopOrderModelOrder::getUniqReferenceOf($or->order_id); } return $data; }
public function update_status() { $app = JFactory::getApplication(); $order_status_id = $app->input->get('order_status_id'); $order_id = $app->input->get('order_id'); $order = new JeproshopOrderModelOrder($order_id); $context = JeproshopContext::getContext(); if (!JeproshopTools::isLoadedObject($order, 'order_id')) { echo '<p>' . JText::_('COM_JEPROSHOP_THE_ORDER_CANNOT_BE_FOUND_WITH_IN_YOUR_DATABASE_MESSAGE') . '</p>'; } if ($this->viewAccess()) { $orderStatus = new JeproshopOrderStatusModelOrderStatus($order_status_id); if (!JeproshopTools::isLoadedObject($orderStatus, 'order_status_id')) { echo JText::_('COM_JEPROSHOP_THE_ORDER_STATUS_CANNOT_BE_FOUND_WITH_IN_YOUR_DATABASE_MESSAGE'); } else { $order = new JeproshopOrderModelOrder(); $currentOrderStatus = $order->getCurrentOrderStatus(); if ($currentOrderStatus->order_status_id != $orderStatus) { // Create a order history $orderHistory = new JeproshopOrderHistoryModelOrderHistory(); $orderHistory->order_id = $order->order_id; $orderHistory->employee_id = (int) $context->employee->employee_id; $useExistingPayment = false; if (!$order->hasInvoice()) { $useExistingPayment = true; } $orderHistory->changeOrderStatusId((int) $orderStatus->order_status_id, $order, $useExistingPayment); $carrier = new JeproshopCarrierModelCarrier($order->carrier_id, $order->lang_id); $templateVars = array(); if ($orderHistory->order_status_id == JeproshopSettingModelSetting::getValue('order_status_shipping') && $order->shipping_number) { } if ($orderHistory->addWithEmail(true, $templateVars)) { // synchronizes quantities if needed... if (JeproshopSettingModelSetting::getValue('advanced_stock_management')) { foreach ($order->getProducts() as $product) { if (JeproshopStockAvailableModelStockAvailable::dependsOnStock($product->product_id)) { JeproshopStockAvailableModelStockAvailable::synchronize($product->product_id, (int) $product->sho_id); } } } $app->redirect('index.php?option=com_jeproshop&view=order&task=view&order_id=' . (int) $order->order_id . '&' . JeproshopTools::getOrderToken() . '=1'); } echo JText::_('COM_JEPROSHOP_AN_ERROR_OCCURRED_WHILE_CHANGING_ORDER_STATUS_OR_WE_WERE_UNABLE_TO_SEND_AN_EMAIL_TO_THE_CUSTOMER_MESSAGE'); } else { echo JText::_('COM_JEPROSHOP_THE_ORDER_HAS_ALREADY_BEEN_ASSIGNED_THIS_STATUS_MESSAGE'); } } } else { echo JText::_('COM_JEPROSHOP_YOU_DO_NOT_HAVE_PERMISSION_TO_EDIT_THIS_ORDER_MESSAGE'); } }
/** * Check if order is free * @return boolean * / public function checkFreeOrder(){ $context = JeproshopContext::getContext(); if ($context->cart->getOrderTotal() <= 0) { $order = new JeproshopFreeOrderModelFreeOrder(); $order->free_order_class = true; $order->validateOrder($context->cart->cart_id, Configuration::get('PS_OS_PAYMENT'), 0, Tools::displayError('Free order', false), null, array(), null, false, $context->cart->secure_key); return (int)JeproshopOrderModelOrder::getOrderByCartId($context->cart->cart_id); } return false; } public function assignCarrier(){ $view = JFactory::getDBO(); $context = JeproshopContext::getContext(); $address = new JeproshopAddressModelAddress($context->cart->address_delivery_id); $zone_id = JeproshopAddressModelAddress::getZoneIdByAddressId($address->address_id); $carriers = $context->cart->simulateCarriersOutput(null, true); $checked = $context->cart->simulateCarrierSelectedOutput(false); $delivery_option_list = $context->cart->getDeliveryOptionList(); $delivery_option = $context->cart->getDeliveryOption(null, false); $this->setDefaultCarrierSelection($delivery_option_list); $view->assignRef('address_collection', $context->cart->getAddressCollection()); $view->assignRef('delivery_option_list', $delivery_option_list); $view->assignRef('carriers', $carriers); $view->assignRef('checked', $checked); $view->assignRef('delivery_option', $delivery_option); $vars = array( /*'HOOK_BEFORECARRIER' => Hook::exec('displayBeforeCarrier', array( 'carriers' => $carriers, 'checked' => $checked, 'delivery_option_list' => $delivery_option_list, 'delivery_option' => $delivery_option ))* / ); JeproshopCartModelCart::addExtraCarriers($vars); $view->assignRef('extra_carriers', $vars); } /** * Decides what the default carrier is and update the cart with it * * @todo this function must be modified - id_carrier is now delivery_option * * @param array $carriers * * @deprecated since 1.5.0 * * @return number the id of the default carrier * / protected function setDefaultCarrierSelection($carriers) { $context = JeproshopContext::getContext(); if (!$context->cart->getDeliveryOption(null, true)) $context->cart->setDeliveryOption($context->cart->getDeliveryOption()); }*/ public function globalInitialization() { $app = JFactory::getApplication(); $view = $app->input->get('view'); $viewClass = $this->getView($view, JFactory::getDocument()->getType()); $context = JeproshopContext::getContext(); $this->isLogged = (bool) ($context->customer->customer_id && JeproshopCustomerModelCustomer::customerIdExistsStatic((int) $context->cookie->customer_id)); parent::initialize(); /* Disable some cache related bugs on the cart/order */ header('Cache-Control: no-cache, must-revalidate'); header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); if (!$context->customer->isLogged(true) && $this->useMobileTheme() && $app->input->get('step')) { $app->redirect(JRoute::_('index.php?option=com_jeproshop&view=authentication&lang_id=' . $context->language->lang_id, true, 1)); } // Redirect to the good order process $task = $app->input->get('task', ''); $order_process_type = JeproshopSettingModelSetting::getValue('order_process_type'); if ($order_process_type == 'standard' && ($task != '' || $task != 'display')) { //$app->redirect('index.php?option=com_jeproshop&view=order'); } if ($order_process_type == 'page_checkout' && $task != 'opc') { $step = $app->input->get('step'); if (isset($step) && $step == 3) { $app->redirect('index.php?option=com_jeproshop&view=order&task=opc&isPaymentStep=true'); } $app->redirect('index.php?option=com_jeproshop&view=order&task=opc'); } $catalog_mode = JeproshopSettingModelSetting::getValue('catalog_mode'); if ($catalog_mode) { $this->has_errors = true; JError::raiseError(500, JText::_('COM_JEPROSHOP_THIS_STORE_DOES_NOT_ACCEPT_NEW_ORDER_MESSAGE')); } $order_id = (int) $app->input->get('order_id'); $currentTask = $app->input->get('task'); if ($currentTask == 'submitReorder' && $order_id) { $oldCart = new JeproshopCartModelCart(JeproshopOrderModelOrder::getStaticCartId($order_id, $context->customer->customer_id)); $duplication = $oldCart->duplicate(); if (!$duplication || !JeproshopTools::isLoadedObject($duplication->cart, 'cart_id')) { $this->has_errors = true; Tools::displayError('Sorry. We cannot renew your order.'); } else { if (!$duplication->success) { $this->has_errors = true; Tools::displayError('Some items are no longer available, and we are unable to renew your order.'); } else { $context->cookie->cart_id = $duplication->cart->cart_id; $context->cookie->write(); if ($order_process_type == 'page_checkout') { $app->redirect('index.php?option=com_jeproshop&view=order&task=opc'); } $app->redirect('index.php?option=com_jeproshop&view=order'); } } } $viewClass->assignRef('order_process_type', $order_process_type); $nbProducts = $context->cart->numberOfProducts(); if ($nbProducts) { if (JeproshopCartRuleModelCartRule::isFeaturePublished()) { if (Tools::isSubmit('submitAddDiscount')) { if (!($code = trim(Tools::getValue('discount_name')))) { $this->has_errors = true; JError::raiseError('You must enter a voucher code.'); } elseif (!Validate::isCleanHtml($code)) { $this->has_errors = true; JEroor::raiseError('The voucher code is invalid.'); } else { $cartRule = new JeproshopCartRuleModelCartRule(JeproshopCartRuleModelCartRule::getIdByCode($code)); if ($cartRule && JeproshopTools::isLoadedObject($cartRule, 'cart_rule_id')) { if ($error = $cartRule->checkValidity($context, false, true)) { $this->has_errors = true; JError::raiseError(500, $error); } else { $context->cart->addCartRule($cartRule->cart_rule_id); if (Configuration::get('PS_ORDER_PROCESS_TYPE') == 1) { Tools::redirect('index.php?controller=order-opc&addingCartRule=1'); } Tools::redirect('index.php?controller=order&task=adding_cart_rule'); } } else { $this->has_errors = true; Tools::displayError('This voucher does not exists.'); } } $discountName = JeproshopTools::safeOutput($code); $viewClass->assignRef('discount_name', $discountName); } elseif (($cart_rule_id = (int) Tools::getValue('delete_discount')) && JeproshopTools::isUnsignedId($cart_rule_id)) { $context->cart->removeCartRule($cart_rule_id); $app->redirect('index.php?option=com_jeproshop&view=order&task=opc'); } } /* Is there only virtual product in cart */ if ($isVirtualCart = $context->cart->isVirtualCart()) { $this->setNoCarrier(); } } //$viewClass->assignRef('back', JTools::safeOutput(Tools::getValue('back')));*/ }
/** * @static * @param $lang_id * @param $customer_id * @param bool $published * @param bool $includeGeneric * @param bool $inStock * @param JeproshopCartModelCart|null $cart * @return array */ public static function getCustomerCartRules($lang_id, $customer_id, $published = false, $includeGeneric = true, $inStock = false, JeproshopCartModelCart $cart = null) { if (!JeproshopCartRuleModelCartRule::isFeaturePublished()) { return array(); } $db = JFactory::getDBO(); $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_cart_rule') . " AS cart_rule LEFT JOIN " . $db->quoteName('#__jeproshop_cart_rule_lang'); $query .= " AS cart_rule_lang ON (cart_rule." . $db->quoteName('cart_rule_id') . " = cart_rule_lang." . $db->quoteName('cart_rule_id') . " AND "; $query .= "cart_rule_lang." . $db->quoteName('lang_id') . " = " . (int) $lang_id . ") WHERE ( cart_rule." . $db->quoteName('customer_id') . " = "; $query .= (int) $customer_id . " OR cart_rule.group_restriction = 1 " . ($includeGeneric ? "OR cart_rule." . $db->quoteName('customer_id') . " = 0" : ""); $query .= ") AND cart_rule.date_from < \"" . date('Y-m-d H:i:s') . "\" AND cart_rule.date_to > \"" . date('Y-m-d H:i:s') . "\""; $query .= ($published ? " AND cart_rule" . $db->quoteName('published') . " = 1" : "") . ($inStock ? " AND cart_rule." . $db->quoteName('quantity') . " > 0" : ""); $db->setQuery($query); $result = $db->loadObjectList(); // Remove cart rule that does not match the customer groups $customerGroups = JeproshopCustomerModelCustomer::getGroupsStatic($customer_id); foreach ($result as $key => $cart_rule) { if ($cart_rule->group_restriction) { $query = "SELECT " . $db->quoteName('group_id') . " FROM " . $db->quoteName('#__jeproshop_cart_rule_group') . " WHERE " . $db->quoteName('cart_rule_id') . " = " . (int) $cart_rule->cart_rule_id; $db->setQuery($query); $cartRuleGroups = $db->loadObjectList(); foreach ($cartRuleGroups as $cartRuleGroup) { if (in_array($cartRuleGroup->group_id, $customerGroups)) { continue 2; } } unset($result[$key]); } } foreach ($result as &$cart_rule) { if ($cart_rule->quantity_per_user) { $quantity_used = JeproshopOrderModelOrder::getCustomerDiscounts((int) $customer_id, (int) $cart_rule->cart_rule_id); if (isset($cart) && isset($cart->cart_id)) { $quantity_used += $cart->getDiscountsCustomer((int) $cart_rule->cart_rule_id); } $cart_rule->quantity_for_user = $cart_rule->quantity_per_user - $quantity_used; } else { $cart_rule->quantity_for_user = 0; } } unset($cart_rule); foreach ($result as $cart_rule) { if ($cart_rule->shop_restriction) { $query = "SELECT shop_id FROM " . $db->quoteName('#__jeproshop_cart_rule_shop') . " WHERE cart_rule_id = " . (int) $cart_rule->cart_rule_id; $db->setQuery($query); $cartRuleShops = $db->loadObjectList(); foreach ($cartRuleShops as $cartRuleShop) { if (JeproshopShopModelShop::isFeatureActive() && $cartRuleShop->shop_id == JeproshopContext::getShopContext()->shop->shop_id) { continue 2; } } unset($result[$key]); } } // RetroCompatibility with 1.4 discounts foreach ($result as &$cart_rule) { $cart_rule->value = 0; $cart_rule->minimal = JeproshopTools::convertPriceFull($cart_rule->minimum_amount, new JeproshopCurrencyModelCurrency($cart_rule->minimum_amount_currency), JeproshopContext::getContext()->currency); $cart_rule->cumulable = !$cart_rule->cart_rule_restriction; $cart_rule->discount_type_id = false; if ($cart_rule->free_shipping) { $cart_rule->discount_type_id = Discount::FREE_SHIPPING; } elseif ($cart_rule->reduction_percent > 0) { $cart_rule->discount_type_id = Discount::PERCENT; $cart_rule->value = $cart_rule->reduction_percent; } elseif ($cart_rule->reduction_amount > 0) { $cart_rule->discount_type_id = Discount::AMOUNT; $cart_rule->value = $cart_rule->reduction_amount; } } return $result; }
public function renderView($tpl = null) { if ($this->getLayout() !== 'modal') { } if ($this->context == null) { $this->context = JeproshopContext::getContext(); } $db = JFactory::getDBO(); $this->setLayout('view'); $this->loadObject(); if (!JeproshopTools::isLoadedObject($this->customer, 'customer_id')) { return; } $this->context->customer = $this->customer; $customer_stats = $this->customer->getStats(); $query = "SELECT SUM(total_paid_real) FROM " . $db->quoteName('#__jeproshop_orders'); $query .= " WHERE customer_id = " . (int) $this->customer->customer_id . " AND valid = 1"; $db->setQuery($query); $total_customer = $db->loadResult(); if ($total_customer) { $query = "SELECT SQL_CALC_FOUND_ROWS COUNT(*) FROM " . $db->quoteName('#__jeproshop_orders'); $query .= " WHERE valid = 1 AND customer_id != " . (int) $this->customer->customer_id . " GROUP BY "; $query .= "customer_id HAVING SUM(total_paid_real) > " . (int) $total_customer; $db->setQuery($query); $db->loadResult(); $count_better_customers = (int) $db->loadResult('SELECT FOUND_ROWS()') + 1; } else { $count_better_customers = '-'; } $orders = JeproshopOrderModelOrder::getCustomerOrders($this->customer->customer_id, true); $total_orders = count($orders); for ($i = 0; $i < $total_orders; $i++) { $orders[$i]->total_paid_real_not_formated = $orders[$i]->total_paid_real; $orders[$i]->total_paid_real = JeproshopTools::displayPrice($orders[$i]->total_paid_real, new JeproshopCurrencyModelCurrency((int) $orders[$i]->currency_id)); } $messages = JeproshopCustomerThreadModelCustomerThread::getCustomerMessages((int) $this->customer->customer_id); $total_messages = count($messages); for ($i = 0; $i < $total_messages; $i++) { $messages[$i]->message = substr(strip_tags(html_entity_decode($messages[$i]->message, ENT_NOQUOTES, 'UTF-8')), 0, 75); $messages[$i]->date_add = Tools::displayDate($messages[$i]->date_add, null, true); } $groups = $this->customer->getGroups(); $total_groups = count($groups); for ($i = 0; $i < $total_groups; $i++) { $group = new JeproshopGroupModelGroup($groups[$i]); $groups[$i] = array(); $groups[$i]['group_id'] = $group->group_id; $groups[$i]['name'] = $group->name[$this->context->controller->default_form_language]; } $total_ok = 0; $orders_ok = array(); $orders_ko = array(); foreach ($orders as $order) { if (!isset($order->order_state)) { $order->order_state = JText::_('COM_JEPROSHOP_THERE_IS_NO_STATUS_DEFINED_FOR_THIS_ORDER_MESSAGE'); } if ($order->valid) { $orders_ok[] = $order; $total_ok += $order->total_paid_real_not_formated; } else { $orders_ko[] = $order; } } $products = $this->customer->getBoughtProducts(); $carts = JeproshopCartModelCart::getCustomerCarts($this->customer->customer_id); $total_carts = count($carts); for ($i = 0; $i < $total_carts; $i++) { $cart = new JeproshopCartModelCart((int) $carts[$i]->cart_id); $this->context->cart = $cart; $summary = $cart->getSummaryDetails(); $currency = new JeproshopCurrencyModelCurrency((int) $carts[$i]->currency_id); $carrier = new JeproshopCarrierModelCarrier((int) $carts[$i]->carrier_id); $carts[$i]['id_cart'] = sprintf('%06d', $carts[$i]['id_cart']); $carts[$i]['date_add'] = JeproshopValidator::displayDate($carts[$i]->date_add, null, true); $carts[$i]['total_price'] = Tools::displayPrice($summary->total_price, $currency); $carts[$i]->name = $carrier->name; } $query = "SELECT DISTINCT cart_product.product_id, cart.cart_id, cart.shop_id, cart_product.shop_id "; $query .= " AS cart_product_shop_id FROM " . $db->quoteName('#__jeproshop_cart_product') . " AS cart_product"; $query .= " JOIN " . $db->quoteName('#__jeproshop_cart') . " AS cart ON (cart.cart_id = cart_product.cart_id) "; $query .= "JOIN " . $db->quoteName('#__jeproshop_product') . " AS product ON (cart_product.product_id = product."; $query .= "product_id) WHERE cart.customer_id = " . (int) $this->customer->customer_id . " AND cart_product.product_id"; $query .= " NOT IN ( SELECT product_id FROM " . $db->quoteName('#__jeproshop_orders') . " AS ord JOIN "; $query .= $db->quoteName('#__jeproshop_order_detail') . " AS ord_detail ON (ord.order_id = ord_detail.order_id ) WHERE "; $query .= "ord.valid = 1 AND ord.customer_id = " . (int) $this->customer->customer_id . ")"; $db->setQuery($query); $interested = $db->loadObjectList(); $total_interested = count($interested); for ($i = 0; $i < $total_interested; $i++) { $product = new JeproshopProductModelProduct($interested[$i]->product_id, false, $this->context->controller->default_form_language, $interested[$i]->shop_id); if (!Validate::isLoadedObject($product, 'product_id')) { continue; } $interested[$i]->url = $this->context->controller->getProductLink($product->product_id, $product->link_rewrite, JeproshopCategoryModelCategory::getLinkRewrite($product->default_category_id, $this->context->controller->default_form_language), null, null, $interested[$i]->cp_shop_id); $interested[$i]->product_id = (int) $product->product_id; $interested[$i]->name = htmlentities($product->name); } $connections = $this->customer->getLastConnections(); if (!is_array($connections)) { $connections = array(); } $total_connections = count($connections); for ($i = 0; $i < $total_connections; $i++) { $connections[$i]->http_referer = $connections[$i]->http_referer ? preg_replace('/^www./', '', parse_url($connections[$i]->http_referer, PHP_URL_HOST)) : JText::_('COM_JEPROSHOP_DIRECT_LINK_LABEL'); } $referrers = JeproshopReferrerModelReferrer::getReferrers($this->customer->customer_id); $total_referrers = count($referrers); for ($i = 0; $i < $total_referrers; $i++) { $referrers[$i]->date_add = JeproshopTools::displayDate($referrers[$i]->date_add, null, true); } $customerLanguage = new JeproshopLanguageModelLanguage($this->customer->lang_id); $shop = new JeproshopShopModelShop($this->customer->shop_id); //$this->assignRef('customer', $customer); /*'gender' => $gender, /* 'gender_image' => $gender_image, // General information of the customer */ $registration = JeproshopTools::displayDate($this->customer->date_add, null, true); $this->assignRef('registration_date', $registration); $this->assignRef('customer_stats', $customer_stats); $last_visit = JeproshopTools::displayDate($customer_stats->last_visit, null, true); $this->assignRef('last_visit', $last_visit); $this->assignRef('count_better_customers', $count_better_customers); $shop_feature_active = JeproshopShopModelShop::isFeaturePublished(); $this->assignRef('shop_is_feature_active', $shop_feature_active); $this->assignRef('shop_name', $shop->shop_name); $customerBirthday = JeproshopTools::displayDate($this->customer->birthday); $this->assignRef('customer_birthday', $customerBirthday); $last_update = JeproshopTools::displayDate($this->customer->date_upd, null, true); $this->assignRef('last_update', $last_update); $customerExists = JeproshopCustomerModelCustomer::customerExists($this->customer->email); $this->assignRef('customer_exists', $customerExists); $this->assignRef('lang_id', $this->customer->lang_id); $this->assignRef('customerLanguage', $customerLanguage); // Add a Private note $customerNote = JeproshopTools::htmlentitiesUTF8($this->customer->note); $this->assignRef('customer_note', $customerNote); // Messages $this->assignRef('messages', $messages); // Groups $this->assignRef('groups', $groups); // Orders $this->assignRef('orders', $orders); $this->assignRef('orders_ok', $orders_ok); $this->assignRef('orders_ko', $orders_ko); $total_ok = JeproshopTools::displayPrice($total_ok, $this->context->currency->currency_id); $this->assignRef('total_ok', $total_ok); // Products $this->assignRef('products', $products); // Addresses $addresses = $this->customer->getAddresses($this->context->controller->default_form_language); $this->assignRef('addresses', $addresses); // Discounts $discounts = JeproshopCartRuleModelCartRule::getCustomerCartRules($this->context->controller->default_form_language, $this->customer->customer_id, false, false); $this->assignRef('discounts', $discounts); // Carts $this->assignRef('carts', $carts); // Interested $this->assignRef('interested_products', $interested); // Connections $this->assignRef('connections', $connections); // Referrers $this->assignRef('referrers', $referrers); if ($this->getLayout() != 'modal') { $this->addToolBar(); $this->sideBar = JHtmlSidebar::render(); } parent::display($tpl); }
public function delete() { if (!count(JeproshopOrderModelOrder::getCustomerOrders((int) $this->customer_id))) { $addresses = $this->getAddresses((int) JeproshopSettingModelSetting::getValue('default_lang')); foreach ($addresses as $address) { $obj = new JeproshopAddressModelAddress((int) $address->address_id); $obj->delete(); } } $db = JFactory::getDBO(); $query = "DELETE FROM " . $db->quoteName('#__jeproshop_customer_group') . " WHERE " . $db->quoteName('customer_id') . " = " . (int) $this->customer_id; $db->setQuery($query); $db->query(); $query = "DELETE FROM " . $db->quoteName('#__jeproshop_message') . " WHERE " . $db->quoteName('customer_id') . " = " . (int) $this->customer_id; $db->setQuery($query); $db->query(); $query = "DELETE FROM " . $db->quoteName('#__jeproshop_specific_price') . " WHERE " . $db->quoteName('customer_id') . " = " . (int) $this->customer_id; $db->setQuery($query); $db->query(); $query = "DELETE FROM " . $db->quoteName('#__jeproshop_compare') . " WHERE " . $db->quoteName('customer_id') . " = " . (int) $this->customer_id; $db->setQuery($query); $db->query(); $query = "SELECT " . $db->quoteName('cart_id') . " FROM " . $db->quoteName('#__jeproshop_cart') . " WHERE " . $db->quoteName('customer_id') . " = " . (int) $this->customer_id; $db->setQuery($query); $carts = $db->loadObjectList(); if ($carts) { foreach ($carts as $cart) { $query = "DELETE FROM " . $db->quoteName('#__jeproshop_cart') . " WHERE " . $db->quoteName('cart_id') . " = " . (int) $cart->cart_id; $db->setQuery($query); $db->query(); $query = "DELETE FROM " . $db->quoteName('#__jeproshop_cart_product') . " WHERE " . $db->quoteName('cart_id') . " = " . (int) $cart->cart_id; $db->setQuery($query); $db->query(); } } $query = "SELECT " . $db->quoteName('customer_thread_id') . " FROM " . $db->quoteName('#__jeproshop_customer_thread') . " WHERE " . $this->quoteName('customer_id') . " = " . (int) $this->customer_id; $db->setQuery($query); $customer_threads = $db->loadObjectList(); if ($customer_threads) { foreach ($customer_threads as $customer_thread) { $query = "DELETE FROM " . $db->quoteName('#__jeproshop_customer_thread') . " WHERE " . $db->quoteName('customer_thread_id') . " = " . (int) $customer_thread->customer_thread_id; $db->setQuery($query); $db->query(); $query = "DELETE FROM " . $db->quoteName('#__jeproshop_customer_message') . " WHERE " . $db->quoteName('customer_thread_id') . " = " . (int) $customer_thread->customer_thread_id; $db->setQuery($query); $db->query(); } } JeproshopCartRuleModelCartRule::deleteByCustomerId((int) $this->customer_id); return parent::delete(); }
public function renderView($tpl = null) { if (!$this->loadObject(true)) { return; } if (!isset($this->context)) { $this->context = JeproshopContext::getContext(); } $customer = new JeproshopCustomerModelCustomer($this->cart->customer_id); $currency = new JeproshopCurrencyModelCurrency($this->cart->currency_id); $this->context->cart = $this->cart; $this->context->currency = $currency; $this->context->customer = $customer; //$this->toolbar_title = sprintf($this->l('Cart #%06d'), $this->context->cart->cart_id); $products = $this->cart->getProducts(); $customized_datas = JeproshopProductModelProduct::getAllCustomizedDatas((int) $this->cart->cart_id); JeproshopProductModelProduct::addCustomizationPrice($products, $customized_datas); $summary = $this->cart->getSummaryDetails(); /* Display order information */ $order_id = (int) JeproshopOrderModelOrder::getOrderIdByCartId($this->cart->cart_id); $order = new JeproshopOrderModelOrder($order_id); if (JeproshopTools::isLoadedObject($order, 'order_id')) { $tax_calculation_method = $order->getTaxCalculationMethod(); $shop_id = (int) $order->shop_id; } else { $shop_id = (int) $this->cart->shop_id; $tax_calculation_method = JeproshopGroupModelGroup::getPriceDisplayMethod(JeproshopGroupModelGroup::getCurrent()->group_id); } if ($tax_calculation_method == COM_JEPROSHOP_TAX_EXCLUDED) { $total_products = $summary->total_products; $total_discounts = $summary->total_discounts_tax_exc; $total_wrapping = $summary->total_wrapping_tax_exc; $total_price = $summary->total_price_without_tax; $total_shipping = $summary->total_shipping_tax_exc; } else { $total_products = $summary->total_products_wt; $total_discounts = $summary->total_discounts; $total_wrapping = $summary->total_wrapping; $total_price = $summary->total_price; $total_shipping = $summary->total_shipping; } foreach ($products as $k => &$product) { if ($tax_calculation_method == COM_JEPROSHOP_TAX_EXCLUDED) { $product->product_price = $product->price; $product->product_total = $product->total; } else { $product->product_price = $product->price_wt; $product->product_total = $product->total_wt; } $image = array(); $db = JFactory::getDBO(); if (isset($product->product_attribute_id) && (int) $product->product_attribute_id) { $query = "SELECT " . $db->quoteName('image_id') . " FROM " . $db->quoteName('#__jeproshop_product_attribute_image') . " WHERE product_attribute_id = " . (int) $product->product_attribute_id; $db->setQuery($query); $image = $db->loadObject(); } if (!isset($image->image_id)) { $query = "SELECT " . $db->quoteName('image_id') . " FROM " . $db->quoteName('#__jeproshop_image') . " WHERE " . $db->quoteName('product_id') . " = " . (int) $product->product_id . " AND cover = 1 "; $db->setQuery($query); $image = $db->loadObject(); } $product_obj = new JeproshopProductModelProduct($product->product_id); $product->qty_in_stock = JeproshopStockAvailableModelStockAvailable::getQuantityAvailableByProduct($product->product_id, isset($product->product_attribute_id) ? $product->product_attribute_id : null, (int) $shop_id); $image_product = new JeproshopImageModelImage($image->image_id); $product->image = isset($image->image_id) ? JeproshopImageManager::thumbnail(COM_JEPROSHOP_IMAGE_DIR . 'products/' . $image_product->getExistingImagePath() . '.jpg', 'product_mini_' . (int) $product->product_id . (isset($product->product_attribute_id) ? '_' . (int) $product->product_attribute_id : '') . '.jpg', 45, 'jpg') : '--'; } /*$helper = new HelperKpi(); $helper->id = 'box-kpi-cart'; $helper->icon = 'icon-shopping-cart'; $helper->color = 'color1'; $helper->title = $this->l('Total Cart', null, null, false); $helper->subtitle = sprintf($this->l('Cart #%06d', null, null, false), $cart->id); $helper->value = Tools::displayPrice($total_price, $currency); $kpi = $helper->generate(); */ //$this->assignRef('kpi', $kpi); $this->assignRef('products', $products); $discounts = $this->cart->getCartRules(); $this->assignRef('discounts', $discounts); $this->assignRef('order', $order); $this->assignRef('currency', $currency); $this->assignRef('customer', $customer); $customerStats = $customer->getStats(); $this->assignRef('customer_stats', $customerStats); $this->assignRef('total_products', $total_products); $this->assignRef('total_discounts', $total_discounts); $this->assignRef('total_wrapping', $total_wrapping); $this->assignRef('total_price', $total_price); $this->assignRef('total_shipping', $total_shipping); $this->assignRef('customized_datas', $customized_datas); if ($this->getLayout() != 'modal') { $this->addToolBar(); $this->sideBar = JHtmlSidebar::render(); } parent::display($tpl); }