Example #1
0
 function hookRightColumn($params)
 {
     global $smarty, $category_path;
     $category_path_ids = array();
     foreach ($category_path as $cat) {
         $category_path_ids[] = $cat['id_category'];
     }
     $currency = new Currency(intval($params['cookie']->id_currency));
     $bestsellers = ProductSale::getBestSalesLight(intval($params['cookie']->id_lang), 0, 25);
     $best_sellers = array();
     $nr = 0;
     foreach ($bestsellers as $bestseller) {
         if ($nr >= 5) {
             break;
         }
         $display = false;
         foreach (Product::getIndexedCategories($bestseller['id_product']) as $row) {
             if (in_array($row['id_category'], $category_path_ids)) {
                 $display = true;
                 break;
             }
         }
         if ($display) {
             $bestseller['price'] = Tools::displayPrice(Product::getPriceStaticLC(intval($bestseller['id_product'])), $currency, false, false);
             $best_sellers[] = $bestseller;
             $nr += 1;
         }
     }
     $smarty->assign(array('best_sellers' => $best_sellers, 'mediumSize' => Image::getSize('medium'), 'static_token' => Tools::getToken(false)));
     return $this->display(__FILE__, 'blockbestsellers.tpl');
 }
 function convertAndFormatPrice($price, $currency = false)
 {
     if (!$currency) {
         $currency = Currency::getCurrent();
     }
     return Tools::displayPrice(Tools::convertPrice($price, $currency), $currency);
 }
 /**
  * @see FrontController::postProcess()
  */
 public function postProcess()
 {
     $cart = $this->context->cart;
     if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     // Check that this payment option is still available in case the customer changed his address just before the end of the checkout process
     $authorized = false;
     foreach (Module::getPaymentModules() as $module) {
         if ($module['name'] == 'swipp') {
             $authorized = true;
             break;
         }
     }
     if (!$authorized) {
         die($this->module->l('This payment method is not available.', 'validation'));
     }
     $customer = new Customer($cart->id_customer);
     if (!Validate::isLoadedObject($customer)) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     $currency = $this->context->currency;
     $total = (double) $cart->getOrderTotal(true, Cart::BOTH);
     $mailVars = array('{swipp_phone}' => Configuration::get('SWIPP_PHONE'), '{swipp_owner}' => Configuration::get('SWIPP_OWNER'), '{swipp_payment_dkk}' => Tools::displayPrice($this->module->__getPriceDkk($cart), (int) Currency::getIdByIsoCode('DKK')));
     $this->module->validateOrder($cart->id, Configuration::get('SWIPP_PAYMENT_STATE'), $total, $this->module->displayName, NULL, $mailVars, (int) $currency->id, false, $customer->secure_key);
     Tools::redirect('index.php?controller=order-confirmation&id_cart=' . $cart->id . '&id_module=' . $this->module->id . '&id_order=' . $this->module->currentOrder . '&key=' . $customer->secure_key);
 }
Example #4
0
 public function initContent()
 {
     parent::initContent();
     $this->paypal = new PayPal();
     $this->context = Context::getContext();
     $this->id_module = (int) Tools::getValue('id_module');
     $this->id_order = (int) Tools::getValue('id_order');
     $order = new Order($this->id_order);
     $order_state = new OrderState($order->current_state);
     $paypal_order = PayPalOrder::getOrderById($this->id_order);
     if ($order_state->template[$this->context->language->id] == 'payment_error') {
         $this->context->smarty->assign(array('message' => $order_state->name[$this->context->language->id], 'logs' => array($this->paypal->l('An error occurred while processing payment.')), 'order' => $paypal_order, 'price' => Tools::displayPrice($paypal_order['total_paid'], $this->context->currency)));
         return $this->setTemplate('error.tpl');
     }
     $order_currency = new Currency((int) $order->id_currency);
     $display_currency = new Currency((int) $this->context->currency->id);
     $price = Tools::convertPriceFull($paypal_order['total_paid'], $order_currency, $display_currency);
     $this->context->smarty->assign(array('is_guest' => $this->context->customer->is_guest || $this->context->customer->id == false, 'order' => $paypal_order, 'price' => Tools::displayPrice($price, $this->context->currency->id), 'HOOK_ORDER_CONFIRMATION' => $this->displayOrderConfirmation(), 'HOOK_PAYMENT_RETURN' => $this->displayPaymentReturn()));
     if ($this->context->customer->is_guest || $this->context->customer->id == false) {
         $this->context->smarty->assign(array('id_order' => (int) $this->id_order, 'id_order_formatted' => sprintf('#%06d', (int) $this->id_order), 'order_reference' => $order->reference));
         /* If guest we clear the cookie for security reason */
         $this->context->customer->mylogout();
     }
     if ($this->context->getMobileDevice() == true) {
         $this->setTemplate('order-confirmation-mobile.tpl');
     } else {
         $this->setTemplate('order-confirmation.tpl');
     }
 }
 public function displayContent()
 {
     $id_order = (int) Tools::getValue('id_order');
     $order = new Order($id_order);
     $paypal_order = PayPalOrder::getOrderById($id_order);
     if (defined("PAYPAL_FORCE_CURRENCY")) {
         $currency = new Currency((int) $this->context->currency->id);
         $paycurrency = new Currency(PAYPAL_FORCE_CURRENCY);
         $currency_decimals = $paycurrency->decimals;
         $paypal_order['total_paid'] = $paypal_order['total_paid'] / $currency->conversion_rate * $paycurrency->conversion_rate;
     }
     $price = Tools::displayPrice($paypal_order['total_paid'], $this->context->currency);
     $order_state = new OrderState($id_order);
     if ($order_state) {
         $order_state_message = $order_state->template[$this->context->language->id];
     }
     if (!$order || !$order_state || isset($order_state_message) && $order_state_message == 'payment_error') {
         $this->context->smarty->assign(array('logs' => array($this->paypal->l('An error occurred while processing payment.')), 'order' => $paypal_order, 'price' => $price));
         if (isset($order_state_message) && $order_state_message) {
             $this->context->smarty->assign('message', $order_state_message);
         }
         $template = 'error.tpl';
     } else {
         $this->context->smarty->assign(array('order' => $paypal_order, 'price' => $price));
         if (version_compare(_PS_VERSION_, '1.5', '>')) {
             $this->context->smarty->assign(array('reference_order' => Order::getUniqReferenceOf($paypal_order['id_order'])));
         }
         $template = 'order-confirmation.tpl';
     }
     $this->context->smarty->assign('use_mobile', (bool) $this->paypal->useMobile());
     echo $this->paypal->fetchTemplate($template);
 }
