public function postProcess()
 {
     // Check if cart is valid
     $cart = new Cart((int) Tools::getValue('id_cart'));
     if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) {
         $this->returnError('Invalid cart');
     }
     // Check if customer exists
     $customer = new Customer($cart->id_customer);
     if (!Validate::isLoadedObject($customer)) {
         $this->returnError('Invalid customer');
     }
     $currency = new Currency((int) $cart->id_currency);
     $total_paid = Tools::getValue('total_paid');
     $extra_vars = array('transaction_id' => Tools::getValue('transaction_id'));
     // Build the validation token
     $validation_token = md5(Configuration::get('MYMOD_API_CRED_SALT') . Tools::getValue('id_cart') . $total_paid . Tools::getValue('transaction_id'));
     // Check validation token
     if (Tools::getValue('validation_token') != $validation_token) {
         $this->returnError('Invalid token');
     }
     // Validate order
     $this->module->validateOrder($cart->id, Configuration::get('PS_OS_PAYMENT'), $total_paid, $this->module->displayName . ' API', NULL, $extra_vars, (int) $currency->id, false, $customer->secure_key);
     // Redirect on order confirmation page
     $shop = new Shop(Configuration::get('PS_SHOP_DEFAULT'));
     $return_url = Tools::getShopProtocol() . $shop->domain . $shop->getBaseURI();
     $this->returnSuccess($return_url . '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 run($params)
 {
     $api_url = Configuration::get('MYMOD_API_URL');
     $api_credentials_id = Configuration::get('MYMOD_API_CRED_ID');
     $api_credentials_salt = Configuration::get('MYMOD_API_CRED_SALT');
     $total_to_pay = (double) $this->context->cart->getOrderTotal(true, Cart::BOTH);
     $id_cart = $this->context->cart->id;
     $payment_token = md5($api_credentials_salt . $id_cart . $total_to_pay);
     $validation_url = $this->context->link->getModuleLink('mymodpayment', 'validationapi');
     $shop = new Shop(Configuration::get('PS_SHOP_DEFAULT'));
     $return_url = Tools::getShopProtocol() . $shop->domain . $shop->getBaseURI();
     $cancel_url = Tools::getShopProtocol() . $shop->domain . $shop->getBaseURI();
     $this->context->smarty->assign('api_url', $api_url);
     $this->context->smarty->assign('api_credentials_id', $api_credentials_id);
     $this->context->smarty->assign('total_to_pay', $total_to_pay);
     $this->context->smarty->assign('id_cart', $id_cart);
     $this->context->smarty->assign('payment_token', $payment_token);
     $this->context->smarty->assign('validation_url', $validation_url);
     $this->context->smarty->assign('return_url', $return_url);
     $this->context->smarty->assign('cancel_url', $cancel_url);
     $this->context->controller->addCSS($this->_path . 'views/css/mymodpayment.css', 'all');
     return $this->module->display($this->file, 'displayPayment.tpl');
 }
Example #3
0
    public function hookDisplayBackOfficeHeader()
    {
        //check if currently updatingcheck if module is currently processing update
        if ($this->isUpdating() || !Module::isEnabled($this->name)) {
            return false;
        }
        if (method_exists($this->context->controller, 'addJquery')) {
            $this->context->controller->addJquery();
            $this->context->controller->addCss($this->_path . 'views/css/gamification.css');
            //add css for advices
            $advices = Advice::getValidatedByIdTab($this->context->controller->id, true);
            $css_str = $js_str = '';
            foreach ($advices as $advice) {
                $css_str .= '<link href="' . Tools::getShopProtocol() . 'gamification.prestashop.com/css/advices/advice-' . _PS_VERSION_ . '_' . (int) $advice['id_ps_advice'] . '.css" rel="stylesheet" type="text/css" media="all" />';
                $js_str .= '"' . (int) $advice['id_ps_advice'] . '",';
            }
            if (version_compare(_PS_VERSION_, '1.6.0', '>=') === TRUE) {
                $this->context->controller->addJs($this->_path . 'views/js/gamification_bt.js');
            } else {
                $this->context->controller->addJs($this->_path . 'views/js/gamification.js');
            }
            $this->context->controller->addJqueryPlugin('fancybox');
            return $css_str . '<script>
				var ids_ps_advice = new Array(' . rtrim($js_str, ',') . ');
				var admin_gamification_ajax_url = \'' . $this->context->link->getAdminLink('AdminGamification') . '\';
				var current_id_tab = ' . (int) $this->context->controller->id . ';
			</script>';
        }
    }
 protected function generateCategoryData()
 {
     $delimiter = ';';
     $line = array();
     $titles = array();
     $id_lang = $this->use_lang;
     $new_path = new Sampledatainstall();
     $f = fopen($new_path->sendPath() . 'output/categories.vsc', 'w');
     foreach ($this->category_fields as $field => $array) {
         $titles[] = $array['label'];
     }
     fputcsv($f, $titles, $delimiter, '"');
     $categories = Category::getCategories($id_lang, true);
     foreach ($categories as $category) {
         foreach ($category as $c) {
             $line = array();
             $categor_id = $c['infos']['id_category'];
             // check if category is not ROOT and not HOME
             if ($categor_id != Configuration::get('PS_HOME_CATEGORY') && $categor_id != Configuration::get('PS_ROOT_CATEGORY')) {
                 $cat = new Category($c['infos']['id_category'], $id_lang);
                 foreach ($this->category_fields as $field => $array) {
                     $line[$field] = property_exists('Category', $field) && !is_array($cat->{$field}) && !Tools::isEmpty($cat->{$field}) ? $cat->{$field} : '';
                 }
                 $link = new Link();
                 $imagelink = '';
                 if ($cat->id_image) {
                     $imagelink = Tools::getShopProtocol() . $link->getCatImageLink($cat->link_rewrite, $cat->id_image);
                     $this->copyConverFileName($imagelink);
                 }
                 for ($i = 0; $i < 3; $i++) {
                     if (file_exists(_PS_CAT_IMG_DIR_ . (int) $cat->id . '-' . $i . '_thumb.jpg')) {
                         $this->copyConverFileName(_PS_CAT_IMG_DIR_ . (int) $cat->id . '-' . $i . '_thumb.jpg');
                     }
                 }
                 $line['image_url'] = $imagelink ? $imagelink : '';
                 if (!$line[$field]) {
                     $line[$field] = '';
                 }
                 fputcsv($f, $line, $delimiter, '"');
             }
         }
     }
     fclose($f);
 }
Example #5
0
					GROUP BY pa.`id_product_attribute`, ag.`id_attribute_group`
					ORDER BY pa.`id_product_attribute`';
            $combinations = Db::getInstance()->executeS($sql);
            if (!empty($combinations)) {
                foreach ($combinations as $k => $combination) {
                    $results[$combination['id_product_attribute']]['id'] = $item['id_product'];
                    $results[$combination['id_product_attribute']]['id_product_attribute'] = $combination['id_product_attribute'];
                    !empty($results[$combination['id_product_attribute']]['name']) ? $results[$combination['id_product_attribute']]['name'] .= ' ' . $combination['group_name'] . '-' . $combination['attribute_name'] : ($results[$combination['id_product_attribute']]['name'] = $item['name'] . ' ' . $combination['group_name'] . '-' . $combination['attribute_name']);
                    if (!empty($combination['reference'])) {
                        $results[$combination['id_product_attribute']]['ref'] = $combination['reference'];
                    } else {
                        $results[$combination['id_product_attribute']]['ref'] = !empty($item['reference']) ? $item['reference'] : '';
                    }
                    if (empty($results[$combination['id_product_attribute']]['image'])) {
                        $results[$combination['id_product_attribute']]['image'] = str_replace('http://', Tools::getShopProtocol(), $context->link->getImageLink($item['link_rewrite'], $combination['id_image'], 'home_default'));
                    }
                }
            } else {
                $product = array('id' => (int) $item['id_product'], 'name' => $item['name'], 'ref' => !empty($item['reference']) ? $item['reference'] : '', 'image' => str_replace('http://', Tools::getShopProtocol(), $context->link->getImageLink($item['link_rewrite'], $item['id_image'], 'home_default')));
                array_push($results, $product);
            }
        } else {
            $product = array('id' => (int) $item['id_product'], 'name' => $item['name'], 'ref' => !empty($item['reference']) ? $item['reference'] : '', 'image' => str_replace('http://', Tools::getShopProtocol(), $context->link->getImageLink($item['link_rewrite'], $item['id_image'], 'home_default')));
            array_push($results, $product);
        }
    }
    $results = array_values($results);
    echo Tools::jsonEncode($results);
} else {
    Tools::jsonEncode(new stdClass());
}
    public function sendCampaign()
    {
        // get abandoned cart :
        $sql = "SELECT * FROM (\n\t\tSELECT\n\t\tCONCAT(LEFT(c.`firstname`, 1), '. ', c.`lastname`) `customer`, a.id_cart total, ca.name carrier, c.id_customer, a.id_cart, a.date_upd,a.date_add,\n\t\t\t\tIF (IFNULL(o.id_order, 'Non ordered') = 'Non ordered', IF(TIME_TO_SEC(TIMEDIFF('" . date('Y-m-d H:i:s') . "', a.`date_add`)) > 86000, 'Abandoned cart', 'Non ordered'), o.id_order) id_order, IF(o.id_order, 1, 0) badge_success, IF(o.id_order, 0, 1) badge_danger, IF(co.id_guest, 1, 0) id_guest\n\t\tFROM `" . _DB_PREFIX_ . "cart` a  \n\t\t\t\tJOIN `" . _DB_PREFIX_ . "customer` c ON (c.id_customer = a.id_customer)\n\t\t\t\tLEFT JOIN `" . _DB_PREFIX_ . "currency` cu ON (cu.id_currency = a.id_currency)\n\t\t\t\tLEFT JOIN `" . _DB_PREFIX_ . "carrier` ca ON (ca.id_carrier = a.id_carrier)\n\t\t\t\tLEFT JOIN `" . _DB_PREFIX_ . "orders` o ON (o.id_cart = a.id_cart)\n\t\t\t\tLEFT JOIN `" . _DB_PREFIX_ . "connections` co ON (a.id_guest = co.id_guest AND TIME_TO_SEC(TIMEDIFF('" . date('Y-m-d H:i:s') . "', co.`date_add`)) < 1800)\n\t\t\t\tWHERE a.date_add > (NOW() - INTERVAL 60 DAY) ORDER BY a.id_cart DESC \n\t\t) AS toto WHERE id_order='Abandoned cart'";
        $currency = Context::getContext()->currency->sign;
        $defaultLanguage = new Language((int) Configuration::get('PS_LANG_DEFAULT'));
        $abandoned_carts = Db::getInstance()->ExecuteS($sql);
        // get all available campaigns
        $sqlCampaigns = 'SELECT * FROM `' . _DB_PREFIX_ . 'campaign` WHERE active=1';
        $allCampaigns = Db::getInstance()->ExecuteS($sqlCampaigns);
        if (!$allCampaigns || empty($allCampaigns)) {
            die('NO CAMPAIGN');
        }
        // loop on all abandoned carts
        foreach ($abandoned_carts as $abncart) {
            if (Cart::getNbProducts((int) $abncart['id_cart']) > 0) {
                $emailsSent = 0;
                // loop on all available campaigns
                foreach ($allCampaigns as $camp) {
                    if (DEBUG_SAC) {
                        echo 'IdCustomer : ' . $abncart['id_customer'] . ' - IdCart : ' . $abncart['id_cart'] . '<br/>';
                    }
                    $cartIsOnCampaign = $this->checkIfCartIsOnCampaign($abncart['date_add'], $camp['execution_time_day'], $camp['execution_time_hour']);
                    if ($cartIsOnCampaign) {
                        if (DEBUG_SAC) {
                            echo 'Cart on campaign</br>';
                        }
                        $id_lang = (int) Configuration::get('PS_LANG_DEFAULT');
                        $customer = new Customer($abncart['id_customer']);
                        $cart = new Cart($abncart['id_cart']);
                        $products = $cart->getProducts();
                        $tpl_vars = array('{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{campaign_name}' => $camp['name'], '{track_url}' => $this->getBaseURL() . '?id_cart=' . (int) $abncart['id_cart'] . '&id_customer=' . (int) $abncart['id_customer'], '{track_request}' => '?id_cart=' . (int) $abncart['id_cart'] . '&id_customer=' . (int) $abncart['id_customer']);
                        $campM = new Campaign($camp['id_campaign']);
                        if ($campM->voucher_amount && $campM->voucher_day && $campM->voucher_amount_type) {
                            $campM->clean_old_reduction($campM->voucher_prefix);
                            $customerVoucher = $campM->registerDiscount($customer->id, $campM->voucher_amount, $campM->voucher_day, $campM->voucher_amount_type, $campM->voucher_prefix);
                            $tpl_vars['{coupon_name}'] = $customerVoucher->name;
                            $tpl_vars['{coupon_code}'] = $customerVoucher->code;
                            $tpl_vars['{coupon_value}'] = $camp['voucher_amount_type'] == 'percent' ? $customerVoucher->reduction_percent . '%' : Tools::displayprice($customerVoucher->reduction_amount);
                            $tpl_vars['{coupon_valid_to}'] = date('d/m/Y', strtotime($customerVoucher->date_to));
                        }
                        if (!empty($products)) {
                            $cart_content = $campM->getCartContentHeader();
                        } else {
                            $cart_content = '';
                        }
                        foreach ($products as $prod) {
                            $p = new Product($prod['id_product'], true, $id_lang);
                            $price_no_tax = Product::getPriceStatic($p->id, false, null, 2, null, false, true, 1, false, null, $abncart['id_cart'], null, $null, true, true, null, false, false);
                            $total_no_tax = $prod['cart_quantity'] * $price_no_tax;
                            $images = Image::getImages((int) $id_lang, (int) $p->id);
                            $link = new Link();
                            $cart_content .= '<tr>
											<td align="center" ><img src="' . Tools::getShopProtocol() . $link->getImageLink($p->link_rewrite, $images[0]['id_image']) . '" width="80"/></td>
											<td align="center" ><a href="' . $link->getProductLink($p) . '?id_cart=' . (int) $abncart['id_cart'] . '&id_customer=' . (int) $abncart['id_customer'] . '"/>' . $p->name . '</a></td>
											<td align="center" >' . Tools::displayprice($price_no_tax) . '</td>
											<td align="center" >' . $prod['cart_quantity'] . '</td>
											<td align="center" >' . Tools::displayprice($total_no_tax) . '</td>
										</tr>';
                        }
                        $cart_content .= '</table>';
                        $tpl_vars['{cart_content}'] = $cart_content;
                        $path = _PS_ROOT_DIR_ . '/modules/superabandonedcart/mails/';
                        // send email to customer :
                        $mailUser = Mail::Send($id_lang, $campM->getFileName(), $camp['name'], $tpl_vars, $customer->email, null, null, null, null, null, $path, false, Context::getContext()->shop->id);
                        // if mail user is successfully sent :
                        if ($mailUser) {
                            $history = new CampaignHistory();
                            $history->id_campaign = (int) $camp['id_campaign'];
                            $history->id_customer = $abncart['id_customer'];
                            $history->id_cart = $abncart['id_cart'];
                            $history->id_cart_rule = isset($customerVoucher->id) ? $customerVoucher->id : 0;
                            $history->click = 0;
                            $history->converted = 0;
                            $history->date_update = date('Y-m-d H:i:s', time());
                            $history->save();
                            // Email to admin :
                            Mail::Send($id_lang, $campM->getFileName(), Mail::l(sprintf('Email sent to %s %s for campaign %s', $customer->lastname, $customer->firstname, $camp['name'])), $tpl_vars, Configuration::get('PS_SHOP_EMAIL'), null, null, null, null, null, $path, false, Context::getContext()->shop->id);
                            ++$emailsSent;
                        } else {
                            PrestaShopLogger::addLog('Error when sending user email (tpl:' . $campM->getFileName() . ',customer:' . $customer->email . ', campagne : ' . $camp['name'], 3);
                        }
                    }
                }
                // log emailing results :
                if ($emailsSent > 0) {
                    PrestaShopLogger::addLog($emailsSent . ' emails sent for ' . $camp['name'] . ' campaign', 1);
                }
            }
        }
    }
