本文整理汇总了PHP中Tools::getIsset方法的典型用法代码示例。如果您正苦于以下问题:PHP Tools::getIsset方法的具体用法?PHP Tools::getIsset怎么用?PHP Tools::getIsset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tools
的用法示例。
在下文中一共展示了Tools::getIsset方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postProcess
public function postProcess()
{
parent::postProcess();
// Déconnexion
if (Tools::getIsset('logout')) {
Auth::disconnect();
Flash::add('Vous êtes bien déconnécté');
Tools::redirect($this->context->link->getPageLink('auth'));
} elseif (Tools::isSubmit('submitLogin')) {
$user = (new User())->getByEmail(Tools::getValue('username'), Tools::getValue('password'));
if (!Validate::isLoadedObject($user)) {
$this->errors[] = 'Identifiant ou mot de passe incorrect';
} else {
Auth::setUser($user);
Tools::redirect($this->context->link->getPageLink('comments'));
}
} elseif (Tools::isSubmit('submitSubscribe')) {
/**
* - Vérification des champs
* - Verification non-existant
* - Inscription
* - Login
*/
if (!Validate::isEmail($email = Tools::getValue('username'))) {
return $this->errors[] = 'Veuillez saisir une adresse e-mail correcte';
}
if (!Validate::isPasswd($password = Tools::getValue('password'))) {
/// @todo être plus spécifique sur les règles de mot de passes valides
return $this->errors[] = 'Veuillez saisir un mot de passe correct';
}
$user = new User();
if (Validate::isLoadedObject($user->getByEmail($email))) {
$this->errors[] = 'Un compte avec cet identifiant existe déjà';
} else {
$user->login = $email;
$user->password = Tools::encrypt($password);
if (!$user->save()) {
$this->errors[] = 'Impossible de vous enregistrer, veuillez réessayer ultérieurement (' . Db::getInstance()->getMsgError() . ')';
} else {
Auth::setUser($user);
Flash::success('Bienvenue! Votre compte a bien été créé');
Tools::redirect($this->context->link->getPageLink('comments'));
}
}
} elseif (Auth::getUser()) {
Tools::redirect($this->context->link->getPageLink('comments'));
}
}
示例2: initContent
/**
* Assign template vars related to page content
* @see FrontController::initContent()
*/
public function initContent()
{
parent::initContent();
$this->productSort();
// Override default configuration values: cause the new products page must display latest products first.
if (!Tools::getIsset('orderway') || !Tools::getIsset('orderby')) {
$this->orderBy = 'date_add';
$this->orderWay = 'DESC';
}
$nbProducts = (int) Product::getNewProducts($this->context->language->id, null, null, true);
$this->pagination($nbProducts);
$products = Product::getNewProducts($this->context->language->id, (int) $this->p - 1, (int) $this->n, false, $this->orderBy, $this->orderWay);
$this->addColorsToProductList($products);
$this->context->smarty->assign(array('HOOK_LEFT_COLUMN' => Hook::exec('displayLeftColumn'), 'products' => $products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'nbProducts' => (int) $nbProducts, 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'comparator_max_item' => Configuration::get('PS_COMPARATOR_MAX_ITEM')));
if ($this->ajax) {
$product_list = $this->context->smarty->fetch(_PS_THEME_DIR_ . 'product-list.tpl');
$pagination = $this->context->smarty->fetch(_PS_THEME_DIR_ . 'pagination.tpl');
$nbLeftProducts = $nbProducts - ($this->n * ($this->p - 1) + count($products));
$nbLeftProductsPercentage = ($nbProducts - $nbLeftProducts) / $nbProducts * 100;
echo Tools::jsonEncode(array('productList' => utf8_encode($product_list), 'pagination' => $pagination, 'nbRenderedProducts' => $nbProducts, 'nbLeftProducts' => $nbLeftProducts, 'nbLeftProductsPercentage' => $nbLeftProductsPercentage));
die;
} else {
$this->setTemplate(_PS_THEME_DIR_ . 'new-products.tpl');
}
}
示例3: renderForm
public function renderForm($args, $data)
{
# validate module
unset($args);
$this->checkFolderImage();
$helper = $this->getFormHelper();
$items = '';
$slide_edit = '';
if ($data['params'] && isset($data['params']['leoslide']) && $data['params']['leoslide']) {
$slides = $data['params']['leoslide'];
$items = $this->getSlide($slides);
if (Tools::getValue('id_slide')) {
$id_slide = Tools::getValue('id_slide');
$slide_edit = $items[$id_slide] ? $items[$id_slide] : '';
}
}
$this->fields_form[1]['form'] = array('legend' => array('title' => $this->l('Carousel Form.')), 'input' => array(array('type' => 'text', 'label' => $this->l('Image Size Width'), 'name' => 'img_width', 'default' => 1170), array('type' => 'text', 'label' => $this->l('Image size Height'), 'name' => 'img_height', 'default' => 400), array('type' => 'text', 'label' => $this->l('Thumb Size Width'), 'name' => 'thumb_width', 'default' => 100), array('type' => 'text', 'label' => $this->l('Thumb size Height'), 'name' => 'thumb_height', 'default' => 100), array('type' => 'text', 'label' => $this->l('Interval'), 'name' => 'interval', 'default' => 8000)), 'buttons' => array(array('title' => $this->l('Save And Stay'), 'icon' => 'process-icon-save', 'class' => 'pull-right', 'type' => 'submit', 'name' => 'saveandstayleotempcp'), array('title' => $this->l('Save'), 'icon' => 'process-icon-save', 'class' => 'pull-right', 'type' => 'submit', 'name' => 'saveleotempcp')));
if (Tools::getIsset('addleowidgets')) {
$this->fields_form[1]['form']['input'][] = array('type' => 'html', 'name' => 'html', 'default' => '', 'html_content' => '<div class="alert alert-info">' . $this->l('Please Click save to input image') . '</div>');
} else {
$this->fields_form[1]['form']['input'][] = array('type' => 'slide', 'name' => 'slide', 'lang' => true, 'selectImg' => Context::getContext()->link->getAdminLink('AdminLeomanagewidgetsImages'), 'tree' => '', 'default' => '');
}
$theme_dir = Context::getContext()->shop->theme_directory;
$images = array();
$thums = array();
$images = LeoWidgetBase::getImageList(_PS_ROOT_DIR_ . '/themes/' . $theme_dir . '/img/modules/' . $this->name . '/image');
$thums = LeoWidgetBase::getImageList(_PS_ROOT_DIR_ . '/themes/' . $theme_dir . '/img/modules/' . $this->name . '/thum');
$iso = Context::getContext()->language->iso_code;
$helper->tpl_vars = array('fields_value' => $this->getConfigFieldsValues($data), 'languages' => Context::getContext()->controller->getLanguages(), 'id_lang_default' => Configuration::get('PS_LANG_DEFAULT'), 'iso_code' => Context::getContext()->language->iso_code, 'iso' => file_exists(_PS_CORE_DIR_ . '/js/tiny_mce/langs/' . $iso . '.js') ? $iso : 'en', 'path_css' => _THEME_CSS_DIR_, 'ad' => __PS_BASE_URI__ . basename(_PS_ADMIN_DIR_), 'images' => $images, 'thums' => $thums, 'items' => $items, 'slide_edit' => $slide_edit, 'url' => AdminController::$currentIndex . '&id_leowidgets=' . Tools::getValue('id_leowidgets') . '&updateleowidgets&token=' . Tools::getValue('token') . '&conf=4', 'pathimg' => __PS_BASE_URI__ . 'themes/' . $theme_dir . '/img/modules/' . $this->name . '/image/', 'paththum' => __PS_BASE_URI__ . 'themes/' . $theme_dir . '/img/modules/' . $this->name . '/thum/');
return $helper->generateForm($this->fields_form);
}
示例4: __construct
public function __construct()
{
$notificationCode = Tools::getValue('notificationCode');
$this->transaction_code = Tools::getIsset($notificationCode) && trim(Tools::getValue('notificationCode')) !== '' ? trim(Tools::getValue('notificationCode')) : null;
$this->createCredential();
$this->createTransaction();
}
示例5: process
public function process()
{
if (Tools::getIsset('DOCUMENT')) {
$data = Tools::getValue('DOCUMENT');
$result = OpenPayU_Order::consumeMessage($data, false);
if ($result->getMessage() == 'ShippingCostRetrieveRequest') {
$id_payu_session = $result->getSessionId();
$iso_country_code = $result->getCountryCode();
$payu = new PayU();
$order_payment = $payu->getOrderPaymentBySessionId($id_payu_session);
$id_cart = $order_payment['id_cart'];
if (!empty($id_cart)) {
$payu->id_cart = $id_cart;
$payu->payu_order_id = $id_payu_session;
$payu->id_request = $result->getReqId();
$xml = $payu->shippingCostRetrieveRequest($iso_country_code);
if (!empty($xml)) {
header('Content-Type:text/xml');
echo $xml;
}
}
}
}
exit;
}
示例6: initContent
public function initContent()
{
parent::initContent();
$this->productSort();
// Override default configuration values: cause the new products page must display latest products first.
if (!Tools::getIsset('orderway') || !Tools::getIsset('orderby')) {
$this->orderBy = 'date_add';
$this->orderWay = 'DESC';
}
$nb_products = (int) Product::getNewProducts($this->context->language->id, isset($this->p) ? (int) $this->p - 1 : null, isset($this->n) ? (int) $this->n : null, true);
$this->pagination($nb_products);
$products = Product::getNewProducts($this->context->language->id, (int) $this->p - 1, (int) $this->n, false, $this->orderBy, $this->orderWay);
$this->addColorsToProductList($products);
/************************* /Images Array ******************************/
if (method_exists('Product', 'getProductsImgs')) {
$image_array = array();
for ($i = 0; $i < $nb_products; $i++) {
if (isset($products[$i]['id_product'])) {
$image_array[$products[$i]['id_product']] = Product::getProductsImgs($products[$i]['id_product']);
}
}
$this->context->smarty->assign('productimg', (isset($image_array) and $image_array) ? $image_array : NULL);
}
/************************* /Images Array ******************************/
$this->context->smarty->assign(array('products' => $products, 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'nbProducts' => (int) $nb_products, 'homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'comparator_max_item' => Configuration::get('PS_COMPARATOR_MAX_ITEM')));
$this->setTemplate(_PS_THEME_DIR_ . 'new-products.tpl');
}
示例7: __construct
public function __construct()
{
// Set variables
$this->table = 'mymod_comment';
$this->className = 'MyModComment';
$this->fields_list = array('id_mymod_comment' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'shop_name' => array('title' => $this->l('Shop'), 'width' => 120, 'filter_key' => 's!name'), 'firstname' => array('title' => $this->l('Firstname'), 'width' => 120), 'lastname' => array('title' => $this->l('Lastname'), 'width' => 140), 'email' => array('title' => $this->l('E-mail'), 'width' => 150), 'product_name' => array('title' => $this->l('Product'), 'width' => 100, 'filter_key' => 'pl!name'), 'grade_display' => array('title' => $this->l('Grade'), 'align' => 'right', 'width' => 80, 'filter_key' => 'a!grade'), 'comment' => array('title' => $this->l('Comment'), 'search' => false), 'date_add' => array('title' => $this->l('Date add'), 'type' => 'date'));
// Set fields form for form view
$this->context = Context::getContext();
$this->context->controller = $this;
$this->fields_form = array('legend' => array('title' => $this->l('Add / Edit Comment'), 'image' => '../img/admin/contact.gif'), 'input' => array(array('type' => 'text', 'label' => $this->l('Firstname'), 'name' => 'firstname', 'size' => 30, 'required' => true), array('type' => 'text', 'label' => $this->l('Lastname'), 'name' => 'lastname', 'size' => 30, 'required' => true), array('type' => 'text', 'label' => $this->l('E-mail'), 'name' => 'email', 'size' => 30, 'required' => true), array('type' => 'select', 'label' => $this->l('Product'), 'name' => 'id_product', 'required' => true, 'default_value' => 1, 'options' => array('query' => Product::getProducts($this->context->cookie->id_lang, 1, 1000, 'name', 'ASC'), 'id' => 'id_product', 'name' => 'name')), array('type' => 'text', 'label' => $this->l('Grade'), 'name' => 'grade', 'size' => 30, 'required' => true, 'desc' => $this->l('Grade must be between 1 and 5')), array('type' => 'textarea', 'label' => $this->l('Comment'), 'name' => 'comment', 'cols' => 50, 'rows' => 5, 'required' => false)), 'submit' => array('title' => $this->l('Save')));
// Enable bootstrap
$this->bootstrap = true;
// Call of the parent constructor method
parent::__construct();
// Update the SQL request of the HelperList
$this->_select = "s.`name` as shop_name, pl.`name` as product_name, CONCAT(a.`grade`, '/5') as grade_display";
$this->_join = 'LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (pl.`id_product` = a.`id_product` AND pl.`id_lang` = ' . (int) $this->context->language->id . ' AND pl.`id_shop` = a.`id_shop`)
LEFT JOIN `' . _DB_PREFIX_ . 'shop` s ON (s.`id_shop` = a.`id_shop`)';
// Add actions
$this->addRowAction('view');
$this->addRowAction('delete');
$this->addRowAction('edit');
// Add bulk actions
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Would you like to delete the selected items?')), 'myaction' => array('text' => $this->l('My Action'), 'confirm' => $this->l('Are you sure?')));
// Define meta and toolbar title
$this->meta_title = $this->l('Comments on Product');
if (Tools::getIsset('viewmymod_comment')) {
$this->meta_title = $this->l('View comment') . ' #' . Tools::getValue('id_mymod_comment');
}
$this->toolbar_title[] = $this->meta_title;
}
示例8: run
public function run()
{
// Get number of comments
$id_product = (int) Tools::getValue('id_product');
$nb_comments = MyModComment::getProductNbComments((int) $id_product);
// Init
$page = 1;
$nb_per_page = 10;
$nb_pages = ceil($nb_comments / $nb_per_page);
if (Tools::getIsset('page')) {
$page = (int) Tools::getValue('page');
}
$limit_start = ($page - 1) * $nb_per_page;
$limit_end = $nb_per_page;
// Build actions url
$ajax_action_url = $this->context->link->getAdminLink('AdminModules', true);
$ajax_action_url = str_replace('index.php', 'ajax-tab.php', $ajax_action_url);
$action_url = $this->context->link->getAdminLink('AdminMyModComments', true);
// Get comments
$comments = MyModComment::getProductComments((int) $id_product, (int) $limit_start, (int) $limit_end);
// Assign comments and product object
$this->context->smarty->assign('page', $page);
$this->context->smarty->assign('nb_pages', $nb_pages);
$this->context->smarty->assign('comments', $comments);
$this->context->smarty->assign('action_url', $action_url);
$this->context->smarty->assign('ajax_action_url', $ajax_action_url);
$this->context->smarty->assign('pc_base_dir', __PS_BASE_URI__ . 'modules/' . $this->module->name . '/');
return $this->module->display($this->file, 'displayAdminProductsExtra.tpl');
}
示例9: init
public function init()
{
parent::init();
if (Module::isEnabled('aimultidimensions')) {
if (Tools::getIsset('add') && $this->context->cart->id) {
require_once _PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'aimultidimensions' . DIRECTORY_SEPARATOR . 'aimultidimensions.php';
require_once _PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'aimultidimensions' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'config.php';
require_once _PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'aimultidimensions' . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'functions' . $GLOBALS['aimd_config_suffix'] . '.php';
$add = 1;
$idProduct = (int) Tools::getValue('id_product', NULL);
if (checkLink($idProduct)) {
$idProductAttribute = (int) Tools::getValue('id_product_attribute', Tools::getValue('ipa'));
$customizationId = (int) Tools::getValue('id_customization', 0);
$qty = (int) abs(Tools::getValue('qty', 1));
if ($add && $qty >= 0 && getProducts($idProduct)) {
$quantity = (int) Db::getInstance()->getValue('SELECT quantity FROM ' . _DB_PREFIX_ . 'cart_product WHERE id_cart = ' . $this->context->cart->id . ' AND id_product = ' . $idProduct . ' AND ' . 'id_product_attribute = ' . $idProductAttribute);
if (Tools::getValue('op', 'up') == 'up') {
$quantity += (int) $qty;
} else {
$quantity -= (int) $qty;
}
$cookie = $this->context->cookie;
$cart = $this->context->cart;
include_once 'modules/aimultidimensions/includes/cart.php';
Product::flushPriceCache();
}
}
}
}
}
示例10: renderForm
public function renderForm()
{
if ($this->is_seller && (Tools::getIsset('updatecategory') || Tools::getIsset('addcategory')) && !(int) Configuration::get('AGILE_MS_EDIT_CATEGORY')) {
$this->errors[] = Tools::displayError('You do not have permission to add/edit category');
return;
}
return parent::renderForm();
}
示例11: postProcess
/**
* Set default medias for this controller
*/
public function postProcess()
{
if (Tools::getIsset('product_id')) {
$output = $this->getProductAttributeCombinations(Tools::getValue('product_id'));
echo json_encode($output);
parent::postProcess();
die;
}
}
示例12: ajaxProcessLoadCartRules
public function ajaxProcessLoadCartRules()
{
$type = $token = $search = '';
$limit = $count = $id_cart_rule = 0;
if (Tools::getIsset('limit')) {
$limit = Tools::getValue('limit');
}
if (Tools::getIsset('type')) {
$type = Tools::getValue('type');
}
if (Tools::getIsset('count')) {
$count = Tools::getValue('count');
}
if (Tools::getIsset('id_cart_rule')) {
$id_cart_rule = Tools::getValue('id_cart_rule');
}
if (Tools::getIsset('search')) {
$search = Tools::getValue('search');
}
$page = floor($count / $limit);
$html = '';
$next_link = '';
if ($page * $limit + 1 == $count || $count == 0) {
if ($count == 0) {
$count = 1;
}
/** @var CartRule $current_object */
$current_object = $this->loadObject(true);
$cart_rules = $current_object->getAssociatedRestrictions('cart_rule', false, true, $page * $limit, $limit, $search);
if ($type == 'selected') {
$i = 1;
foreach ($cart_rules['selected'] as $cart_rule) {
$html .= '<option value="' . (int) $cart_rule['id_cart_rule'] . '"> ' . Tools::safeOutput($cart_rule['name']) . '</option>';
if ($i == $limit) {
break;
}
$i++;
}
if ($i == $limit) {
$next_link = Context::getContext()->link->getAdminLink('AdminCartRules') . '&ajaxMode=1&ajax=1&id_cart_rule=' . (int) $id_cart_rule . '&action=loadCartRules&limit=' . (int) $limit . '&type=selected&count=' . ($count - 1 + count($cart_rules['selected']) . '&search=' . urlencode($search));
}
} else {
$i = 1;
foreach ($cart_rules['unselected'] as $cart_rule) {
$html .= '<option value="' . (int) $cart_rule['id_cart_rule'] . '"> ' . Tools::safeOutput($cart_rule['name']) . '</option>';
if ($i == $limit) {
break;
}
$i++;
}
if ($i == $limit) {
$next_link = Context::getContext()->link->getAdminLink('AdminCartRules') . '&ajaxMode=1&ajax=1&id_cart_rule=' . (int) $id_cart_rule . '&action=loadCartRules&limit=' . (int) $limit . '&type=unselected&count=' . ($count - 1 + count($cart_rules['unselected']) . '&search=' . urlencode($search));
}
}
}
echo Tools::jsonEncode(array('html' => $html, 'next_link' => $next_link));
}
示例13: assign
/**
* Assign wishlist template
*/
public function assign()
{
$errors = array();
if ($this->context->customer->isLogged()) {
$add = Tools::getIsset('add');
$add = empty($add) === false ? 1 : 0;
$delete = Tools::getIsset('deleted');
$delete = empty($delete) === false ? 1 : 0;
$id_wishlist = Tools::getValue('id_wishlist');
if (Tools::isSubmit('submitWishlist')) {
if (Configuration::get('PS_TOKEN_ACTIVATED') == 1 and strcmp(Tools::getToken(), Tools::getValue('token'))) {
$errors[] = $this->module->l('Invalid token', 'mywishlist');
}
if (!sizeof($errors)) {
$name = Tools::getValue('name');
if (empty($name)) {
$errors[] = $this->module->l('You must specify a name.', 'mywishlist');
}
if (WishList::isExistsByNameForUser($name)) {
$errors[] = $this->module->l('This name is already used by another list.', 'mywishlist');
}
if (!sizeof($errors)) {
$wishlist = new WishList();
$wishlist->id_shop = $this->context->shop->id;
$wishlist->id_shop_group = $this->context->shop->id_shop_group;
$wishlist->name = $name;
$wishlist->id_customer = (int) $this->context->customer->id;
list($us, $s) = explode(' ', microtime());
srand($s * $us);
$wishlist->token = strtoupper(substr(sha1(uniqid(rand(), true) . _COOKIE_KEY_ . $this->context->customer->id), 0, 16));
$wishlist->add();
Mail::Send($this->context->language->id, 'wishlink', Mail::l('Your wishlist\'s link', $this->context->language->id), array('{wishlist}' => $wishlist->name, '{message}' => Tools::getProtocol() . htmlentities($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . __PS_BASE_URI__ . 'modules/blockwishlist/view.php?token=' . $wishlist->token), $this->context->customer->email, $this->context->customer->firstname . ' ' . $this->context->customer->lastname, NULL, strval(Configuration::get('PS_SHOP_NAME')), NULL, NULL, $this->module->getLocalPath() . 'mails/');
}
}
} else {
if ($add) {
WishList::addCardToWishlist($this->context->customer->id, Tools::getValue('id_wishlist'), $this->context->language->id);
} else {
if ($delete and empty($id_wishlist) === false) {
$wishlist = new WishList((int) $id_wishlist);
if (Validate::isLoadedObject($wishlist)) {
$wishlist->delete();
} else {
$errors[] = $this->module->l('Cannot delete this wishlist', 'mywishlist');
}
}
}
}
$this->context->smarty->assign('wishlists', WishList::getByIdCustomer($this->context->customer->id));
$this->context->smarty->assign('nbProducts', WishList::getInfosByIdCustomer($this->context->customer->id));
} else {
Tools::redirect('index.php?controller=authentication&back=' . urlencode($this->context->link->getModuleLink('blockwishlist', 'mywishlist')));
}
$this->context->smarty->assign(array('id_customer' => (int) $this->context->customer->id, 'errors' => $errors, 'form_link' => $errors));
$this->setTemplate('mywishlist.tpl');
}
示例14: init
/**
* Initialize auth controller
* @see FrontController::init()
*/
public function init()
{
parent::init();
if (!Tools::getIsset('step') && $this->context->customer->isLogged() && !$this->ajax) {
Tools::redirect('index.php?controller=' . ($this->authRedirection !== false ? urlencode($this->authRedirection) : 'my-account'));
}
if (Tools::getValue('create_account')) {
$this->create_account = true;
}
}
示例15: initContent
public function initContent()
{
parent::initContent();
if (Tools::getIsset('collection_id') && Tools::getValue('collection_id') != 'null') {
// payment variables
$payment_statuses = array();
$payment_ids = array();
$payment_types = array();
$payment_method_ids = array();
$card_holder_names = array();
$four_digits_arr = array();
$statement_descriptors = array();
$status_details = array();
$transaction_amounts = 0;
$collection_ids = split(',', Tools::getValue('collection_id'));
foreach ($collection_ids as $collection_id) {
$mercadopago = $this->module;
$mercadopago_sdk = $mercadopago->mercadopago;
$result = $mercadopago_sdk->getPayment($collection_id);
$payment_info = $result['response']['collection'];
$id_cart = $payment_info['external_reference'];
$cart = new Cart($id_cart);
$payment_statuses[] = $payment_info['status'];
$payment_ids[] = $payment_info['id'];
$payment_types[] = $payment_info['payment_type'];
$payment_method_ids[] = $payment_info['payment_method_id'];
$transaction_amounts += $payment_info['transaction_amount'];
if ($payment_info['payment_type'] == 'credit_card') {
$card_holder_names[] = $payment_info['cardholder']['name'];
$four_digits_arr[] = '**** **** **** ' . $payment_info['last_four_digits'];
$statement_descriptors[] = $payment_info['statement_descriptor'];
$status_details[] = $payment_info['status_detail'];
}
}
if (Validate::isLoadedObject($cart)) {
$order_id = Order::getOrderByCartId($cart->id);
$order = new Order($order_id);
$uri = __PS_BASE_URI__ . 'order-confirmation.php?id_cart=' . $order->id_cart . '&id_module=' . $mercadopago->id . '&id_order=' . $order->id . '&key=' . $order->secure_key;
$uri .= '&payment_status=' . $payment_statuses[0];
$uri .= '&payment_id=' . join(" / ", $payment_ids);
$uri .= '&payment_type=' . join(" / ", $payment_types);
$uri .= '&payment_method_id=' . join(" / ", $payment_method_ids);
$uri .= '&amount=' . $transaction_amounts;
if ($payment_info['payment_type'] == 'credit_card') {
$uri .= '&card_holder_name=' . join(" / ", $card_holder_names);
$uri .= '&four_digits=' . join(" / ", $four_digits_arr);
$uri .= '&statement_descriptor=' . $statement_descriptors[0];
$uri .= '&status_detail=' . $status_details[0];
}
Tools::redirectLink($uri);
}
} else {
error_log('External reference is not set. Order placement has failed.');
}
}