Example #6
0
 public function smartyAssigns(&$smarty, &$params)
 {
     global $errors, $cookie;
     // Set currency
     if (!intval($params['cart']->id_currency)) {
         $currency = new Currency(intval($params['cookie']->id_currency));
     } else {
         $currency = new Currency(intval($params['cart']->id_currency));
     }
     if (!Validate::isLoadedObject($currency)) {
         $currency = new Currency(intval(Configuration::get('PS_CURRENCY_DEFAULT')));
     }
     if ($params['cart']->id_customer) {
         $customer = new Customer(intval($params['cart']->id_customer));
         $taxCalculationMethod = Group::getPriceDisplayMethod(intval($customer->id_default_group));
     } else {
         $taxCalculationMethod = Group::getDefaultPriceDisplayMethod();
     }
     $usetax = $taxCalculationMethod == PS_TAX_EXC ? false : true;
     $products = $params['cart']->getProducts(true);
     $nbTotalProducts = 0;
     foreach ($products as $product) {
         $nbTotalProducts += intval($product['cart_quantity']);
     }
     $wrappingCost = floatval($params['cart']->getOrderTotal($usetax, 6));
     $smarty->assign(array('products' => $products, 'customizedDatas' => Product::getAllCustomizedDatas(intval($params['cart']->id)), 'CUSTOMIZE_FILE' => _CUSTOMIZE_FILE_, 'CUSTOMIZE_TEXTFIELD' => _CUSTOMIZE_TEXTFIELD_, 'discounts' => $params['cart']->getDiscounts(false, $usetax), 'nb_total_products' => intval($nbTotalProducts), 'shipping_cost' => Tools::displayPrice($params['cart']->getOrderTotal($usetax, 5), $currency), 'show_wrapping' => $wrappingCost > 0 ? true : false, 'wrapping_cost' => Tools::displayPrice($wrappingCost, $currency), 'product_total' => Tools::displayPrice($params['cart']->getOrderTotal($usetax, 4), $currency), 'total' => Tools::displayPrice($params['cart']->getOrderTotal($usetax), $currency), 'id_carrier' => intval($params['cart']->id_carrier), 'ajax_allowed' => intval(Configuration::get('PS_BLOCK_CART_AJAX')) == 1 ? true : false));
     if (sizeof($errors)) {
         $smarty->assign('errors', $errors);
     }
     if (isset($cookie->ajax_blockcart_display)) {
         $smarty->assign('colapseExpandStatus', $cookie->ajax_blockcart_display);
     }
 }
Example #7
0
 /**
  * Initialize order controller
  * @see FrontController::init()
  */
 public function init()
 {
     global $orderTotal;
     parent::init();
     $this->step = (int) Tools::getValue('step');
     if (!$this->nbProducts) {
         $this->step = -1;
     }
     // If some products have disappear
     if (!$this->context->cart->checkQuantities()) {
         $this->step = 0;
         $this->errors[] = Tools::displayError('An item in your cart is no longer available in this quantity, you cannot proceed with your order.');
     }
     // Check minimal amount
     $currency = Currency::getCurrency((int) $this->context->cart->id_currency);
     $orderTotal = $this->context->cart->getOrderTotal();
     $minimal_purchase = Tools::convertPrice((double) Configuration::get('PS_PURCHASE_MINIMUM'), $currency);
     if ($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) < $minimal_purchase && $this->step != -1) {
         $this->step = 0;
         $this->errors[] = sprintf(Tools::displayError('A minimum purchase total of %d is required in order to validate your order.'), Tools::displayPrice($minimal_purchase, $currency));
     }
     if (!$this->context->customer->isLogged(true) && in_array($this->step, array(1, 2, 3))) {
         Tools::redirect($this->context->link->getPageLink('authentication', true, (int) $this->context->language->id, 'back=' . $this->context->link->getPageLink('order', true, (int) $this->context->language->id, 'step=' . $this->step . '&multi-shipping=' . (int) Tools::getValue('multi-shipping')) . '&multi-shipping=' . (int) Tools::getValue('multi-shipping')));
     }
     if (Tools::getValue('multi-shipping') == 1) {
         $this->context->smarty->assign('multi_shipping', true);
     } else {
         $this->context->smarty->assign('multi_shipping', false);
     }
     if ($this->context->customer->id) {
         $this->context->smarty->assign('address_list', $this->context->customer->getAddresses($this->context->language->id));
     } else {
         $this->context->smarty->assign('address_list', array());
     }
 }