Example #7
0
    /**
     * Find the shop from current domain / uri and get an instance of this shop
     * if INSTALL_VERSION is defined, will return an empty shop object
     *
     * @return Shop
     */
    public static function initialize()
    {
        if (!($id_shop = Tools::getValue('id_shop')) || defined('_PS_ADMIN_DIR_')) {
            $found_uri = '';
            $is_main_uri = false;
            $host = Tools::getHttpHost();
            $request_uri = rawurldecode($_SERVER['REQUEST_URI']);
            $sql = 'SELECT s.id_shop, CONCAT(su.physical_uri, su.virtual_uri) AS uri, su.domain, su.main
					FROM ' . _DB_PREFIX_ . 'shop_url su
					LEFT JOIN ' . _DB_PREFIX_ . 'shop s ON (s.id_shop = su.id_shop)
					WHERE (su.domain = \'' . pSQL($host) . '\' OR su.domain_ssl = \'' . pSQL($host) . '\')
						AND s.active = 1
						AND s.deleted = 0
					ORDER BY LENGTH(CONCAT(su.physical_uri, su.virtual_uri)) DESC';
            $result = Db::getInstance()->executeS($sql);
            $through = false;
            foreach ($result as $row) {
                if (preg_match('#^' . preg_quote($row['uri'], '#') . '#i', $request_uri)) {
                    $through = true;
                    $id_shop = $row['id_shop'];
                    $found_uri = $row['uri'];
                    if ($row['main']) {
                        $is_main_uri = true;
                    }
                    break;
                }
            }
            if ($through && $id_shop && !$is_main_uri) {
                foreach ($result as $row) {
                    if ($row['id_shop'] == $id_shop && $row['main']) {
                        $request_uri = substr($request_uri, strlen($found_uri));
                        $url = str_replace('/' . '/', '/', $row['domain'] . $row['uri'] . $request_uri);
                        $redirect_type = Configuration::get('PS_CANONICAL_REDIRECT') == 2 ? '301' : '302';
                        header('HTTP/1.0 ' . $redirect_type . ' Moved');
                        header('Cache-Control: no-cache');
                        header('location: ' . Tools::getShopProtocol() . $url);
                        exit;
                    }
                }
            }
        }
        $http_host = Tools::getHttpHost();
        $all_media = array();
        if (!$id_shop && defined('_PS_ADMIN_DIR_') || Tools::isPHPCLI() || in_array($http_host, $all_media)) {
            if (!$id_shop && Tools::isPHPCLI() || defined('_PS_ADMIN_DIR_')) {
                $id_shop = (int) Configuration::get('PS_SHOP_DEFAULT');
            }
            $shop = new Shop((int) $id_shop);
            if (!Validate::isLoadedObject($shop)) {
                $shop = new Shop((int) Configuration::get('PS_SHOP_DEFAULT'));
            }
            $shop->virtual_uri = '';
            if (Tools::isPHPCLI()) {
                if (!isset($_SERVER['HTTP_HOST']) || empty($_SERVER['HTTP_HOST'])) {
                    $_SERVER['HTTP_HOST'] = $shop->domain;
                }
                if (!isset($_SERVER['SERVER_NAME']) || empty($_SERVER['SERVER_NAME'])) {
                    $_SERVER['SERVER_NAME'] = $shop->domain;
                }
                if (!isset($_SERVER['REMOTE_ADDR']) || empty($_SERVER['REMOTE_ADDR'])) {
                    $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
                }
            }
        } else {
            $shop = new Shop($id_shop);
            if (!Validate::isLoadedObject($shop) || !$shop->active) {
                $default_shop = new Shop(Configuration::get('PS_SHOP_DEFAULT'));
                if (!Validate::isLoadedObject($default_shop)) {
                    throw new PrestaShopException('Shop not found');
                }
                $params = $_GET;
                unset($params['id_shop']);
                $url = $default_shop->domain;
                if (!Configuration::get('PS_REWRITING_SETTINGS')) {
                    $url .= $default_shop->getBaseURI() . 'index.php?' . http_build_query($params);
                } else {
                    if (strpos($url, 'www.') === 0 && 'www.' . $_SERVER['HTTP_HOST'] === $url || $_SERVER['HTTP_HOST'] === 'www.' . $url) {
                        $url .= $_SERVER['REQUEST_URI'];
                    } else {
                        $url .= $default_shop->getBaseURI();
                    }
                    if (count($params)) {
                        $url .= '?' . http_build_query($params);
                    }
                }
                $redirect_type = Configuration::get('PS_CANONICAL_REDIRECT') == 2 ? '301' : '302';
                header('HTTP/1.0 ' . $redirect_type . ' Moved');
                header('location: ' . Tools::getShopProtocol() . $url);
                exit;
            } elseif (defined('_PS_ADMIN_DIR_') && empty($shop->physical_uri)) {
                $shop_default = new Shop((int) Configuration::get('PS_SHOP_DEFAULT'));
                $shop->physical_uri = $shop_default->physical_uri;
                $shop->virtual_uri = $shop_default->virtual_uri;
            }
        }
        self::$context_id_shop = $shop->id;
        self::$context_id_shop_group = $shop->id_shop_group;
        self::$context = self::CONTEXT_SHOP;
        return $shop;
    }
Example #8
0
    private function getScriptCustomerPagesViews($params)
    {
        // Record the guest path then increment the visit counter of the page
        $token_array = Connection::setPageConnection($params['cookie']);
        ConnectionsSource::logHttpReferer();
        if (Configuration::get('PS_STATSDATA_PAGESVIEWS')) {
            Page::setPageViewed($token_array['id_page']);
        }
        if (Configuration::get('PS_STATSDATA_CUSTOMER_PAGESVIEWS')) {
            // Ajax request sending the time spend on the page
            $token = sha1($token_array['id_connections'] . $token_array['id_page'] . $token_array['time_start'] . _COOKIE_KEY_);
            return '<script type="text/javascript">
				var time_start;
				$(window).load(
					function() {
						time_start = new Date();
					}
				);
				$(window).unload(
					function() {
						var time_end = new Date();
						var pagetime = new Object;
						pagetime.type = "pagetime";
						pagetime.id_connections = "' . (int) $token_array['id_connections'] . '";
						pagetime.id_page = "' . (int) $token_array['id_page'] . '";
						pagetime.time_start = "' . $token_array['time_start'] . '";
						pagetime.token = "' . $token . '";
						pagetime.time = time_end-time_start;
						$.post("' . Context::getContext()->link->getPageLink('statistics', (bool) (Tools::getShopProtocol() == 'https://')) . '", pagetime);
					}
				);
			</script>';
        }
        return '';
    }
 public function postProcess()
 {
     if (Tools::isSubmit('submitExport')) {
         $delimiter = Tools::getValue('export_delimiter');
         $id_lang = Tools::getValue('export_language');
         $id_shop = (int) $this->context->shop->id;
         set_time_limit(0);
         $fileName = 'products_' . date("Y_m_d_H_i_s") . '.csv';
         header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
         header('Content-Description: File Transfer');
         header("Content-type: text/csv");
         header("Content-Disposition: attachment; filename={$fileName}");
         header("Expires: 0");
         header("Pragma: public");
         $f = fopen('php://output', 'w');
         foreach ($this->available_fields as $field => $array) {
             $titles[] = $array['label'];
         }
         fputcsv($f, $titles, $delimiter, '"');
         $export_active = Tools::getValue('export_active') == 0 ? false : true;
         $export_category = Tools::getValue('export_category') == 99999 ? false : Tools::getValue('export_category');
         $products = Product::getProducts($id_lang, 0, 0, 'id_product', 'ASC', $export_category, $export_active);
         foreach ($products as $product) {
             $line = array();
             $p = new Product($product['id_product'], true, $id_lang, $id_shop);
             $p->loadStockData();
             foreach ($this->available_fields as $field => $array) {
                 if (isset($p->{$field}) && !is_array($p->{$field})) {
                     $line[$field] = $p->{$field} ? $p->{$field} : ' ';
                 } else {
                     switch ($field) {
                         case 'categories':
                             $cats = $p->getProductCategoriesFull($p->id, $id_lang);
                             $cat_array = array();
                             foreach ($cats as $cat) {
                                 $cat_array[] = $cat['name'];
                             }
                             $line['categories'] = implode(",", $cat_array);
                             break;
                         case 'price_tex':
                             $line['price_tex'] = $p->getPrice(false);
                             $line['price_tin'] = $p->getPrice(true);
                             break;
                         case 'upc':
                             $line['upc'] = $p->upc ? $p->upc : ' ';
                             break;
                         case 'features':
                             $line['features'] = '';
                             $features = $p->getFrontFeatures($id_lang);
                             $position = 1;
                             foreach ($features as $feature) {
                                 $line['features'] .= $feature['name'] . ':' . $feature['value'] . ':' . $position;
                                 $position++;
                             }
                             break;
                         case 'reduction_price':
                             $specificPrice = SpecificPrice::getSpecificPrice($p->id, $id_shop, 0, 0, 0, 0);
                             $line['reduction_price'] = '';
                             $line['reduction_percent'] = '';
                             $line['reduction_from'] = '';
                             $line['reduction_to'] = '';
                             if ($specificPrice['reduction_type'] == "amount") {
                                 $line['reduction_price'] = $specificPrice['reduction'];
                             } elseif ($specificPrice['reduction_type'] == "percent") {
                                 $line['reduction_percent'] = $specificPrice['reduction'];
                             }
                             if ($line['reduction_price'] !== '' || $line['reduction_percent'] !== '') {
                                 $line['reduction_from'] = date_format(date_create($specificPrice['from']), "Y-m-d");
                                 $line['reduction_to'] = date_format(date_create($specificPrice['to']), "Y-m-d");
                             }
                             break;
                         case 'tags':
                             $tags = $p->getTags($id_lang);
                             $line['tags'] = $tags;
                             break;
                         case 'image':
                             $link = new Link();
                             $imagelinks = array();
                             $images = $p->getImages($id_lang);
                             foreach ($images as $image) {
                                 $imagelinks[] = Tools::getShopProtocol() . $link->getImageLink($p->link_rewrite, $p->id . '-' . $image['id_image']);
                             }
                             $line['image'] = implode(",", $imagelinks);
                             break;
                         case 'delete_existing_images':
                             $line['delete_existing_images'] = 0;
                             break;
                         case 'shop':
                             $line['shop'] = $id_shop;
                             break;
                         case 'warehouse':
                             $warehouses = Warehouse::getWarehousesByProductId($p->id);
                             $line['warehouse'] = '';
                             if (!empty($warehouses)) {
                                 $line['warehouse'] = implode(',', array_map("{$this->getWarehouses}", $warehouses));
                             }
                             break;
                         case 'date_added':
                             $date = new DateTime($p->date_add);
                             $line['date_add'] = $date->format("Y-m-d");
                             break;
                     }
                 }
             }
             if (!$line[$field]) {
                 $line[$field] = '';
             }
             fputcsv($f, $line, $delimiter, '"');
         }
         fclose($f);
         die;
     }
 }
Example #10
0
$supported_currencies = explode(';', Configuration::get('PAYPLUG_MODULE_CURRENCIES'));
if (!in_array($result_currency['iso_code'], $supported_currencies)) {
    return false;
}
/**
 *  Check amount
 */
$amount = $context->cart->getOrderTotal(true, Cart::BOTH) * 100;
if ($amount < Configuration::get('PAYPLUG_MODULE_MIN_AMOUNT') * 100 || $amount > Configuration::get('PAYPLUG_MODULE_MAX_AMOUNT') * 100) {
    return false;
}
/**
 *  Parameters for payment url
 */
$url_payment = Configuration::get('PAYPLUG_MODULE_URL');
if (Tools::getShopProtocol() == 'https://') {
    $baseurl = _PS_BASE_URL_SSL_;
} else {
    $baseurl = _PS_BASE_URL_;
}
$base_return_url = $baseurl . __PS_BASE_URI__ . 'modules/payplug/controllers/front/validation.php';
if (version_compare(_PS_VERSION_, '1.5', '<')) {
    $customer = new Customer($context->cookie->id_customer);
} else {
    $customer = $context->customer;
}
$params = array('amount' => $amount, 'custom_data' => $context->cart->id, 'origin' => 'Prestashop ' . _PS_VERSION_ . ' module ' . $payplug->version, 'currency' => $result_currency['iso_code'], 'ipn_url' => $baseurl . __PS_BASE_URI__ . 'modules/payplug/ipn.php', 'cancel_url' => $base_return_url . '?ps=2&cartid=' . $context->cart->id, 'return_url' => $base_return_url . '?ps=1&cartid=' . $context->cart->id, 'email' => $customer->email, 'firstname' => $customer->firstname, 'lastname' => $customer->lastname, 'order' => $context->cart->id, 'customer' => $customer->id);
$url_params = http_build_query($params);
$privatekey = Configuration::get('PAYPLUG_MODULE_KEY');
openssl_sign($url_params, $signature, $privatekey, $signature_alg = OPENSSL_ALGO_SHA1);
$url_param_base_encode = base64_encode($url_params);
function theme_load_manifest($version)
{
    $manifests_dir = theme_get_manifests_dir();
    if (file_exists("{$manifests_dir}/{$version}")) {
        $content = FilesHelper::readFile("{$manifests_dir}/{$version}");
        $protocol = Tools::getShopProtocol();
        if ($protocol === 'https://') {
            $content = str_replace('http://', 'https://', $content);
        }
        return $content;
    }
    return false;
}
    public function getBlockPartners()
    {
        // Init var
        $return = '';
        $protocol = Tools::getShopProtocol();
        $isoCountry = Context::getContext()->country->iso_code;
        $isoUser = Context::getContext()->language->iso_code;
        // Refresh preactivation xml file if needed
        if (is_writable('../config/xml/') && (!file_exists('../config/xml/preactivation.xml') || time() - filemtime('../config/xml/preactivation.xml') > 86400)) {
            $stream_context = @stream_context_create(array('http' => array('method' => 'GET', 'timeout' => AdminHomeController::TIPS_TIMEOUT)));
            $content = Tools::file_get_contents('http://api.prestashop.com/partner/premium/get_partners.php?protocol=' . $protocol . '&iso_country=' . Tools::strtoupper($isoCountry) . '&iso_lang=' . Tools::strtolower($isoUser) . '&ps_version=' . _PS_VERSION_ . '&ps_creation=' . _PS_CREATION_DATE_ . '&host=' . urlencode($_SERVER['HTTP_HOST']) . '&email=' . urlencode(Configuration::get('PS_SHOP_EMAIL')), false, $stream_context);
            @unlink('../config/xml/preactivation.xml');
            file_put_contents('../config/xml/preactivation.xml', $content);
        }
        $count = 0;
        libxml_use_internal_errors(true);
        // If preactivation xml file exists, we load it
        if (file_exists('../config/xml/preactivation.xml') && filesize('../config/xml/preactivation.xml') > 0 && ($preactivation = simplexml_load_file('../config/xml/preactivation.xml'))) {
            foreach ($preactivation->partner as $partner) {
                // Cache the logo
                if (!file_exists('../img/tmp/preactivation_' . htmlentities((string) $partner->module) . '.png')) {
                    @copy(htmlentities((string) $partner->logo), '../img/tmp/preactivation_' . htmlentities((string) $partner->module) . '.png');
                }
                // Check if module is not already installed and configured
                $display = 0;
                if (file_exists('../config/xml/default_country_modules_list.xml') && filesize('../config/xml/default_country_modules_list.xml') > 10) {
                    foreach ($partner->checkconfiguration->key as $key) {
                        if (Configuration::get(pSQL((string) $key)) == '') {
                            $display = 1;
                        }
                    }
                }
                // Display the module
                if ($display == 1 && $count < 2) {
                    $label_final = '';
                    foreach ($partner->labels->label as $label) {
                        if (empty($label_final) || (string) $label->attributes()->iso == $isoUser) {
                            $label_final = (string) $label;
                        }
                    }
                    $optional_final = '';
                    if (isset($partner->optionals)) {
                        foreach ($partner->optionals->optional as $optional) {
                            if (empty($optional_final) && (string) $optional->attributes()->iso == $isoUser) {
                                $optional_final = (string) $optional;
                            }
                        }
                    }
                    $link = 'index.php?controller=adminmodules&install=' . htmlentities((string) $partner->module) . '&token=' . Tools::getAdminTokenLite('AdminModules') . '&module_name=' . htmlentities((string) $partner->module) . '&redirect=config';
                    $return .= '<div style="width:46.5%;min-height:85px;border:1px solid #cccccc;background-color:white;padding-left:5px;padding-right:5px;' . (empty($return) ? 'float:left' : 'float:right') . '">
						<p align="center">
							<a href="' . $link . '" class="preactivationLink" rel="' . htmlentities((string) $partner->module) . '"><img src="../img/tmp/preactivation_' . htmlentities((string) $partner->module) . '.png" alt="' . htmlentities((string) $partner->name) . '" border="0" /></a><br />
							<b><a href="' . $link . '" class="preactivationLink" rel="' . htmlentities((string) $partner->module) . '">' . htmlentities(utf8_decode((string) $label_final)) . '</a></b>
							' . ($optional_final != '' ? '<a href="' . $link . '" class="preactivationLink" rel="' . htmlentities((string) $partner->module) . '"><img src="' . htmlentities((string) $optional_final) . '" /></a>' : '') . '
						</p>
					</div>';
                    $count++;
                }
            }
        }
        libxml_clear_errors();
        if (!empty($return)) {
            $return .= '<br clear="left" />
			<script>
				$(".preactivationLink").click(function() {
					var module = $(this).attr("rel");
					var ajaxCurrentIndex = "' . str_replace('index', 'ajax-tab', self::$currentIndex) . '";
					try
					{
						resAjax = $.ajax({
								type:"POST",
								url : ajaxCurrentIndex,
								async: true,
								data : {
									ajax : "1",
									controller : "AdminHome",
									action : "savePreactivationRequest",
									module : module,
								},
								success : function(data)
								{
								},
								error: function(res,textStatus,jqXHR)
								{
								}
						});
					}
					catch(e){}
				});
			</script>';
        }
        return $return;
    }
 /**
  * Display form on module page configuration
  * @return string
  */
 private function displayForm()
 {
     $checked_auto = '';
     $checked_delayed = '';
     $checked_realvault_yes = '';
     $checked_realvault_no = '';
     $checked_cvn_yes = '';
     $checked_cvn_no = '';
     $checked_liability_yes = '';
     $checked_liability_no = '';
     if (Tools::getValue('settlement') == 'auto') {
         $checked_auto = "checked='checked'";
     } elseif (Tools::getValue('settlement') == 'delayed') {
         $checked_delayed = "checked='checked'";
     } elseif ($this->settlement == 'auto') {
         $checked_auto = "checked='checked'";
     } elseif ($this->settlement == 'delayed') {
         $checked_delayed = "checked='checked'";
     }
     if (Tools::getValue('realvault') == '1') {
         $checked_realvault_yes = "checked='checked'";
     } elseif (Tools::getValue('realvault') != '' && Tools::getValue('realvault') == '0') {
         $checked_realvault_no = "checked='checked'";
     } elseif ($this->realvault == '1') {
         $checked_realvault_yes = "checked='checked'";
     } elseif ($this->realvault == '0') {
         $checked_realvault_no = "checked='checked'";
     }
     if (Tools::getValue('cvn') == '1') {
         $checked_cvn_yes = "checked='checked'";
     } elseif (Tools::getValue('cvn') != '' && Tools::getValue('cvn') == '0') {
         $checked_cvn_no = "checked='checked'";
     } elseif ($this->cvn == '1') {
         $checked_cvn_yes = "checked='checked'";
     } elseif ($this->cvn == '0') {
         $checked_cvn_no = "checked='checked'";
     }
     if (Tools::getValue('liability') == '1') {
         $checked_liability_yes = "checked='checked'";
     } elseif (Tools::getValue('liability') != '' && Tools::getValue('liability') == '0') {
         $checked_liability_no = "checked='checked'";
     } elseif ($this->liability == '1') {
         $checked_liability_yes = "checked='checked'";
     } elseif ($this->liability == '0') {
         $checked_liability_no = "checked='checked'";
     }
     if (Configuration::get('PS_SSL_ENABLED')) {
         $link_site = Tools::getShopDomainSsl();
     } else {
         $link_site = Tools::getShopDomain();
     }
     $link_request = Tools::getShopProtocol() . $link_site . '/module/realexredirect/payment';
     $link_response = $this->url_validation;
     $this->html .= '<form action="' . Tools::htmlentitiesUTF8($_SERVER['REQUEST_URI']) . '" method="post">';
     $this->html .= '<fieldset>';
     $this->html .= '<legend><img src="../img/admin/contact.gif" />' . $this->l('Realex Payments information') . '</legend>';
     $this->html .= '<table border="0" width="500" cellpadding="5" cellspacing="0" id="form">';
     $this->html .= '<tr><td colspan="2">' . $this->l('Please specify your realex account details.') . '.<br /><br /></td></tr>';
     $this->html .= '<tr><td width="130" style="height: 35px;vertical-align: top;">' . $this->l('Merchant ID') . '</td>';
     $this->html .= '<td style="vertical-align: top;">';
     $this->html .= '<input type="text" name="merchantId" value="' . htmlentities(Tools::getValue('merchantId', $this->merchant_id), ENT_COMPAT, 'UTF-8') . '" style="width: 300px;" />';
     $this->html .= '</td></tr>';
     $this->html .= '<tr><td width="130" style="height: 35px;vertical-align: top;">' . $this->l('Shared secret') . '</td>';
     $this->html .= '<td style="vertical-align: top;">';
     $this->html .= '<input type="password" name="sharedSecret" value="' . htmlentities(Tools::getValue('sharedSecret', $this->shared_secret), ENT_COMPAT, 'UTF-8') . '" style="width: 300px;" />';
     $this->html .= '<br/><br/></td></tr>';
     $this->html .= '<tr><td width="130" style="height: 35px;vertical-align: top;">' . $this->l('Settlement') . '</td>';
     $this->html .= '<td><input type="radio" name="settlement" ' . $checked_auto . ' value="auto" /> Auto';
     $this->html .= '<br/><input type="radio" name="settlement" ' . $checked_delayed . ' value="delayed" />';
     $this->html .= 'Delayed<br/><em>' . $this->l('If you are using DCC the settlement type will be automatically set to "Auto"') . '</em></td></tr>';
     $this->html .= '<tr><td width="130" style="height: 35px;vertical-align: top;">' . $this->l('RealVault') . '</td>';
     $this->html .= '<td><input type="radio" name="realvault" ' . $checked_realvault_yes . ' value="1" /> Yes <br/>';
     $this->html .= '<input type="radio" name="realvault" ' . $checked_realvault_no . ' value="0" /> No</td></tr>';
     $this->html .= '<tr><td width="130" style="height: 35px;vertical-align: top;">' . $this->l('Request Security Code on tokenised transactions: ') . '</td>';
     $this->html .= '<td><input type="radio" name="cvn" ' . $checked_cvn_yes . ' value="1" /> Yes ';
     $this->html .= '<br/><input type="radio" name="cvn" ' . $checked_cvn_no . ' value="0" /> No</td></tr>';
     $this->html .= '<tr><td width="130" style="height: 35px;vertical-align: top;">' . $this->l('Require Liability Shift on 3DSecure transactions') . '</td>';
     $this->html .= '<td><input type="radio" name="liability" ' . $checked_liability_yes . ' value="1" /> Yes <br/>';
     $this->html .= '<input type="radio" name="liability" ' . $checked_liability_no . ' value="0" /> No</td></tr>';
     $this->html .= '<tr><td colspan="2" align="center">';
     $this->html .= '<input class="button" name="btnSubmit" value="' . $this->l('Update settings') . '" type="submit" /></td></tr>';
     $this->html .= '<tr><td colspan="2"><br/><br/>';
     $this->html .= '<strong>';
     $this->html .= $this->l('Before you can use this module you must supply Realex with the following URL\'s:') . '</strong><br/><br/>';
     $this->html .= '<strong><u>Request</u></strong> = ' . $link_request . '<br/><br/>';
     $this->html .= '<strong><u>Response</u></strong> = ' . $link_response . '<br/>';
     $this->html .= '</td></tr>';
     $this->html .= '</table>';
     $this->html .= '</fieldset></form>';
     $this->html .= '<br/><br/>';
     $this->html .= '<fieldset><legend><img src="../img/admin/contact.gif" />' . $this->l('Realex Payments subaccounts') . '</legend>';
     if (!empty($this->edit_account)) {
         $this->html .= $this->edit_account;
     } else {
         $this->html .= $this->getAccount();
         $this->html .= '<br/><br/>';
         $this->html .= '<form action="' . Tools::htmlentitiesUTF8($_SERVER['REQUEST_URI']) . '" method="post">';
         $this->html .= '<table border="0" cellpadding="5" cellspacing="0"';
         $this->html .= 'id="form" style="padding:10px; border: 1px solid #606062; background:#F4F6F9">';
         $this->html .= '<tr><td style="height: 35px;vertical-align: top;" colspan="2"><strong><strong>' . $this->l('Add a sub-account') . '</strong></strong></td></tr>';
         $this->html .= '<tr><td style="height: 35px;vertical-align: top;"><strong>' . $this->l('Sub-account') . ':</strong></td>';
         $this->html .= '<td style="vertical-align: top;"><input type="text" name="subAccount"  style="width: 300px;" /></tr>';
         $this->html .= '<tr><td><strong>' . $this->l('Cards') . ':</strong></td><td>';
         $this->html .= '<input type="checkbox" value="VISA" name="type_card[]" /> Visa - ';
         $this->html .= '<input type="checkbox" value="MC" name="type_card[]"/> MasterCard - ';
         $this->html .= '<input type="checkbox" value="LASER" name="type_card[]"/> Laser - ';
         $this->html .= '<input type="checkbox" value="SWITCH" name="type_card[]"/> Switch - ';
         $this->html .= '<input type="checkbox" value="AMEX" name="type_card[]"/> American Express - ';
         $this->html .= '<input type="checkbox" value="DELTA" name="type_card[]"/> Delta - ';
         $this->html .= '<input type="checkbox" value="DINERS" name="type_card[]"/> Diners - ';
         $this->html .= '<input type="checkbox" value="SOLO" name="type_card[]"/> Solo ';
         $this->html .= '&nbsp;  &nbsp;  &nbsp; </td></tr>';
         $this->html .= '<tr><td width="130" style="height: 35px;vertical-align: top;">';
         $this->html .= '<strong>' . $this->l('3D secure') . ':</strong></td>';
         $this->html .= '<td><input type="radio" name="threeds" value="0" checked="checked" /> ' . $this->l('No') . '<br/>';
         $this->html .= '<input type="radio" name="threeds" value="1" /> ' . $this->l('Yes') . ' </td></tr>';
         $this->html .= '<tr><td width="130" style="height: 35px;vertical-align: top;">';
         $this->html .= '<strong>' . $this->l('Dynamic Currency Conversion (DCC)') . ':</strong></td>';
         $this->html .= '<td><input type="radio" name="dcc" value="0" checked="checked" /> ' . $this->l('No') . '<br/>';
         $this->html .= '<input type="radio" name="dcc" value="1" /> ' . $this->l('Yes') . ' <br/><br/>';
         $this->html .= '<input type="radio" name="dcc_choice" value="fexco" checked="checked" /> ' . $this->l('fexco') . '<br/>';
         $this->html .= '<input type="radio" name="dcc_choice" value="euroconex" /> ' . $this->l('euroconex') . '</td></tr>';
         $this->html .= '<tr><td colspan="2" align="center"><br/>';
         $this->html .= '<input class="button" name="btnSubmitAccount" value="' . $this->l('Save') . '" type="submit" /></td></tr>';
         $this->html .= '</table></form>';
     }
     $this->html .= '</fieldset>';
 }
Example #14
0
    public function hookFooter($params)
    {
        $html = '';
        if (!isset($params['cookie']->id_guest)) {
            Guest::setNewGuest($params['cookie']);
            if (Configuration::get('PS_STATSDATA_PLUGINS')) {
                $this->context->controller->addJS($this->_path . 'js/plugindetect.js');
                $token = sha1($params['cookie']->id_guest . _COOKIE_KEY_);
                $html .= '
				<script type="text/javascript">
					$(document).ready(function() {
						plugins = new Object;
						plugins.adobe_director = (PluginDetect.getVersion("Shockwave") != null) ? 1 : 0;
						plugins.adobe_flash = (PluginDetect.getVersion("Flash") != null) ? 1 : 0;
						plugins.apple_quicktime = (PluginDetect.getVersion("QuickTime") != null) ? 1 : 0;
						plugins.windows_media = (PluginDetect.getVersion("WindowsMediaPlayer") != null) ? 1 : 0;
						plugins.sun_java = (PluginDetect.getVersion("java") != null) ? 1 : 0;
						plugins.real_player = (PluginDetect.getVersion("RealPlayer") != null) ? 1 : 0;

						navinfo = { screen_resolution_x: screen.width, screen_resolution_y: screen.height, screen_color:screen.colorDepth};
						for (var i in plugins)
							navinfo[i] = plugins[i];
						navinfo.type = "navinfo";
						navinfo.id_guest = "' . (int) $params['cookie']->id_guest . '";
						navinfo.token = "' . $token . '";
						$.post("' . Context::getContext()->link->getPageLink('statistics', (bool) (Tools::getShopProtocol() == 'https://')) . '", navinfo);
					});
				</script>';
            }
        }
        // Record the guest path then increment the visit counter of the page
        $token_array = Connection::setPageConnection($params['cookie']);
        ConnectionsSource::logHttpReferer();
        if (Configuration::get('PS_STATSDATA_PAGESVIEWS')) {
            Page::setPageViewed($token_array['id_page']);
        }
        if (Configuration::get('PS_STATSDATA_CUSTOMER_PAGESVIEWS')) {
            // Ajax request sending the time spend on the page
            $token = sha1($token_array['id_connections'] . $token_array['id_page'] . $token_array['time_start'] . _COOKIE_KEY_);
            $html .= '
			<script type="text/javascript">
				var time_start;
				$(window).load(
					function() {
						time_start = new Date();
					}
				);
				$(window).unload(
					function() {
						var time_end = new Date();
						var pagetime = new Object;
						pagetime.type = "pagetime";
						pagetime.id_connections = "' . (int) $token_array['id_connections'] . '";
						pagetime.id_page = "' . (int) $token_array['id_page'] . '";
						pagetime.time_start = "' . $token_array['time_start'] . '";
						pagetime.token = "' . $token . '";
						pagetime.time = time_end-time_start;
						$.post("' . Context::getContext()->link->getPageLink('statistics', (bool) (Tools::getShopProtocol() == 'https://')) . '", pagetime);
					}
				);
			</script>';
        }
        return $html;
    }
Example #15
0
 public function getBadgeImgUrl()
 {
     return Tools::getShopProtocol() . self::BAGDE_IMG_URL . '/' . (int) $this->id_ps_badge . '/' . (int) $this->validated . '.png';
 }
Example #16
0
 public function getImage()
 {
     if (!Validate::isLoadedObject($this)) {
         return Tools::getAdminImageUrl('prestashop-avatar.png');
     }
     return Tools::getShopProtocol() . 'profile.prestashop.com/' . urlencode($this->email) . '.jpg';
 }
 private function createNewOrder()
 {
     // URL for back payment transaction
     // --------------------------------
     $current_uri = Tools::getShopProtocol() . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'];
     $current_uri .= '?controller=' . $this->context->controller->controller_name;
     $current_uri .= '&order_session=%%session%%';
     $current_token = '&token=' . Tools::getAdminTokenLite($this->context->controller->controller_name);
     $order_session = null;
     $parameters = array('application_id' => $this->session_api->application_id, 'cart_source' => 'Prestashop', 'account_email' => Configuration::get('PS_SHOP_EMAIL'), 'country_iso' => $this->context->language->iso_code, 'back_url_success' => $current_uri . '&success' . $current_token, 'back_url_error' => $current_uri . '&error' . $current_token);
     // account_id can be different for email, sms or fax
     // -------------------------------------------------
     $product = (string) Tools::getValue('product');
     if (Tools::strpos($product, 'fax-') !== false) {
         if ($this->session_api->connectFromCredentials('fax')) {
             $parameters['account_id'] = $this->session_api->account_id;
         }
     } elseif (Tools::strpos($product, 'sms-') !== false) {
         if ($this->session_api->connectFromCredentials('sms')) {
             $parameters['account_id'] = $this->session_api->account_id;
         }
     } else {
         if ($this->session_api->connectFromCredentials('email')) {
             $parameters['account_id'] = $this->session_api->account_id;
         }
     }
     // Create the order
     // ----------------
     if ($this->session_api->callExternal('http://www.express-mailing.com/api/cart/ws.php', 'common', 'order', 'initialize', $parameters, $order_session)) {
         $this->order_session = $order_session;
     } else {
         $this->errors[] = sprintf($this->module->l('Unable to create a cart : %s'), $this->session_api->getError());
         return false;
     }
     // Store the order_session into local database
     // -------------------------------------------
     Db::getInstance()->insert('expressmailing_order_cart', array('order_session' => pSQL($this->order_session), 'order_product' => pSQL($this->order_product), 'campaign_media' => pSQL($this->media), 'campaign_id' => (int) $this->campaign_id));
     // Add the product into the cart
     // -----------------------------
     $response_array = array();
     $parameters = array('order_session' => $this->order_session, 'product_ref' => $this->order_product, 'product_quantity' => 1);
     if ($this->session_api->callExternal('http://www.express-mailing.com/api/cart/ws.php', 'common', 'order', 'add', $parameters, $response_array)) {
         $this->context->smarty->assign('cart', $response_array);
         return true;
     } else {
         $this->errors[] = sprintf($this->module->l('Unable to create a cart : %s'), $this->session_api->getError());
         return false;
     }
     return false;
 }