Example #8
0
 public function displayContent($params)
 {
     $alias_shop = (int) Tools::getValue('ash');
     if (!empty($alias_shop)) {
         $_s = AphStore::getByAlias($alias_shop, Context::getContext()->language->id);
         $id_shop = $_s['id_shop'];
     } else {
         $id_shop = (int) Tools::getValue('ids');
     }
     $shop = new AphStore($id_shop, Context::getContext()->language->id);
     $this->nbOffers = AphOffer::getOffers('store', $id_shop, Context::getContext()->language->id, true, NULL, (int) Configuration::get('APH_OFFERS_PER_PAGE'), $this->orderBy, $this->orderWay, true);
     $this->pagination((int) $this->nbOffers);
     // Pagination must be call after "getStoresByProduct"
     $this->offerSort();
     $id_currency = Validate::isLoadedObject(Context::getContext()->currency) ? (int) Context::getContext()->currency->id : (int) Configuration::get('PS_CURRENCY_DEFAULT');
     $offers = AphOffer::getOffers('store', $id_shop, Context::getContext()->language->id, true, NULL, (int) Configuration::get('APH_OFFERS_PER_PAGE'), $this->orderBy, $this->orderWay);
     foreach ($offers as &$offer) {
         $offer = new AphOffer($offer['id_offer'], (int) Context::getContext()->language->id, (int) $id_shop);
         $offer['price_from'] = Tools::displayPrice($offer->price_wt, $id_currency);
         error_log($o->reduction . ' ' . $o->id);
         $offer['new_price'] = $o->price_wt < 0 ? $o->reduction_type == 'percentage' ? '-' . intval(round($o->reduction)) . '%' : '-' . Tools::displayPrice($o['reduction'], (int) Context::getContext()->currency->id) : Tools::displayPrice($o->price_wt, (int) Context::getContext()->currency->id) . ' ';
         $offer['url'] = Context::getContext()->link->getModuleLink('blockoffers', 'offer', array('aof' => $offer['link_rewrite'], 'ido' => $offer['id_offer']));
         $offer['img_link_rewrite'] = Tools::link_rewrite($offer['legend']);
     }
     $this->context->smarty->assign(array('offers' => $offers, 'nb_offers' => $this->nbOffers));
     $this->context->controller->addJS($this->_path . 'blockoffer.js');
     return $this->display(__FILE__, 'blockoffers.tpl', $this->getCacheId());
 }
Example #9
0
 public function postProcess()
 {
     // Check if cart exists and all fields are set
     $cart = $this->context->cart;
     if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     // Check if module is enabled
     $authorized = false;
     foreach (Module::getPaymentModules() as $module) {
         if ($module['name'] == $this->module->name) {
             $authorized = true;
         }
     }
     if (!$authorized) {
         die('This payment method is not available.');
     }
     // Check if customer exists
     $customer = new Customer($cart->id_customer);
     if (!Validate::isLoadedObject($customer)) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     // Set datas
     $currency = $this->context->currency;
     $total = (double) $cart->getOrderTotal(true, Cart::BOTH);
     $extra_vars = array('{total_to_pay}' => Tools::displayPrice($total), '{cheque_order}' => Configuration::get('MYMOD_CH_ORDER'), '{cheque_address}' => Configuration::get('MYMOD_CH_ADDRESS'), '{bankwire_details}' => Configuration::get('MYMOD_BA_DETAILS'), '{bankwire_owner}' => Configuration::get('MYMOD_BA_OWNER'));
     // Validate order
     $this->module->validateOrder($cart->id, Configuration::get('PS_OS_MYMOD_PAYMENT'), $total, $this->module->displayName, NULL, $extra_vars, (int) $currency->id, false, $customer->secure_key);
     // Redirect on order confirmation page
     Tools::redirect('index.php?controller=order-confirmation&id_cart=' . $cart->id . '&id_module=' . $this->module->id . '&id_order=' . $this->module->currentOrder . '&key=' . $customer->secure_key);
 }
 public function preProcess()
 {
     global $isVirtualCart, $orderTotal;
     parent::preProcess();
     /* If some products have disappear */
     if (!self::$cart->checkQuantities()) {
         $this->step = 0;
         $this->errors[] = Tools::displayError('An item in your cart is no longer available for this quantity, you cannot proceed with your order.');
     }
     /* Check minimal amount */
     $currency = Currency::getCurrency((int) self::$cart->id_currency);
     $orderTotal = self::$cart->getOrderTotal();
     $minimalPurchase = Tools::convertPrice((double) Configuration::get('PS_PURCHASE_MINIMUM'), $currency);
     if (self::$cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) < $minimalPurchase && $this->step != -1) {
         $this->step = 0;
         $this->errors[] = Tools::displayError('A minimum purchase total of') . ' ' . Tools::displayPrice($minimalPurchase, $currency) . ' ' . Tools::displayError('is required in order to validate your order.');
     }
     if (!self::$cookie->isLogged(true) and in_array($this->step, array(1, 2, 3))) {
         Tools::redirect('authentication.php?back=' . urlencode('order.php?step=' . $this->step));
     }
     if ($this->nbProducts) {
         self::$smarty->assign('virtual_cart', $isVirtualCart);
     }
     // Update carrier selected on preProccess in order to fix a bug of
     // block cart when it's hooked on leftcolumn
     if ($this->step == 3 && Tools::isSubmit('processCarrier')) {
         $this->processCarrier();
     }
 }
Example #11
0
    public function getData()
    {
        $currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
        $this->query = 'SELECT SQL_CALC_FOUND_ROWS cr.code, ocr.name, COUNT(ocr.id_cart_rule) as total, ROUND(SUM(o.total_paid_real) / o.conversion_rate,2) as ca
				FROM ' . _DB_PREFIX_ . 'order_cart_rule ocr
				LEFT JOIN ' . _DB_PREFIX_ . 'orders o ON o.id_order = ocr.id_order
				LEFT JOIN ' . _DB_PREFIX_ . 'cart_rule cr ON cr.id_cart_rule = ocr.id_cart_rule
				WHERE o.valid = 1
					' . Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o') . '
					AND o.invoice_date BETWEEN ' . $this->getDate() . '
				GROUP BY ocr.id_cart_rule';
        if (Validate::IsName($this->_sort)) {
            $this->query .= ' ORDER BY `' . bqSQL($this->_sort) . '`';
            if (isset($this->_direction) && (Tools::strtoupper($this->_direction) == 'ASC' || Tools::strtoupper($this->_direction) == 'DESC')) {
                $this->query .= ' ' . pSQL($this->_direction);
            }
        }
        if (($this->_start === 0 || Validate::IsUnsignedInt($this->_start)) && Validate::IsUnsignedInt($this->_limit)) {
            $this->query .= ' LIMIT ' . (int) $this->_start . ', ' . (int) $this->_limit;
        }
        $values = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($this->query);
        foreach ($values as &$value) {
            $value['ca'] = Tools::displayPrice($value['ca'], $currency);
        }
        $this->_values = $values;
        $this->_totalCount = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT FOUND_ROWS()');
    }
Example #12
0
 public function displayContent()
 {
     $id_order = (int) Tools::getValue('id_order');
     $order = PayPalOrder::getOrderById($id_order);
     $price = Tools::displayPrice($order['total_paid'], $this->context->currency);
     $this->context->smarty->assign(array('order' => $order, 'price' => $price));
     echo $this->context->smarty->fetch(_PS_MODULE_DIR_ . '/paypal/views/templates/front/order-confirmation.tpl');
 }
Example #13
0
 public function displayContent()
 {
     $order = PayPalOrder::getOrderById((int) Tools::getValue('id_order'));
     $this->context->smarty->assign(array('order' => $order, 'price' => Tools::displayPrice($order['total_paid'], $this->context->currency), 'use_mobile' => $this->context->getMobileDevice()));
     if (!$order) {
         $this->context->smarty->assign('errors', array($this->paypal->l('Payment error')));
     }
     echo $this->paypal->fetchTemplate('/views/templates/front/', 'order-confirmation');
 }
Example #14
0
 /**
  * Initialize order controller
  * @see FrontController::init()
  */
 public function init()
 {
     global $orderTotal;
     parent::init();
     $this->step = (int) Tools::getValue('step');
     if (!$this->nbProducts) {
         $this->step = -1;
     }
     $product = $this->context->cart->checkQuantities(true);
     if ((int) ($id_product = $this->context->cart->checkProductsAccess())) {
         $this->step = 0;
         $this->errors[] = sprintf(Tools::displayError('An item in your cart is no longer available (%1s). You cannot proceed with your order.'), Product::getProductName((int) $id_product));
     }
     // If some products have disappear
     if (is_array($product)) {
         $this->step = 0;
         $this->errors[] = sprintf(Tools::displayError('An item (%1s) in your cart is no longer available in this quantity. You cannot proceed with your order until the quantity is adjusted.'), $product['name']);
     }
     // Check minimal amount
     $currency = Currency::getCurrency((int) $this->context->cart->id_currency);
     $orderTotal = $this->context->cart->getOrderTotal();
     $minimal_purchase = Tools::convertPrice((double) Configuration::get('PS_PURCHASE_MINIMUM'), $currency);
     if ($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) < $minimal_purchase && $this->step > 0) {
         $this->step = 0;
         $this->errors[] = sprintf(Tools::displayError('A minimum purchase total of %1s (tax excl.) is required to validate your order, current purchase total is %2s (tax excl.).'), Tools::displayPrice($minimal_purchase, $currency), Tools::displayPrice($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS), $currency));
     }
     if (!$this->context->customer->isLogged(true) && in_array($this->step, array(1, 2, 3))) {
         $params = array();
         if ($this->step) {
             $params['step'] = (int) $this->step;
         }
         if ($multi = (int) Tools::getValue('multi-shipping')) {
             $params['multi-shipping'] = $multi;
         }
         $back_url = $this->context->link->getPageLink('order', true, (int) $this->context->language->id, $params);
         $params = array('back' => $back_url);
         if ($multi) {
             $params['multi-shipping'] = $multi;
         }
         if ($guest = (int) Configuration::get('PS_GUEST_CHECKOUT_ENABLED')) {
             $params['display_guest_checkout'] = $guest;
         }
         Tools::redirect($this->context->link->getPageLink('authentication', true, (int) $this->context->language->id, $params));
     }
     if (Tools::getValue('multi-shipping') == 1) {
         $this->context->smarty->assign('multi_shipping', true);
     } else {
         $this->context->smarty->assign('multi_shipping', false);
     }
     if ($this->context->customer->id) {
         $this->context->smarty->assign('address_list', $this->context->customer->getAddresses($this->context->language->id));
     } else {
         $this->context->smarty->assign('address_list', array());
     }
 }
Example #15
0
 public function displayContent()
 {
     $id_order = (int) Tools::getValue('id_order');
     $order = PayPalOrder::getOrderById($id_order);
     $price = Tools::displayPrice($order['total_paid'], $this->context->currency);
     $this->context->smarty->assign(array('order' => $order, 'price' => $price));
     if (version_compare(_PS_VERSION_, '1.5', '>')) {
         $this->context->smarty->assign(array('reference_order' => Order::getUniqReferenceOf($id_order)));
     }
     echo $this->context->smarty->fetch(_PS_MODULE_DIR_ . '/paypal/views/templates/front/order-confirmation.tpl');
 }
 public function initContent()
 {
     parent::initContent();
     if (Tools::getValue('id_cart')) {
         $cart = new Cart((int) Tools::getValue('id_cart'));
         $this->context->smarty->assign(array('total' => Tools::displayPrice($cart->getOrderTotal())));
         return $this->setTemplate('confirmation.tpl');
     } else {
         return $this->setTemplate('error.tpl');
     }
 }
Example #17
0
 /**
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     $cart = $this->context->cart;
     if (!$this->module->checkCurrency($cart)) {
         Tools::redirect('index.php?controller=order');
     }
     $total = sprintf($this->getTranslator()->trans('%1$s (tax incl.)', array(), 'Modules.BankBCA.Shop'), Tools::displayPrice($cart->getOrderTotal(true, Cart::BOTH)));
     $this->context->smarty->assign(array('back_url' => $this->context->link->getPageLink('order', true, NULL, "step=3"), 'confirm_url' => $this->context->link->getModuleLink('bankbca', 'validation', [], true), 'image_url' => $this->module->getPathUri() . 'bankwire.jpg', 'cust_currency' => $cart->id_currency, 'currencies' => $this->module->getCurrency((int) $cart->id_currency), 'total' => $total, 'this_path' => $this->module->getPathUri(), 'this_path_ssl' => Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/' . $this->module->name . '/'));
     $this->setTemplate('payment_execution.tpl');
 }
 public function returnPaymentConfiguration($params)
 {
     $this->context = Context::getContext();
     if (!Tools::isEmpty($params['objOrder']) && $params['objOrder']->module === 'pagseguro') {
         $this->context->smarty->assign(array('total_to_pay' => Tools::displayPrice($params['objOrder']->total_paid, $this->context->currency->id, false), 'status' => 'ok', 'id_order' => (int) $params['objOrder']->id));
         if (isset($params['objOrder']->reference) && !Tools::isEmpty($params['objOrder']->reference)) {
             $this->context->smarty->assign('reference', $params['objOrder']->reference);
         }
     } else {
         $this->context->smarty->assign('status', 'failed');
     }
 }
Example #19
0
 function hookRightColumn($params)
 {
     global $smarty;
     $currency = new Currency(intval($params['cookie']->id_currency));
     $bestsellers = ProductSale::getBestSalesLight(intval($params['cookie']->id_lang), 0, 5);
     $best_sellers = array();
     foreach ($bestsellers as $bestseller) {
         $bestseller['price'] = Tools::displayPrice(Product::getPriceStatic(intval($bestseller['id_product'])), $currency);
         $best_sellers[] = $bestseller;
     }
     $smarty->assign(array('best_sellers' => $best_sellers, 'mediumSize' => Image::getSize('medium')));
     return $this->display(__FILE__, 'blockbestsellers.tpl');
 }
 public function run($params)
 {
     if ($params['objOrder']->payment != $this->module->displayName) {
         return '';
     }
     $reference = $params['objOrder']->id;
     if (isset($params['objOrder']->reference) && !empty($params['objOrder']->reference)) {
         $reference = $params['objOrder']->reference;
     }
     $total_to_pay = Tools::displayPrice($params['total_to_pay'], $params['currencyObj'], false);
     $this->context->smarty->assign(array('MYMOD_CH_ORDER' => Configuration::get('MYMOD_CH_ORDER'), 'MYMOD_CH_ADDRESS' => Configuration::get('MYMOD_CH_ADDRESS'), 'MYMOD_BA_OWNER' => Configuration::get('MYMOD_BA_OWNER'), 'MYMOD_BA_DETAILS' => Configuration::get('MYMOD_BA_DETAILS'), 'reference' => $reference, 'total_to_pay' => $total_to_pay));
     return $this->module->display($this->file, 'displayPaymentReturn.tpl');
 }
Example #21
0
 public function initContent()
 {
     if (!$this->context->customer->isLogged() || empty($this->context->cart)) {
         Tools::redirect('index.php');
     }
     parent::initContent();
     $this->paypal = new PayPal();
     $this->context = Context::getContext();
     $this->id_module = (int) Tools::getValue('id_module');
     $currency = new Currency((int) $this->context->cart->id_currency);
     $this->context->smarty->assign(array('form_action' => PayPal::getShopDomainSsl(true, true) . _MODULE_DIR_ . $this->paypal->name . '/express_checkout/payment.php', 'total' => Tools::displayPrice($this->context->cart->getOrderTotal(true), $currency), 'logos' => $this->paypal->paypal_logos->getLogos(), 'use_mobile' => (bool) $this->paypal->useMobile()));
     $this->setTemplate('order-summary.tpl');
 }
Example #22
0
    public function hookAdminStatsModules($params)
    {
        global $cookie;
        $totals = $this->getTotals();
        $currency = new Currency((int) Configuration::get('PS_CURRENCY_DEFAULT'));
        if (($id_export = (int) Tools::getValue('export')) == 1) {
            $this->csvExport(array('layers' => 2, 'type' => 'line', 'option' => '1-' . (int) Tools::getValue('id_country')));
        } elseif ($id_export == 2) {
            $this->csvExport(array('layers' => 0, 'type' => 'line', 'option' => '2-' . (int) Tools::getValue('id_country')));
        } elseif ($id_export == 3) {
            $this->csvExport(array('type' => 'pie', 'option' => '3-' . (int) Tools::getValue('id_country')));
        }
        $this->_html = '
		<fieldset class="width3"><legend><img src="../modules/' . $this->name . '/logo.gif" /> ' . $this->displayName . '</legend>
			<form action="' . $_SERVER['REQUEST_URI'] . '" method="post" style="float: right; margin-left: 10px;">
				<select name="id_country">
					<option value="0"' . (!Tools::getValue('id_order_state') ? ' selected="selected"' : '') . '>' . $this->l('All') . '</option>';
        foreach (Country::getCountries($cookie->id_lang) as $country) {
            $this->_html .= '<option value="' . $country['id_country'] . '"' . ($country['id_country'] == Tools::getValue('id_country') ? ' selected="selected"' : '') . '>' . $country['name'] . '</option>';
        }
        $this->_html .= '</select>
				<input type="submit" name="submitCountry" value="' . $this->l('Filter') . '" class="button" />
			</form>
			<p><center><img src="../img/admin/down.gif" />
				' . $this->l('These graphs represent the evolution of your orders and sales turnover for a given period. This tool allows for quick overview of the viability of your shop. You can also keep watch on the difference between time periods (like the holiday season). Only valid orders are included in these two graphs.') . '
			</center></p>
			<p>' . $this->l('Orders placed:') . ' ' . (int) $totals['orderCount'] . '</p>
			<p>' . $this->l('Products bought:') . ' ' . (int) $totals['products'] . '</p>
			<center>' . ModuleGraph::engine(array('type' => 'line', 'option' => '1-' . (int) Tools::getValue('id_country'), 'layers' => 2)) . '</center>
			<p><a href="' . $_SERVER['REQUEST_URI'] . '&export=1"><img src="../img/admin/asterisk.gif" alt="" />' . $this->l('CSV Export') . '</a></p>
			<p>' . $this->l('Sales:') . ' ' . Tools::displayPrice($totals['orderSum'], $currency) . '</p>
			<center>' . ModuleGraph::engine(array('type' => 'line', 'option' => '2-' . (int) Tools::getValue('id_country'))) . '</center></p>
			<p><a href="' . $_SERVER['REQUEST_URI'] . '&export=2"><img src="../img/admin/asterisk.gif" alt="" />' . $this->l('CSV Export') . '</a></p>
			<p class="space"><img src="../img/admin/down.gif" />
				' . $this->l('You can see the order state distribution below.') . '
			</p><br />
			' . ($totals['orderCount'] ? ModuleGraph::engine(array('type' => 'pie', 'option' => '3-' . (int) Tools::getValue('id_country'))) : $this->l('No orders for this period.')) . '</center>
			<p><a href="' . $_SERVER['REQUEST_URI'] . '&export=3"><img src="../img/admin/asterisk.gif" />' . $this->l('CSV Export') . '</a></p>
		</fieldset>
		<br class="clear" />
		<fieldset class="width3"><legend><img src="../img/admin/comment.gif" /> ' . $this->l('Guide') . '</legend>
			<h2>' . $this->l('Various order statuses') . '</h2>
			<p>
				' . $this->l('In your back-office, you can find the following order statuses : Awaiting check payment, Payment accepted, Preparation in progress, Shipping, Delivered, Cancelled, Refund, Payment error, Out of stock, and Awaiting bank wire payment.') . '<br />
				' . $this->l('Statuses cannot be removed from the back-office, but you have the option to add more.') . '
			</p>
		</fieldset>';
        return $this->_html;
    }
 protected function getBestSellers($params)
 {
     if (Configuration::get('PS_CATALOG_MODE')) {
         return false;
     }
     if (!($result = ProductSale::getBestSalesLight((int) $params['cookie']->id_lang, 0, 3))) {
         return Configuration::get('PS_BLOCK_BESTSELLERS_DISPLAY') ? array() : false;
     }
     $currency = new Currency($params['cookie']->id_currency);
     $usetax = Product::getTaxCalculationMethod((int) $this->context->customer->id) != PS_TAX_EXC;
     foreach ($result as &$row) {
         $row['price'] = Tools::displayPrice(Product::getPriceStatic((int) $row['id_product'], $usetax), $currency);
     }
     return $result;
 }
Example #24
0
 private function displayOrdersTable()
 {
     $order_state = new OrderState((int) Configuration::get('MONDIAL_RELAY_ORDER_STATE'), $this->context->language->id);
     $orders = MondialRelay::getOrders(array(), MondialRelay::NO_FILTER, $this->mondialrelay->account_shop['MR_WEIGHT_COEFFICIENT']);
     // Simulate a ticket generation
     $MRCreateTicket = new MRCreateTickets(array('orderIdList' => NULL, 'totalOrder' => NULL, 'weightList' => NULL));
     foreach ($orders as &$order) {
         $order['display_total_price'] = Tools::displayPrice($order['total'], new Currency($order['id_currency']));
         $order['display_shipping_price'] = Tools::displayPrice($order['shipping'], new Currency($order['id_currency']));
         $order['display_date'] = Tools::displayDate($order['date'], $order['id_lang']);
     }
     $this->context->smarty->assign(array('MR_token_admin_module' => Tools::getAdminToken('AdminModules' . (int) Tab::getIdFromClassName('AdminModules') . (int) $this->context->employee->id), 'MR_token_admin_contact' => Tools::getAdminToken('AdminContact' . (int) Tab::getIdFromClassName('AdminContact') . (int) $this->context->employee->id), 'MR_token_admin_orders' => Tools::getAdminToken('AdminOrders' . (int) Tab::getIdFromClassName('AdminOrders') . (int) $this->context->employee->id), 'MR_order_state_name' => $order_state->name, 'MR_orders' => $orders, 'MR_PS_IMG_DIR_' => _PS_IMG_DIR_, 'MR_errors_type' => $MRCreateTicket->checkPreValidation()));
     unset($order_state);
     echo $this->context->smarty->fetch(dirname(__FILE__) . '/tpl/admintab/generate_tickets.tpl');
 }
Example #25
0
 /**
  * Initialize order controller
  * @see FrontController::init()
  */
 public function init()
 {
     global $orderTotal;
     parent::init();
     $this->step = (int) Tools::getValue('step');
     if (!$this->nbProducts) {
         $this->step = -1;
     }
     // If some products have disappear
     if (!$this->context->cart->checkQuantities()) {
         $this->step = 0;
         $this->errors[] = Tools::displayError('An item in your cart is no longer available in this quantity. You cannot proceed with your order until the quantity is adjusted.');
     }
     // Check minimal amount
     $currency = Currency::getCurrency((int) $this->context->cart->id_currency);
     //Gelikon Стоимость товаров без доставки BEGIN
     $cart_products = $this->context->cart->getProducts();
     $products_total_wt = 0;
     if ($cart_products) {
         foreach ($cart_products as $cart_product) {
             $products_total_wt += $cart_product["total_wt"];
         }
     }
     $this->context->smarty->assign('products_total_wt', $products_total_wt);
     //Gelikon Стоимость товаров без доставки END
     $orderTotal = $this->context->cart->getOrderTotal();
     $this->context->smarty->assign('global_order_total', $orderTotal);
     $minimal_purchase = Tools::convertPrice((double) Configuration::get('PS_PURCHASE_MINIMUM'), $currency);
     if ($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS) < $minimal_purchase && $this->step > 0) {
         $this->step = 0;
         $this->errors[] = sprintf(Tools::displayError('A minimum purchase total of %1s (tax excl.) is required in order to validate your order, current purchase total is %2s (tax excl.).'), Tools::displayPrice($minimal_purchase, $currency), Tools::displayPrice($this->context->cart->getOrderTotal(false, Cart::ONLY_PRODUCTS), $currency));
     }
     if (!$this->context->customer->isLogged(true) && in_array($this->step, array(1, 2, 3))) {
         $back_url = $this->context->link->getPageLink('order', true, (int) $this->context->language->id, array('step' => $this->step, 'multi-shipping' => (int) Tools::getValue('multi-shipping')));
         $params = array('multi-shipping' => (int) Tools::getValue('multi-shipping'), 'display_guest_checkout' => (int) Configuration::get('PS_GUEST_CHECKOUT_ENABLED'), 'back' => $back_url);
         Tools::redirect($this->context->link->getPageLink('authentication', true, (int) $this->context->language->id, $params));
     }
     if (Tools::getValue('multi-shipping') == 1) {
         $this->context->smarty->assign('multi_shipping', true);
     } else {
         $this->context->smarty->assign('multi_shipping', false);
     }
     if ($this->context->customer->id) {
         $this->context->smarty->assign('address_list', $this->context->customer->getAddresses($this->context->language->id));
     } else {
         $this->context->smarty->assign('address_list', array());
     }
 }
Example #26
0
    public function hookAdminStatsModules($params)
    {
        $totals = $this->getTotals();
        $currency = new Currency((int) Configuration::get('PS_CURRENCY_DEFAULT'));
        if (($id_export = (int) Tools::getValue('export')) == 1) {
            $this->csvExport(array('layers' => 2, 'type' => 'line', 'option' => '1-' . (int) Tools::getValue('id_country')));
        } elseif ($id_export == 2) {
            $this->csvExport(array('layers' => 0, 'type' => 'line', 'option' => '2-' . (int) Tools::getValue('id_country')));
        } elseif ($id_export == 3) {
            $this->csvExport(array('type' => 'pie', 'option' => '3-' . (int) Tools::getValue('id_country')));
        }
        $this->_html = '
		<div class="blocStats"><h2 class="icon-' . $this->name . '"><span></span>' . $this->displayName . '</h2>
			<form action="' . Tools::safeOutput($_SERVER['REQUEST_URI']) . '" method="post" style="float: right; margin-left: 10px;">
				<select name="id_country">
					<option value="0"' . (!Tools::getValue('id_order_state') ? ' selected="selected"' : '') . '>' . $this->l('All') . '</option>';
        foreach (Country::getCountries($this->context->language->id) as $country) {
            $this->_html .= '<option value="' . $country['id_country'] . '"' . ($country['id_country'] == Tools::getValue('id_country') ? ' selected="selected"' : '') . '>' . $country['name'] . '</option>';
        }
        $this->_html .= '</select>
				<input type="submit" name="submitCountry" value="' . $this->l('Filter') . '" class="button" />
			</form>
			<p><img src="../img/admin/down.gif" />
				' . $this->l('The following graphs represent the evolution of your e-store\'s orders and sales turnover for a selected period. This tool is one that you should use often as it allows you to quickly monitor your store\'s viability. This feature also allows you to monitor multiple time periods, and only valid orders are graphically represented.') . '
			</p>
			<p>' . $this->l('Orders placed:') . ' <span class="totalStats">' . (int) $totals['orderCount'] . '</span></p>
			<p>' . $this->l('Products bought:') . ' <span class="totalStats">' . (int) $totals['products'] . '</span></p>
			<div>' . $this->engine(array('type' => 'line', 'option' => '1-' . (int) Tools::getValue('id_country'), 'layers' => 2)) . '</div>
			<p><a class="button export-csv" href="' . Tools::safeOutput($_SERVER['REQUEST_URI']) . '&export=1"><span>' . $this->l('CSV Export') . '</span></a></p>
			<h4>' . $this->l('Sales:') . ' ' . Tools::displayPrice($totals['orderSum'], $currency) . '</h4>
			<div>' . $this->engine(array('type' => 'line', 'option' => '2-' . (int) Tools::getValue('id_country'))) . '</div>
			<p><a class="button export-csv" href="' . Tools::safeOutput($_SERVER['REQUEST_URI']) . '&export=2"><span>' . $this->l('CSV Export') . '</span></a></p>
			<p class="space"><img src="../img/admin/down.gif" />
				' . $this->l('You can view order distribution below.') . '
			</p><br />
			' . ($totals['orderCount'] ? $this->engine(array('type' => 'pie', 'option' => '3-' . (int) Tools::getValue('id_country'))) : $this->l('No orders for this period.')) . '</center>
			<p><a class="button export-csv" href="' . Tools::safeOutput($_SERVER['REQUEST_URI']) . '&export=3"><span>' . $this->l('CSV Export') . '</span></a></p>
		</div >
		<br />
		<div class="blocStats"><h2 class="icon-guide"><span></span>' . $this->l('Guide') . '</h2>
			<h2>' . $this->l('Various order statuses') . '</h2>
			<p>
				' . $this->l('In your Back Office, you can modify the following order statuses: Awaiting Check Payment, Payment Accepted, Preparation in Progress, Shipping, Delivered, Cancelled, Refund, Payment Error, Out of Stock, and Awaiting Bank Wire Payment.') . '<br />
				' . $this->l('These order statuses cannot be removed from the Back Office, however you have the option to add more.') . '
			</p>
		</div >';
        return $this->_html;
    }
Example #27
0
 public function initContent()
 {
     parent::initContent();
     $this->paypal = new PayPal();
     $this->context = Context::getContext();
     $this->id_module = (int) Tools::getValue('id_module');
     $this->id_order = (int) Tools::getValue('id_order');
     $order = PayPalOrder::getOrderById($this->id_order);
     $this->context->smarty->assign(array('is_guest' => $this->context->customer->is_guest, 'order' => $order, 'price' => Tools::displayPrice($order['total_paid'], $this->context->currency), 'HOOK_ORDER_CONFIRMATION' => $this->displayOrderConfirmation(), 'HOOK_PAYMENT_RETURN' => $this->displayPaymentReturn()));
     if ($this->context->customer->is_guest) {
         $this->context->smarty->assign(array('id_order' => (int) $this->order->id_order, 'id_order_formatted' => sprintf('#%06d', (int) $this->order->id_order)));
         /* If guest we clear the cookie for security reason */
         $this->context->customer->mylogout();
     }
     $this->setTemplate('order-confirmation.tpl');
 }
 public function printOutstandingCalculation($id_invoice, $tr)
 {
     $order_invoice = new OrderInvoice($id_invoice);
     if (!Validate::isLoadedObject($order_invoice)) {
         throw new PrestaShopException('object OrderInvoice cannot be loaded');
     }
     $order = new Order($order_invoice->id_order);
     if (!Validate::isLoadedObject($order)) {
         throw new PrestaShopException('object Order cannot be loaded');
     }
     $customer = new Customer((int) $order->id_customer);
     if (!Validate::isLoadedObject($order_invoice)) {
         throw new PrestaShopException('object Customer cannot be loaded');
     }
     return '<b>' . Tools::displayPrice($customer->getOutstanding(), Context::getContext()->currency) . '</b>';
 }
Example #29
-1
 public function displayContent()
 {
     $id_product = (int) Tools::getValue('id_product');
     if (!empty($id_product)) {
         $this->nbShops = AphStore::getStoresByProduct($id_product, Context::getContext()->language->id, null, null, $this->orderBy, $this->orderWay, true);
         $this->pagination((int) $this->nbShops);
         // Pagination must be call after "getStoresByProduct"
         $this->shopSort();
         $shops = AphStore::getStoresByProduct($id_product, Context::getContext()->language->id, $this->p, $this->n, $this->orderBy, $this->orderWay);
         $id_currency = Validate::isLoadedObject(Context::getContext()->currency) ? (int) Context::getContext()->currency->id : (int) Configuration::get('PS_CURRENCY_DEFAULT');
         if (!empty($shops)) {
             foreach ($shops as &$shop) {
                 $product = new Product($id_product, (int) Context::getContext()->language->id, (int) $shop['id_shop']);
                 $shop['price_from'] = Tools::displayPrice($product->price, $id_currency);
                 //$url = !empty($ssl) ? 'https://'.$shop['domain_ssl'] : 'http://'.$shop['domain'];
                 //$shop['url'] = $url.$shop['uri'];
                 $shop['url'] = Context::getContext()->link->getModuleLink('blockshops', 'shop', array('ash' => $shop['virtual_uri'], 'ids' => $shop['id_shop']));
                 $shop['img_link_rewrite'] = Tools::link_rewrite($shop['legend']);
             }
         }
     }
     $this->context->smarty->assign(array('shops' => $shops, 'nb_shops' => $this->nbShops));
     $this->context->controller->addJS('blockshops.js');
     //return $this->display(__FILE__, 'blockshops.tpl', $this->getCacheId());
 }
Example #30
-1
 /**
  * override method: get list image from articles.
  */
 function getListByParameters($params, $ids)
 {
     if (_PS_VERSION_ <= "1.4") {
         $products = self::_getListv13($params, $ids);
     } elseif (_PS_VERSION_ < "1.5") {
         $products = self::_getListv14($params, $ids);
     } else {
         $products = self::_getListv15($params, $ids);
     }
     $isThumb = $params->get('auto_renderthumb', 1);
     $maxDesc = $params->get('des_limit', 100);
     if (empty($products)) {
         return array();
     }
     foreach ($products as &$product) {
         $product['description'] = substr(trim(strip_tags($product['description_short'])), 0, $maxDesc);
         $product['price'] = Tools::displayPrice($product['price']);
         if ($product['link']) {
             $product['link'] = $this->addhttp($product['link']);
             $product['description'] = $product['description'] . "<a href='" . $product['name'] . "' title='" . $product['name'] . "' >" . $params->get('readmore_txt', '[More...]') . "</a>";
         }
         $product = $this->parseImages($product, $params);
         $product = $this->generateImages($product, $params);
     }
     return $products;
 }